Linux File System Structure Tree


When we freshly install an operating system, there are some folders and files are placed by default. Have you wondered what are those and folders and why they have weird names and what files are contained there? Today we will start our journey learning some of their purpose.

These are the folders in root directory for freshly installed ubuntu in docker
A more elaborate tree like representation with recursive directories
  • / – this is known as “root”, the logical beginning of the Linux file system structure. Every single file path in Linux begins from root in one way or another. / contains the entirety of your operating system.
  • /bin – Pronounced “bin” (as opposed to “bine”), this is where most of your binary files are stored, typically for the Linux terminal commands and core utilities, such as cd (change directory), pwd (print working directory), mv (move), and so on.
  • /boot – This is where all the needed files for Linux to boot are kept. Many people, including myself, like to keep this folder in it’s own separate partition on the hard drive, especially when dual-booting is involved. A key thing to note is that even when /boot is stored on different partition, it is still logically located at /boot as far as Linux is concerned.
  • /dev – This is where your physical devices are mounted, such as your hard drives, USB drives, optical drives, and so on. We’ve already explored that typically, your system hard drive is mounted under /dev/sda, whereas your USB thumb drive might be mounted under /dev/sde. You may also have different partitions on your disk, so you’ll see /dev/sda1, /dev/sda2, and so on. In Windows, when you go to “My Computer” or “Computer” and you can see all of the physical devices and drives connected to your computer, this is the equivalent of /dev in Linux file structure.
  • /etc – Pronounced “et-see”, although some also prefer to spell it out, is where configuration files are stored. Configurations stored in /etc will typically affect all users on the system; whereas users can also store configuration files under their own /home folders, which will only affect that particular user.
  • /home – This is where you’ll spend the overwhelming majority of your time, as this is where all of your personal files are kept. The Desktop, Documents, Downloads, Photos, and Videos folders are all stored under the /home/username directory. You can also store files directly in your /home folder without going to a sub-folder, if you wish so. Typically, when you open a command-line terminal in Linux, the default location that the terminal points to is your /home/username folder, unless you’ve manually changed the default location to something else.
  • /lib – This is where libraries are kept. You’ll notice that many times when installing Linux software packages, additional libraries are also automatically downloaded, and they almost always start with lib-something. These are basically the files needed for your programs on Linux to work. You can think of this folder as somewhat equivalent to the Program Files folder on Windows, although it’s not exactly the same. Unlike Windows, libraries can be shared between many different programs, which results in Linux installations typically being much more lightweight than Windows, because typically in Windows each program needs it’s own library installed, even if it’s redundant and already exists for another program. Surely a benefit of Linux file system structure.
  • /media – Another place where external devices such as optical drives and USB drives can be mounted. This varies between different Linux distros.
  • /mnt – This is basically a placeholder folder used for mounting other folders or drives. Typically this is used for Network locations, but you could really use it for anything you want. I used to use it as the mount point for my media server’s hard drive (/mnt/server).
  • /opt – Optional software for your system that is not already managed by your distro’s package manager. I don’t really ever find myself using this, your mileage may vary.
  • /proc – The “processes” folder where a lot of system information is represented as files (remember, everything is a file). It basically provides a way for the Linux kernel (the core of the operating system) to send and receive information from various processes running in the Linux environment.
  • /root – This is the equivalent to the /home folder specifically for the root user, also called the superuser. You really don’t want to touch anything in here unless you know what you’re doing.
  • /sbin – Similar to /bin, except that it’s dedicated to certain commands that can only be run by the root user, or the superuser.
  • /tmp – This is where temporary files are stored, and they are usually deleted upon shutdown, which saves you from having to manually delete them like is required in Windows.
  • /usr – Contains files and utilities that are shared between users.
  • /var – This is where variable data is kept, usually system logs but can also include other types of data as well.

/bin contains all the command line tools. The explanation of each of the tools is getting ready and hopefully will be posted soon.


Comments

Popular Posts