If you are a newbie and are planning to play around with the files in Linux, you need to stop right now. Understanding the file system and directories in Linux for beginners or someone who has very little experience working with Linux can be quite difficult. This is because you have access to all the configuration and system files due to the flexibility that Linux provides to its users. In fact, if you are a root user or someone with sudo privileges, you might even have access to these files and will be able to make changes to them. Linux allows its users to customize the operating system to any extent they want. 

You can make changes in configuration files to customize a message to welcome you or run a script every time you open a bash or log in. Although the ability to allow customizations to its users is a major reason why people switch from Windows or other OS to Linux, however, this might be a pain if you try to fiddle around with absolutely no knowledge. You might find yourself deleting critical system files or directories and may even crash the system.

Hence, it’s important that you know and understand the important directories and files in Linux and have a basic or fundamental knowledge of what purpose they serve. This is beneficial because later if you want to search for a file or want to make some configuration changes, you will know which directory to visit or which file to open.

In this comprehensive guide, we will discuss some of the most important directories in Linux that you should definitely know about as a beginner to avoid creating a mess of your Linux File System. 

If you ever find yourself troubleshooting or making system-level changes, you might also need to learn how to reboot Linux safely to ensure your changes take effect properly.

Important Directories in Linux distributions

Although most Linux distribution follows the Linux File Hierarchy Standard. However, there might be a slight difference in the structure of the file system in different Linux distros. Nevertheless, you will notice the following directories in common for all of them.

Directory

Description

/

A simple forward slash denotes the root directory that contains all the other user-specific and global sub-directories.

/boot

The boot directory stores the kernel of the Linux system as well as the files related to the boot loader.

/etc

This particular directory includes all the files that define the configuration of the system. It contains files such as passwd which stores information related to each user, fstab which has details regarding the mounted devices, hosts which contains details regarding the hostnames that the system recognizes, and init.d which has information related to scripts that are used to start system-related services during boot.

/bin, /usr/bin

The /bin directory has all the programs required by the system to work and the /usr/bin has programs specific to system users’ applications.

/sbin, /usr/sbin

These directories store programs that are used by the superuser or sysadmins.

/usr

This directory has all files related to user applications. Some of them include - /share/X11 (for X windows systems), /share/dict (for spell checking), /share/doc (for storing documentations), /share/man (for storing manuals), /usr/src (for storing source codes), etc. 

/usr/local

This directory along with its subdirectories stores files related to software installations and others specific to the local machines. Most of the programs are stored or installed inside /usr/local/bin.

/var

It has files that are dynamically changing. For example, it includes - /var/log containing log files, /var/spool which stores files that have been queued such as sending emails, printing content, etc.

/lib

This stores the shared libraries.

/home

This is the user-specific directory where they can keep their personal files.

/root

This directory acts as a home directory for the superuser.

/tmp

In this directory, processes can include their temporary files.

/dev

This directory contains devices in the form of files that are available to the system. You can read or write in these files/devices. For instance, /dev/fd0 represents floppy disks, /dev/sda represents hard drives, etc.

/proc

This is a virtual directory that contains entries corresponding to the processes that are being run in the system. Additionally, there are also some named entries that allow access to config files and can be viewed,

/media,/mnt

The /media directory is used to store mount points. To access a device in Linux, it has to be first mounted. During the boot, the kernel reads the /etc/fstab file to look for mounting instructions for permanent drives. However, for temporary mounts like CDs, USBs, etc., the /mnt directory has a place to mount them.

/opt

It contains applications that are 3rd party such as Java, etc. It abbreviates for optional.

/srv

It abbreviates for service and contains files that are specific to services.

These are some important directories that are not meant to be messed up. As a root user, you have all the permissions and access to these directories. Hence, to be on the safer side, it’s always a good practice to create a separate user without root privileges and use it as your default user account for day-to-day operation. In case you want to access root privileges, you can always switch back to the root account.

For tasks that require administrative privileges without directly switching to the root account, you can use sudo to execute commands with elevated permissions. Learn more about how to configure and utilize sudo privileges in Linux to maintain both security and flexibility in your system management.

Wrapping Up!

To sum up, in this comprehensive guide on directories in Linux, we started with a general introduction to understanding how important it is for Linux users, to know their file system, user directories, system directories, and configuration files to avoid creating a mess in their system. We then discussed a few system and config directories along with their purposes in detail. Some of them include the root directory, boot, proc, etc, bin, sbin, usr, var, lib, home, tmp, dev, media, mnt, etc. 

You will surely come across them slowly when you start installing packages or try to fix errors, but it’s always best to have slight knowledge so that in such an event, you at least know where to look for fixes. You can also buy linux vps to practice it on a routine basis.

We certainly hope that this article gives you a birds-eye overview of some of the most important directories in Linux Servers.

People also read: