DEV Community

Cover image for Root Directory in Linux
Shiva Charan
Shiva Charan

Posted on

Root Directory in Linux

Root Directory

In simple terms, the Root Directory is the starting point for every single file and folder on a Linux system. It is represented by a single forward slash (/).


🌳 1. The Starting Point

Unlike Windows, which uses different drive letters (like C: or D:), Linux puts everything into one giant "tree" structure.

The Root Directory is the trunk of that tree, and all other folders are "children" that branch out from it.

Example:

/
β”œβ”€β”€ bin
β”œβ”€β”€ boot
β”œβ”€β”€ dev
β”œβ”€β”€ etc
β”œβ”€β”€ home
└── usr
Enter fullscreen mode Exit fullscreen mode

πŸš€ 2. Essential for Booting

The computer cannot start up without the Root Directory.

The partition containing this directory is the very first thing "mounted" (attached to the system) when you turn on the computer.

If the system cannot find it, it will not boot.


πŸ“‚ 3. Standard Folders inside Root

To keep systems organized and consistent, there is a set of standard folders that are required to be inside the Root Directory.


πŸ”Ή /bin

Essential programs that everyone can use.

  • Essential Command Binaries: This directory contains fundamental system programs that must be available to all users. These tools, such as ls, cp, and cat, are considered essential because they are needed even when only the root partition is mounted, such as during system repair or in single-user mode.

πŸ”Ή /boot

The files needed to start the computer.

  • (Static Files of the Boot Loader): This folder stores everything required for the boot process except for certain boot-loader configuration files. It contains the system kernel, sector/system map files, and other data used before the kernel begins executing programs.

πŸ”Ή /dev

Special files that represent your hardware (like your mouse or hard drive).

  • (Device Files): This is the location for special files that represent your hardware. In Linux, everything is treated as a file; for example, /dev/hda1 represents a hard drive partition, while /dev/dsp represents your speakers.

πŸ”Ή /etc

The "nerve center" containing all your system settings and configuration files.

  • (Host-Specific System Configuration): Known as the "nerve center" of the system, this directory contains all static configuration files used to control program operations. It does not contain any binary programs.

πŸ”Ή /lib

Essential shared libraries and kernel modules required for core system programs to run.

  • (Essential Shared Libraries and Kernel Modules): This directory holds the code libraries (similar to DLLs in Windows) that are absolutely necessary to boot the system and run the commands found in /bin and /sbin. It also houses kernel modules, which act as hardware drivers.

πŸ”Ή media

Used for automatically mounted removable devices like USB drives and CDs/DVDs.

  • (Mount Point for Removable Media): This directory provides a standard location for mounting removable devices like floppy disks, CD-ROMs, and zip disks. Historically, these were scattered in various places, but /media was created to keep the root directory tidy.

πŸ”Ή mnt

A temporary location used by administrators to manually mount filesystems.

  • (Mount Point for Temporary Filesystems): This is a generic directory provided so that a system administrator can temporarily mount a filesystem as needed.

πŸ”Ή opt

Stores optional or third-party software packages and applications.

  • (Add-on Application Software Packages): This area is reserved for third-party software and add-on packages that are not part of the default system installation, such as office suites or web browsers.

πŸ”Ή /home

Where users keep their personal files (this is actually optional, but very common).


πŸ”Ή /root

The private home folder for the system administrator.


πŸ”Ή /sbin

Important tools used specifically for system maintenance and repair.

  • (Essential System Binaries): Similar to /bin, this directory contains binaries essential to the system's operation, but these are primarily intended for system maintenance and administrative tasks performed by the root user.

πŸ”Ή srv

Contains data used by services provided by the system, such as web or FTP servers.

  • (Data for Services Provided by the System): This directory contains site-specific data that is served by the system, such as files for web or FTP services.

πŸ”Ή /tmp

A place for programs to store files temporarily while they are running.

  • (Temporary Files): Programs use this directory to store data they only need temporarily. Files here are usually cleared out whenever the system is booted or shut down.

πŸ”Ή /usr

Usually the largest folder; it contains most of the user's programs and documentation.

  • (Secondary Hierarchy): This is typically the largest directory on the system, containing the vast majority of user binaries, documentation, and libraries. It is intended to contain shareable, read-only data.

πŸ”Ή /var

Holds data that changes constantly, like system logs and emails.

  • (Variable Data): This directory stores files that change constantly during normal system operation. This includes system logs, mail spools, and printer queues.

🧹 4. Tidy Organization

Historically, the system administrator's personal files were kept directly in the Root Directory, but modern standards now give the administrator their own separate folder (/root) to keep the main Root Directory tidy and organized.

Top comments (0)