Linux directory structure (File system structure). Explained with examples

Have you wondered why some programs are in / bin or / sbin or / usr / bin or / usr / sbin?

For example, why is the command in the / usr / bin directory. Why not in / bin or / sbin or / user / sbin? What are the differences between all of these directories?

In this article, we will describe the Linux file structure so that you can understand the meaning of individual high-level directories.

1. / root

  • Every file and directory starts at the root directory.
  • Only the root user has the privilege to write in this directory.
  • Note that / root is the user’s root home directory, which is not the same as /.

2. / bin – User binaries

  • Contains binary executable files.
  • Common Linux commands are located in this directory, you need to use in single user mode.
  • The commands used by all users of the system are located here.
  • For example: ps, ls, ping, grep, cp.

3. / sbin – System binaries

  • Just like / bin, / sbin also contains binary executables.
  • But, in Linux, the commands located in this directory are used, as a rule, by the system administrator to maintain the system.
  • For example: iptables, reboot, fdisk, ifconfig, swapon

4. / etc – Configuration files

  • Contains configuration files required for all programs.
  • Also contains shell startup and shutdown scripts, used to start / stop individual programs.
  • For example: /etc/resolv.conf, /etc/logrotate.conf

5. / dev – Device files

  • Contains device files.
  • These include terminal devices, USB, or any device connected to the system.
  • For example: / dev / tty1, / dev / usbmon0

6. / proc – Process information

  • Contains information about the system process.
  • This pseudo-filesystem contains information about the startup process. For example: the / proc / {} PID directory contains information about the process with that specific PID.
  • It is a virtual file system with textual information about system resources. For example: / proc / uptime

7. / var – Variable files

  • var consists of variable files.
  • Content files that are expected to grow can be found in this directory.
  • It includes – system log files (/ var / log); packages and database files (/ var / lib); email (/ var / mail); print queues (/ var / spool); file locking (/ var / lock); temporary files needed after reboot (/ var / tmp);

8. / tmp – Temporary files

  • A directory that contains temporary files created by the system and users.
  • Files in this directory are deleted when the system is rebooted.

9. / usr – User programs

  • Contains binaries, libraries, documentation and source code for second-level programs.
  • / usr / bin contains binaries for user programs. If you cannot find the user’s binary in / usr, look in / usr / bin. For example: at, awk, cc, less, scp.
  • / usr / sbin contains binaries for system administrators. If you cannot find the system binaries in / sbin, look for them in / usr / sbin. For example: ATD, cron, SSHd, useradd, userdel
  • / usr / lib contains libraries for / usr / bin and / usr / sbin
  • / usr / contains the users of the program you are installing bp source. For example, when installing Apache from source, it goes to / usr / local / apache2

10. / home – Personal directories

  • Home directories for all users to store their personal files.
  • For example: / home / andreyex, / home / destroyer

11. / boot – file loader

  • Contains downloaders for related files.
  • Kernel initrd, vmlinux, grub files are located in / boot directory
  • For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

12. / lib – System Libraries

  • Contains library files that support binaries located in / bin and / sbin directory
  • Filename library either ld * or lib * .so. *
  • For example: ld-2.11.1.so, libncurses.so.5.7

13. / opt – Optional additional applications

  • opt means optional.
  • Contains additional applications from selected vendors.
  • Additional applications must be installed respectively in / opt / or in the / opt / subdirectory.

14.mnt – Mount directory

  • A temporary mount directory where system administrators can mount file systems.

15. / media – removable media

  • A temporary mount directory for removable devices.
  • For example, / media / cdrom for CD-ROM; / media / floppy for floppy disks; / media / cdrecorder for CD burning

16. / srv – Data service

  • SRV stands for service.
  • Contains server-specific data-related services.
  • For example / srv / cvs contains data related to cvs.

Sidebar