The Linux directory structure

Heitor Helmer Herzog
3 min readJan 31, 2017

--

The root directory (/)
All files and directories on the Linux system installed on the computer come from a single source: the root directory. Even if they are stored on other physical devices, it is from the root directory — represented by the slash (/) — that you can access them.
It is also worth remembering that the only user of the system able to create or move files from the root directory is root, that is, the user-administrator. This prevents ordinary users from making mistakes and compromising the integrity of the entire file system.

Executable binaries: / bin

In the / bin directory are located the executable binaries that can be used by any user of the system. They are essential commands, used to work with files, texts and some basic network resources, such as cp, mv, ping and grep.

System binaries: / sbin
Like / bin, this directory stores executables, but with a differential: they are applications used by system administrators for the purpose of performing maintenance functions and other similar tasks. Among the available commands are ifconfig, to configure and control TCP / IP network interfaces, and fdisk, which allows partitioning hard disks, for example.

Libraries: / lib
At this point in the file system are located the libraries used by the commands present in / bin and / sbin. Typically, library files begin with the ld or lib prefixes and have “extension” so.

Optional: / opt
Additional applications, which are not essential to the system, terminate in this directory.

Personal files: / home
In the / home directory are the personal files, such as documents and photographs, always within folders that take the name of each user. Note that the administrator’s home directory is not in the same location, but in / root.

Boot: / boot
Files related to system boot, that is, the Linux boot process, when the computer is turned on, are in / boot.

Volumes and media: / mnt and / media
To access the files from a CD, USB or hard disk in another machine on the network, you need to “mount” this content on the local file system, that is, make it accessible as if it were just another directory on the system.
In / media all removable media such as USB devices and data DVDs are mounted. The / mnt directory is reserved for administrators who need to temporarily mount an external file system.

Services: / srv
Data from servers and services running on the computer are stored within this directory.

Device Files: / dev
In Linux, everything is presented in the form of files. When you plug a USB stick into your computer, for example, a file will be created inside the / dev directory and it will serve as an interface to access or manage the USB drive. In this directory, you find similar paths to access terminals and any device connected to the computer, such as the mouse and even modems.

Variable files: / var
Every file that grows in size over time is in the variable files directory. A good example is the system logs, that is, text logs of activities performed on Linux, such as logins made over the months.

System processes: / proc
Remember the story that everything works as a file on Linux? For / proc is proof of this. In this directory are found files that reveal information about the resources and processes running on the system. Want an example? To find out how long Linux has been in use since the last time it was started, just read the / proc / uptime file.

Temporary files: / tmp
Files and directories temporarily created by both the system and users must be in this directory. Most of them are erased whenever the computer restarts.
As you can easily tell, directory names give you insider tips on what’s inside, and with a few months of use you’ll be navigating through them with ease.

--

--

Heitor Helmer Herzog
Heitor Helmer Herzog

Written by Heitor Helmer Herzog

Software developer, In love with games and the industry. Let’s code! About me: www.linkedin.com/in/heitorhherzog

No responses yet