Linux Directories Explained

Kapil Bhise
Analytics Vidhya
Published in
4 min readMar 2, 2021

--

/root (/): /root is the home directory of the superuser (also known as the “Administrator”) of the system. All the directories in the Linux system come under the root directory which is represented by a forward slash (/). Everything in your system can be found under this root directory even if they are stored in different virtual or physical devices.

/bin : /bin is the directory that contains binaries, that is, some of the applications and programs you can run.

/boot : The /boot directory contains files required for starting your system.

/dev : /dev contains device files. Many of these are generated at boot time or even on the fly.

/etc : /etc is the directory where names start to get confusing. /etc gets its name from the earliest Unixes and it was literally “et cetera” because it was the dumping ground for system files administrators were not sure where else to put.

/home : /home is where one will find your users’ personal directories. In my case, under /home there are two directories: /home/kapil, which contains all my stuff; and /home/guest, in case anybody needs to borrow my computer.

/lib : /lib is where libraries live. They contain snippets of code that applications use to draw windows on your desktop, control peripherals, or send files to your hard disk. It contains the all-important kernel modules.

/media : The /media directory is where external storage will be automatically mounted when you plug it in and try to access it.

/mnt : This is where you would manually mount storage devices or partitions.

/opt : The /opt directory is often where software you compile sometimes lands. Applications will end up in the /opt/bin directory and libraries in the /opt/lib directory. Another place where applications and libraries end up is /usr/local, When software gets installed here, there will also be /usr/local/bin and /usr/local/lib directories.

/proc : /proc, like /dev is a virtual directory. It contains information about your computer, such as information about your CPU and the kernel your Linux system is running.

/run : /run is another new directory. System processes use it to store temporary data for their own nefarious reasons.

/sbin : /sbin is similar to /bin, but it contains applications that only the superuser (hence the initial s) will need. /sbin typically contains tools that can install stuff, delete stuff and format stuff. You can use these applications with the sudo command that temporarily concedes you superuser powers on many distributions.

/usr : /usr contains a mish-mash of directories which in turn contain applications, libraries, documentation, wallpapers, icons and a long list of other stuff that need to be shared by applications and services.You will also find bin, sbin and lib directories in /usr. Originally, the /bin directory (hanging off of root) would contain very basic commands, like ls, mv and rm; But many modern Linux distributions just put everything into /usr/bin and have /bin point to /usr/bin just in case erasing it completely would break something. Ubuntu and Mint still keep /bin and /usr/bin (and /sbin and /usr/sbin) separate;

/srv : The /srv directory contains data for servers. If you are running a web server from your Linux box, your HTML files for your sites would go into /srv/http (or /srv/www). If you were running an FTP server, your files would go into /srv/ftp.

/sys : /sys is another virtual directory like /proc and /dev and also contains information from devices connected to your computer.

/tmp : /tmp contains temporary files, usually placed there by applications that you are running. The files and directories often (not always) contain data that an application doesn’t need right now, but may need later on.

/var : /var was originally given its name because its contents was deemed variable, in that it changed frequently. Today it is a bit of a misnomer because there are many other directories that also contain data that changes frequently, especially the virtual directories. /var contains things like logs in the /var/log subdirectories. Logs are files that register events that happen on the system. If something fails in the kernel, it will be logged in a file in /var/log.

Thank You

--

--

Kapil Bhise
Analytics Vidhya

Passionate about learning new technologies and implementing them. Enjoy contributing ideas to projects. Strong written and verbal communication skills;