Understand system directories on Linux systems

by Daniel Pham
Published: Updated:
This entry is part 6 of 6 in the series Linux commands: Part 3 - Exploring the system

This article will help you understand system directories on Linux systems. This, personally, is very important and especially for those who want to become a system administrator.

There will be times when you install a software on a Linux server and you get an error. What should I do now? You will begin to view configuration files to see if anything is wrong.

But to see where those files are, if you don’t understand Linux’s system directory structure, you’ll have trouble.

List system directories on Linux systems

Now, below, I will give you a list of system directories on Linux.

understand system directories on linux systems
Understand system directories on Linux systems.

Main directories

DirectoryComments
/This is the root directory, where all directories or files start on the Linux system. When you understand it’s the root directory, you’ll know why the rm -rf /* command is dangerous and made fun of people who just learned Linux.
/binAbbreviation for the word binaries. that must be present for the system to boot and run.
/bootContains the Linux kernel, initial RAM disk image (for drivers needed at boot time), and the boot loader. In some jobs, you may be able to edit the file /boot/grub/grub.conf or /boot/grub/grub.cfg (depending on base OS), which are used to configure the boot loader.
/devThis directory contains information about all device nodes. On Linux, all devices connected to the system are viewed as files and when you work on files, they are also working on the device. You can see the best example with the command fdisk -l. It will list all drives on the machine, you will see some lines like /dev/sda/dev/sdb, …
/etc/etc is referred to as the etcetera directory. The /etc directory contains all of the system-wide configuration files. It also contains a collection of shell scripts which start each of the system services at boot time. Most of the software you install on the system, there are configuration files located in this directory. Therefore, when an error occurs, search for the configuration file in this first. Some files you will often work in this directory:
/etc/crontab : where you set up automatic scheduling processes for the system. Or you can use the crontab -e command to set.
/etc/fstab : where you set up mount points for storage devices on your system.
/etc/passwd : a list of the user accounts.
/libAbbreviated for library. The directory contains the shared library files used for the core system. It is similar to DLLs in Windows.

Home and media directories

DirectoryComments
/homeThis is the home directory of regular users on the system. When you create a new user on the system, it will create a corresponding directory in /home and that user can only write and execute the file on their home directory. For example, I have a user named danie, the home directory is /home/danie, respectively. I can only create, edit, delete and execute files/folders on the /home/danie folder.
/lost+foundEach partition or storage device when connected to your system will have this folder. This folder is used to recover a piece of data if there is a problem corrupt file system. However, most of the time, this directory will be empty.
/mediaOn modern Linux systems, the folder contains mount points for removable devices such as USB, CD-ROM, …
/mntOn older Linux systems, /mnt used to store mount points for removable devices.

System information and options

DirectoryComments
/optThis directory is used to install optional software. Later, when you install some software such as Zimbra, Mod Security, … then you will see these software will be in the /opt directory.
/procThis is a special folder. It contains files but not really file systems. These files are generated by the kernel and are maintained in the kernel itself. These virtual files display information about your system, which shows the kernel how to identify your system. For example, you want to know how many processors the system has. You type the following command to try it cat /proc/cpuinfo | grep processor.
/rootThis is the home directory for the root account.
/sbinThis directory contains the system binaries files used to perform general system tasks, most of which serve superusers.
/tmpThe directory contains temporary files of programs on the system. This folder can be emptied every time the system reboots.

Unix system resources and logs

DirectoryComments
/usrSome people say /usr means user, others say /usr means Unix System Resources. You can read more at the FreeBSD documentation about these directories, but I personally think that /usr is more suitable for Unix System Resources. This directory contains all the programs and support files used by regular users.
/usr/binThis directory contains the executable programs installed by Linux distribution. If your read the post about script file location, you will see that I mentioned this folder and what the system will do with the files in this directory.
/usr/libIt contains all shared libraries for the programs in /usr/bin.
/usr/localThis directory does not contain the default operating system programs, but it contains programs compiled from the source and placed in the directory /user/local/bin. Most of these programs are installed and used by users throughout the system.
/usr/sbinContains system administration programs.
/usr/shareThis directory contains all the shared data used by programs in /usr/bin. It’s may include something like example configuration files, document files, …
/usr/share/docWhen you install the software, these software packages will include the documentation that comes with it. Of course, you can read it on the homepage. But these packages will by default place their respective documents in this directory.
/varThis directory is the location of the changed data of the system or the user. For example: PID files, various databases, user mail, …
/var/logThis directory contains system log files, program log files. If you want to troubleshot certain problems, see log in this directory.

Conclusion

Okey, so you have a fairly general overview of the system directory tree structure in Linux systems. Now, practice and learn more about it.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: Understand long format of ls command in Linux

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.