Linux File System Explained — From Root to Kernel

Listen to this Post

The Linux file system is a hierarchical structure that organizes and manages files and directories. Understanding its layout is crucial for system administration, troubleshooting, and efficient navigation. Below is a detailed breakdown of the key directories and their purposes:

Key Directories in Linux File System

1. / (root)

The starting point of the entire file system. Everything branches from here.

2. /bin

Contains essential command-line binaries like ls, cp, and mv. These commands are available to all users.

3. /sbin

Houses system administration binaries such as `shutdown` and mount. These are typically used by the root user or system administrators.

4. /etc

Configuration files for the system and installed applications. Think of it as the system’s control center.

5. /home

User-specific directories. Each user gets a folder, e.g., /home/arif, /home/data_user.

6. /usr

Contains user-level programs, libraries, and documentation. It’s akin to the “Program Files” directory in Windows.

7. /var

Stores variable files like logs (/var/log), mail, and cache. This directory changes frequently.

8. /tmp

Temporary files used by applications. Files here are automatically cleared on reboot.

9. /lib

Essential system libraries required for `/bin` and `/sbin` binaries to function.

10. /opt

Optional software packages and third-party applications are installed here.

11. /dev

Represents hardware devices like disks and USBs. For example, `/dev/sda1` refers to the first partition on the first hard drive.

12. /proc

A virtual directory providing kernel and process information. Check memory or CPU usage here.

13. /mnt and /media

Mount points for external drives and file systems.

14. /boot

Contains bootloader and kernel files. Without this, Linux won’t start.

15. /root

Home directory for the root user (admin). This is different from /.

You Should Know: Practical Commands and Steps

1. Navigating the File System

Use the `cd` command to change directories and `ls` to list contents.

Example:

cd / 
ls -l

2. Viewing System Logs

System logs are stored in /var/log. Use `cat` or `tail` to view them.

Example:

tail -f /var/log/syslog

3. Mounting a File System

Use the `mount` command to attach a file system.

Example:

sudo mount /dev/sdb1 /mnt

4. Checking Disk Usage

The `df` command shows disk space usage.

Example:

df -h

5. Managing Processes

Use `ps` to view running processes and `kill` to terminate them.

Example:

ps aux 
kill -9 <PID>

6. Creating and Deleting Directories

Use `mkdir` to create and `rmdir` to delete directories.

Example:

mkdir /home/user/newdir 
rmdir /home/user/newdir

7. Editing Configuration Files

Use `nano` or `vim` to edit files in /etc.

Example:

sudo nano /etc/nginx/nginx.conf

8. Clearing Temporary Files

Files in `/tmp` are temporary. You can manually clear them using:

sudo rm -rf /tmp/*

9. Checking Hardware Information

Use `lshw` or `lsblk` to view hardware details.

Example:

sudo lshw

10. Rebooting the System

Use the `reboot` command to restart the system.

Example:

sudo reboot

What Undercode Say

Understanding the Linux file system is fundamental for anyone working with Linux, whether you’re a system administrator, developer, or enthusiast. The hierarchical structure ensures organized data management, while the commands and tools provided allow for efficient system control and troubleshooting. By mastering these concepts and commands, you can unlock the full potential of Linux and streamline your workflow.

Expected Output:

  • Navigate and explore the Linux file system using `cd` and ls.
  • Manage system logs and processes with tail, ps, and kill.
  • Mount and unmount file systems using `mount` and umount.
  • Monitor disk usage and hardware information with `df` and lshw.
  • Edit configuration files in `/etc` using `nano` or vim.
  • Clear temporary files in `/tmp` to free up space.

By following these steps and commands, you can effectively manage and optimize your Linux system.

References:

Reported By: Iamarifalam %F0%9D%97%9F%F0%9D%97%B6%F0%9D%97%BB%F0%9D%98%82%F0%9D%98%85 – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image