3

There are a lot of folders in the / directory what do they all do? I know a few like /dev has links to devices in the system but what about /lost+found or /proc I just am curious.

9

The official reference for this on Linux is the Filesystem Hierarchy Standard. Distributions mostly follow the FHS (currently at version 3.0), but can occasionally deviate. Other Unix variants have many similarities but again can deviate. There is also a good summary on Wikipedia.

I'll summarize the role of each directory that is found on typical Linux installations. See the FHS or Wikipedia for more details about the role of each directory.

  • /bin: system programs meant for every user. See also /usr/bin.
  • /boot: files used to start up the system: typically a bootloader, a kernel image, and a few associated files. These files are mostly not accessed after booting.
  • /dev: device files. These are the ways applications communicate with hardware and more generally with kernel features that are about shuffling data around, such as disk partitions, terminals including virtual ones, etc.
  • /etc: system configuration files. (So named because it started out as “stuff that didn't fit in the other directories”, but nowadays it's exclusively for configuration files on Linux and mostly if not exclusively for configuration files on other Unix variants. Miscellaneous stuff is now under /var.)
  • /home: the directory containing users' home directories. E.g. Alice's files are typically under /home/alice. On systems with many users, the administrator may choose to have more levels (e.g. /home/faculty/alice, /home/students/bob, …). A few sites have home directories at a different location such as /homes, /users, …
  • /lib contains shared libraries. See also /usr/lib.
    Some distributions have other directories such as /lib32 and /lib64 to store libraries for different processor architectures.
  • /lost+found: for files recovered from filesystem corruption (but you're rarely so lucky).
  • /media: contains mount points for removable media. On some systems, the mount points are at a third level, under directories named after users.
  • /mnt: There used to be a dispute as to whether /mnt should be a directory that's available to the system administrator as a temporary mount point, or whether it should be a directory where the administrator can create subdirectories to be used as mount points. Nowadays the first position has won, and /media plays the second role.
  • /opt: contains additional software with one subdirectory per software package. Some distributions use it heavily, others not at all.
  • /proc: contains one subdirectory per process, exposing various information about the processes. That's where tools such as ps and top get their information. Not present on all Unix variants (BSD tends not to have it). On Linux, /proc also contains information about the system in general, but see also /sys. Content in /proc is generated on the fly by the kernel when an application reads it.
  • /root: the root user's home directory. Not present on all systems; traditionally root's home directory was /.
  • /run: an in-memory filesystem containing system files that don't need to be preserved upon reboots, such as information about running services. There are typically per-user directories under /run/user. This is a Linux thing.
  • /sbin: system programs meant only for administrators. See also /usr/sbin.
  • /srv: sort of like /home, but for system services. A creation of the FHS that hasn't been universally adopted.
  • /sys: like /proc, but presents information about kernel drivers and about hardware (the use of /proc for non-process-related information is deprecated but files that were in /proc remain in /proc for backward compatibility). Specific to Linux.
  • /tmp: temporary files, accessible by every user. This is often an in-memory filesystem.
  • /usr: This is where most of the software is installed. /usr contains subdirectories such as /bin, /lib and /sbin (but usually not /etc). The distinction is that the subdirectories of / contain essential files needed while the system is starting, and /usr contains all the rest. /usr exists separately because there were reasons to keep it on a separate filesystem (which could be read-only, and shared between multiple machines) but the distinction is not always relevant, and less and less so as time goes on, so e.g. /bin can be a symbolic link to /usr/bin or vice versa. The name comes from “user” but it has been a very long time since /usr had anything to do with users, today /usr contains system files and that's that.
  • /var: contains files that tend to change over time, in contrast with /usr which contains files that don't change except when upgrading or installing software. Unlike /tmp, the files under /var are (for the most part) meant to be preserved if the system reboots. /var is pretty diverse: it contains caches, metadata about installed software, printer spools, system mail, log files, temporary files (like /tmp, but /var/tmp is always preserved upon reboot and usually has more space), etc.
0

With / being the root, the others are as follows

Note Some of these depend on your distribution

  • /bin: Essential binaries (programs or executables)
  • /boot: Boot files, i.e., all the required items for GRUB (or other) boot loader
  • /cdrom (depends on your distro): Mount point for CD / DVD drive
  • /dev: Device files, these files represent (they are actually real files) devices physically (or virtually) attached
  • /etc: Configuration files
  • /home: home folders for users
  • /lib: shared libraries for installed binaries
  • /lost+found: Recovered files that the kernel (or some binary) tried to rescue
  • /media: removable media
  • /mnt: mount location (but you can mount anywhere)
  • /opt: optional packages you want to install that dont make sense to live elsewhere (though this is an arguable point)
  • /proc: Kernel and process files. Similar to /dev.
  • /root: root user home directory
  • /run: application files save their state here when they are running
  • /sbin: More binaries (mainly for sudo user)
  • /selinux: if using SELinux (Centos, Redhat Enterprise, etc), contains special files used by SELinux
  • /srv: data directory for services, e.g., a web server might use this to store files to 'serve'
  • /tmp: temp files
  • /usr: User binaries
  • /var: log files in /var/log and other data files. generally relates to /usr binaries

Source: https://www.howtogeek.com/117435/htg-explains-the-linux-directory-structure-explained/

(Paraphrased a little)

  • 2
    There are enough inaccuracies here that I do not recommend the howtogeek page as an information source. Wikipedia is more reliable. – Gilles 'SO- stop being evil' Jun 16 '17 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.