DEV Community

Alexander Njoku
Alexander Njoku

Posted on • Edited on

https://medium.com/@alex2020global/understanding-the-linux-filesystem-92e2eb65968f

Understanding the Linux Filesystem
As promised in my last article this week I focused on Linux Filesystem Structure.
The Linux file system is hierarchical, starting from the root directory (/) and branching out into subdirectories.

Key directories in the Linux Filesystem

/ (root) directory --> Root directory; the top-level directory of the file system, it’s worth noting that only the root user possesses the privilege to execute write operations within this directory. To see the files inside the root directory you have go as a superuser sudo su and cd into it, type ls and Press enter.

/bin directory --> Within the '/bin' directory, you'll find a collection of binary executable files needed for booting and system recovery. According to Mr Bernard Chika Uwaezuoke "Binary files are fundamentally composed of a sequence of bytes, each represented by a combination of 0s and 1s".

/boot directory --> Files required for booting the system (e.g., kernel, bootloader). Please DO NOT TOUCH files here you may mess up your system.

/dev directory --> Device files representing hardware devices, such as 'cdrom,'web cam’ 'cpu,' printers, USB, and more. this is a place to check Hardware issues. Drives of external hardware devices are here.

/etc directory --> Configuration files for the system and installed software, it houses the fundamental configuration files that are vital for the system's operation. This is a place to check software issues. It's System Administrators and DevOps professionals who handle these files. They encompass a wide range of configurations, such as usernames, passwords, network settings, application-specific configurations, as well as system startup and shutdown scripts.

/home directory --> User-specific directories and files, whenever a new user account is created, a corresponding directory bearing their username is automatically generated within the home directory to provide them with a dedicated storage space.

/lib directory --> Shared libraries required by system programs, it house shared library files crucial for booting the system, functioning much like DLLs on Windows. '/lib' accommodates 32-bit compatibility libraries. Applications need them to function.

/media directory --> Mount points for removable media (e.g., USB drives, CDs), Any external storage such as media/cdrom when plugged in will be automatically mounted under /media directory. When you have issues with USB, speakers and any external hardware this is a place to check.
It is empty because I haven’t connected anything yet.

/mnt directory --> Temporary mount points for external file systems, (Hardware, storage) This directory serves as a location where system administrators can mount regular filesystems like NFS. Is here that you add more storage (Eg) When you purchase a gigabyte from AWS or any other vendor this is the place where you mount and format it so that it will be permanent/persistence because if is not persistence when you reboot your system it will go away.
It is empty because I have not mounted anything.

/opt directory --> Optional add-on software packages, this directory contains any third-party applications available from individual vendors. It is recommended to install third-party applications under /opt. You can add plugins and extensions here.
No extensions yet.
/proc directory --> Virtual file system providing information about system processes, this directory stores data related to system processes identified by a specific process ID (PID). It's commonly referred to as a virtual or pseudo filesystem, as it contains textual information about various system resources, including CPU and memory. Files and directories within this directory are generated dynamically as the system starts or undergoes changes. The current process that are running in the system the information this is a place to see them.

/root directory --> Home directory for the root user, anytime you come to system and see # sign instead of $ sign just know you are in the root directory. BE CAREFUL HERE. If you don’t have privileged you can’t enter to root directory.

/run directory --> Runtime variable data, This directory is designed to contain temporary data that does not need to persist across system reboots. Variables are like creating a vacant room that does not have anything, anytime you want to use it you can put anything inside it, variables are place holders. If you having issues with runtime variables files you have to check here. /run

/sbin directory --> System binaries used for system administration, it contains essential executable programs for system administration and maintenance, primarily used by the root user and requiring root privileges for execution. This contrasts with /bin and /usr/bin, which hold user-level executables, and /usr/sbin, which also contains system administration binaries but are typically needed after the /usr filesystem is mounted during system startup.

/srv directory --> Data for services provided by the system, to see services and configurations of a server.
No server is configured yet.
/tmp directory --> Temporary files, many applications keep their temporary files here which contain data that an application might not need right now but may need later. These files will be kept until the next boot or application restart.

/usr directory --> Secondary hierarchy for user-related data, this directory contains applications, libraries, docs, icons, images and other files which needs to be shared by applications and services. It is basically shareable, read-only data.

/var directory --> Variable data such as logs, caches, and spool files, the index files of a webserver are located in /var, it stores variable data files, meaning files that are expected to grow or change during normal system operation.

This is what I learned this week (July 01- 05, 2025) next week I will focus on Filesystem Navigation.

Thanks for following my journey from Linux to DevOps. Alex

Top comments (2)

Collapse
 
simongreennet profile image
Simon Green

Your description about the /run directory is incorrect. On modern Linux systems, this is mounted as tmpfs (a temporary file system) which doesn't survive a reboot. It would be very rare for it to contain system executables. All the ones you have mentioned (fdisk, fsck, reboot, shutdown, iptables) are usually in /usr/bin.

Contents in the /run directory are usually things like pid files and file sockets. For example, the PostgreSQL file socket is found in /run/postgresql/.s.PGSQL.5432.

Collapse
 
pingalex profile image
Alexander Njoku

Thanks @simongreennet for insightful comment i was able to correct it. Please keep up with me, I will appreciate it.