Besides having a different type of file system with Windows, Linux also has a different file and directory structure.
If you are new to Linux or want to migrate to Linux, you should learn the file structure and its directories to make the work easier.
Directories in Linux can be described with a hierarchy like the image below:
The description of each directory is as follows:
Directory | Contents |
---|---|
/ (root) | It is the highest directory in the hierarchy called “root”. All other essential files and directories are under this directory, so in writing they always use the “/” sign in front of them. |
/bin | It is a binary file directory containing the basic commands required by the system and user to run, for example cd (change directory), pwd (print working directory), mv (move), mkdir (make directory), etc. |
/boot | It contains the Linux Kernel and other files required when booting the system, especially when implementing dual-boot. |
/dev | It is a directory containing the device files where physical devices are installed, such as Hard drives (/dev/sda), USB drives (dev/sde), Optical drives, and other devices installed on the system. |
/etc | It contains configuration files needed by all programs and a "start-up and shutdown" shell script to start or stop individual programs. For example, /etc/opt as configuration file storage for add-on packages, /etc/sgml as configuration file storage for software that processes SGML, /etc/X11 as configuration file storage for X Window System version 11, /etc/xml as a configuration file storage for software that processes XML, etc. |
/home | It is a home directory that stores user data. Each registered user will automatically be created in the /home directory which consists of other directories such as Desktop, Downloads, Documents and so on. For example, the user name that we will create is “kevin” and the /home/kevin directory will automatically be formed. |
/lib | It is a directory containing library files from existing applications on the system. This directory can be considered equivalent to Program Files on Windows, although it is not exactly the same. Each program in Windows requires its own library to be installed even though it already exists for other programs. It is different from Linux where sometimes one library file can be used by some applications together. |
/media | It is a directory containing media files from external devices installed and connected to the system. For example, CDROM, external Hard disk, and so on. It varies between different Linux distributions. |
/mnt | It is a directory basically used as a place for installing file system or other temporary drives. For example, /mnt/server is the mounting location for the hard drive media server. |
/opt | It is a directory containing additional application packages for systems that cannot be managed by existing distribution packages. For example, /opt/arcsight as a repository for additional packages from the ArgSight application that have not been managed by the package distribution manager. |
/proc | It is a process directory where a lot of system information is represented as a file. Generally, it provides a way for the Linux kernel to send and receive information from various running processes. |
/run | It is a run-time data variable directory that contains information about the system running since the last boot, for example when logging in and running a daemon. |
/sbin | It is a directory containing essential binary programs needed by the system administrator for maintenance, such as iptables, fdisk, ifconfig, swapon, reboot, fsck, init, route and others. |
/srv | It is a directory containing certain servers with related file services, such as data and scripts for web servers, data offered by FTP servers, and repositories for system control versions. |
/sys | It is a directory containing information about devices that are connected to the system and allows to save and modify it. |
/tmp | It is a temporary system directory that stores temporary files to be accessed by users and root up to the next boot. |
/usr | It is a secondary hierarchy directory containing source code programs that can be accessed by users. For example, /usr/bin as a binary command that is to some extent not from the Linux OS (at, awk, cc, less, scp), /usr/include as a standard for loading header files from the C and C++ program languages, etc. |
/var | It is a variable file directory containing information on the operating process of the system. For example, /var/log as a directory containing logs from different applications, /var/mail as a directory containing Mailbox files, /var/lock as a directory containing files that can only be used by one application. |
Do I Have to Memorize All Directories?
If you only use Linux as a desktop for daily work, you don’t need to memorize all directories.
You only need to pay attention to directories that you use often like /home
, /root
, or /usr
.
Yet, if you are a developer, surely you have to understand most of the directory structures on Linux that have been mentioned above.
Top comments (0)