Linux Directory Structure and Important Files Paths Explained

Brief: This article gives a breakdown of the Linux File System/directory structure, some of the critical files, their usability, and their location.

You must have probably heard that everything is considered a file in UNIX and UNIX derivatives such as Linux. If not a file, then it must be a running process.

There are three broad categories of files in Linux.

  • General Files – These are ordinary files made up of binary or ASCII data. These are regular files such as documents, images, audio and video files, etc.
  • Directory Files – In Linux, directories are also categorized as files since they also serve as storage space for other files and folders.
  • Device Files – These are special files that provide an interface to device drivers which enable the usability of hardware devices on the system such as mice, keyboards, USB devices, hard drives, etc. These are found in the /dev directory.

Linux Directory Structure Diagram

A standard Linux distribution follows the directory structure as provided below with Diagram and explanation.

Linux File System Structure
Linux Directory Structure

Each of the above directories (which is a file, in the first place) contains important information, required for booting to device drivers, configuration files, etc. Describing briefly the purpose of each directory, we are starting hierarchically.

/ Directory

The root directory, denoted by a single forward slash (/), is the uppermost directory in the Linux directory structure. It contains all directories, sub-directories, and files on your Linux system. It’s from the root directory where the Linux directory hierarchy starts.

NOTE: The root directory (/) should not be confused with the root home directory (/root).

Root Directory in Linux
Root Directory in Linux

/boot Directory

This is one of the most vital directories in a Linux system. As the name infers, the boot directory contains Linux boot files such as the bootloader, the kernel, and its associated files. Files such as ‘vmlinuz‘ represent the compressed image of the Linux kernel.

Boot Directory in Linux
Boot Directory in Linux

/etc Directory

The /etc directory contains system configuration files for all the services, scripts, and third-party applications that are installed. This directory is considered the nerve center of the Linux system.

/etc Directory in Linux
/etc Directory in Linux

/home Directory

The /home directory is a directory that contains a user’s personal folders and files. On a graphical Linux system, the home directory, by default, contains folders such as Desktop, Documents, Downloads, Pictures, Videos, and Public.

In addition, the /home directory contains personal configuration files which are prefixed with a dot (.). These are hidden files that contain user-specific settings for the login shell session.

Home Directory in Linux
Home Directory in Linux

/root Directory

The /root directory is the home directory for the root user, which is also referred to as the root user’s home directory (and not as the root (/) directory).

The root account also referred to as the superuser, administrative user, system administrator or just the root user has all the access to commands and system files in Linux.

Root User Directory in Linux
Root User Directory in Linux

/opt Directory

The /opt directory is a directory that is reserved for add-on packages and third-party software applications that are not included by default in the system’s official repositories.

For example, when you install applications such as Skype, Discord, Spotify, and Java, to mention a few, they get stored in the /opt directory.

/opt Directory in Linux
/opt Directory in Linux

/dev Directory

The /dev directory contains device files or special files for devices that are attached to the system such as the hard drive, keyboard, and mouse. As mentioned, these are not regular that a user can read and write to.

These are abstractions of standard devices that applications on your system interact with through input and output system calls.

/dev Directory in Linux
/dev Directory in Linux

/var Directory

The /var directory stores system-generated variable files, which include log files, caches, and spool files just to mention a few.

/var Directory in Linux
/var Directory in Linux

/bin Directory

The /bin directory contains user binaries, executable programs, and common system commands that are used by all users in the system. These include ls, pwd, cat, mkdir, cd, mv, cp, du, df, tar, rpm, wc, history, etc.

/bin Directory in Linux
/bin Directory in Linux

/sbin Directory

The /sbin directory contains executable files, utilities, and system commands that are reserved for the root user or a user with root privileges. Such commands include halt, reboot, mkfs, fsck, fdisk, halt, iptables, ifconfig, ip, swapon, etc.

/sbin Directory in Linux
/sbin Directory in Linux

/usr Directory

The /usr directory ranks as one of the most important directories due to the enormous amount of data it holds. The directory contains system-wide read-only files. These include libraries, user binaries and their documentation, programs, and system utilities.

/usr Directory in Linux
/usr Directory in Linux

/proc Directory

The /proc directory is somewhat of a strange directory. It is a virtual or pseudo filesystem that contains vital information about running processes. It is considered the control and information center for the Linux kernel.

The filesystem is created on the fly upon system startup and is destroyed once the system is powered off.

/proc Directory in Linux
/proc Directory in Linux

/mnt Directory

The /mnt directory along with its subdirectories is a directory intended to be used as a temporary mount point for mounting storage devices such as Hard disk drives, USB drives, and CDROMs.

mnt Directory in Linux
mnt Directory in Linux

/sys Directory

The /sys is a virtual file system that contains a set of virtual files that provide an interface to the Linux kernel.

/sys Directory in Linux
/sys Directory in Linux

/media Directory

The /media directory is a directory where the system mounts removable media such as USB drives.

/media Directory in Linux
/media Directory in Linux

/run Directory

The /run directory is a temporary filesystem that contains volatile runtime data that shows the system has since it was booted. Files under the /run directory must be deleted (removed or truncated as convenient) at the start of the boot process.

/run Directory in Linux
/run Directory in Linux

/tmp Directory

The /tmp directory is a directory that stores temporary files and many programs use this directory to create lock files and keep the temporary storage of data.

Do not delete files under the/tmp directory unless you know exactly what you are doing! Many of these files are critical for presently running programs and removing them may affect a system crash.

/tmp Directory in Linux
/tmp Directory in Linux

/lib Directory

The /lib directory stores all the essential standard libraries required by user binaries in the /bin directory.

/lib Directory in Linux
/lib Directory in Linux

/lost+found Directory

The lost+found directory is installed during the installation of Linux, useful for recovering files that may be broken due to unexpected shut-down.

/srv Directory

The /srv directory is the service directory and is abbreviated as ‘srv‘. This directory contains server-specific and service-related files.

Exploring Important file, their location, and their Usability

Linux is a complex system that requires a more complex and efficient way to start, stop, maintain and reboot a system, unlike Windows. There is a well-defined configuration file, binaries, man pages, info files, etc. for every process in Linux.

In addition to the major directories, here is a list of some of the prominent files and directories and their uses.

  • /boot/vmlinuz : The Linux Kernel file.
  • /dev/hda : Device file for the first IDE HDD (Hard Disk Drive).
  • /dev/hdc : Device file for the IDE Cdrom, commonly.
  • /dev/sda: Device file for the first SATA Drive (Hard Disk Drive).
  • /dev/null : A pseudo-device, that doesn’t exist. Sometimes garbage output is redirected to /dev/null, so that it gets lost, forever.
  • /etc/bashrc : This file contains system-wide defaults, functions, and aliases among other files that are used by all the system users.
  • /etc/crontab : This is a system-wide file that is uniquely formatted to schedule or automate system tasks on a Linux system.
  • /etc/exports : A file that determines which file systems are exported to remote hosts and specifies options.
  • /etc/fstab : This is a special file that contains information about all avaiable mount points and mount point options. Each line in this file provides six options, each of which denotes information about a mount point or filesystem.
  • /etc/hosts : This is a configuration file that maps system hostnames to their corresponding IP addresses.
  • /etc/hosts.allow : The file specifies which hosts are permitted to connect to the local system.
  • /etc/host.deny : The file specifies which hosts are denied access and services on the local machine.
  • /etc/issue : Contains a pre-login message.
  • /etc/modules : This file contains the names of kernel modules that should be loaded at boot time, one per line.
  • /etc/motd : motd stands for a message of the day, the message users get upon login.
  • /etc/mtab : A read-only file that contains a list of currently mounted filesystems.
  • /etc/passwd : A file that contains the system user’s information such as the username, UID, GID, and login shell among others
  • /etc/printcap : Contains printer information that is generated by the /etc/cups/printers.conf file.
  • /etc/profile : Contains Linux system-wide environment and other startup scripts.
  • /etc/profile.d : Application script, executed after login.
  • /etc/rc.d : Information about run level specific script.
  • /etc/rc.d/init.d : Run Level Initialisation Script.
  • /etc/resolv.conf : This is a DNS resolver file. It specifies how the system leverages DNS to resolve hostnames.
  • /etc/security : Contains configuration files for various PAM modules.
  • /etc/skel : This is a directory that contains a set of user configuration files that are copied to the user’s home directory when a user is created.
  • /etc/X11 : This is a directory that contains configuration files for the X-window System.
  • /usr/bin : Normal user executable commands.
  • /usr/bin/X11 : This directory contains infinitely nested directories and binaries for the X Windows System.
  • /usr/include : The directory contains header files for C compilers. This includes stdio.h, stdlib.h, and string.h among others.
  • /usr/share : Shared directories of man files, info files, etc.
  • /usr/lib : This directory consists of object files and directories
  • /usr/sbin : The directory contains binaries with superuser privileges or for System Administration.
  • /proc/cpuinfo : The file contains system info including CPU model, model name, number of cores, and clock speed to mention a few files.
  • /proc/interrupts : Information about the current interrupts being utilized currently.
  • /proc/ioports : The file contains all the Input/Output addresses used by devices on the server.
  • /proc/meminfo : A file that stores memory usage information including swap information.
  • /proc/modules : A file that lists all the modules being used by the kernel
  • /proc/mount : The file contains detailed mounted file-system information.
  • /proc/stat : The file contains detailed information about the system and kernel activity.
  • /proc/swaps : The file contains information about the swap file.
  • /proc/version : The file contains Linux version information.
  • /var/log/lastlog : A binary file that contains information about the last successful user logins.
  • /var/log/messages : The file contains a log of messages produced by the syslog daemon at boot.
  • /var/log/syslog : A file that contains non-critical system logs.
  • /var/log/wtmp : A file listing the login time and duration of each user on the system currently.

That’s all for now. Keep connected to Tecmint for any News and post related to Linux and Foss world. Stay healthy and Don’t forget to give your valuable comments in the comment section.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

60 Comments

Leave a Reply
  1. Dear Sirs and Madames,

    I want to thank you for giving us the opportunity to resolve problems!

    My problem is this:

    efthy @ localhst´s password: … the cursor stops here and I cannot add any more commands.

    During my Debian installation on my cell phone!

    Thanks in advance

    Efthymios

    Reply
  2. I am happy to say, that this site gives me some stuff to get Linux knowledge. We both are the same in searching for Linux. I think we could refer different sites to make us clear and more explanation may receive from that useful resources. I am not going to give up. I will be a best Linux user and reach admin level knowledge. all the best for all. contact me if you want to discuss it with me.

    Reply
  3. how can find the System Administration Guide like one provided from Red hat but not online with in the system, is it possible or no ?

    Reply
  4. Thanks friend for this wonderfull stuff, I love it although am new to linux
    tryiny to get it all into my brain but I believe someday i’ll become a great linux
    Terminal user.

    Reply
  5. Please. Slow down. What’s a binary? What the difference between executable Windows and executable Linux, if any? What is Kernel, and is it comparable to Windows or Mac? What is source code? What are libraries? What are man pages? What is a shell? What is a shadow file? A bash shell? A terminal list? A swap file? Daemon?

    Reply
    • what’s a binary? go to google, write: what’s a binary -> there you go. what is kernel? go to google, write: what is kernel -> there you go. what are libraries? go to google, write: what are libraries -> there you go, etc, etc, etc

      Reply
      • Oh, since we are being sarcastic and non-helpful, you can just go to google, write: Linux filesystem -> there you go, and do away with the entire article.

        Reply
        • Rather than being a smart yourself, perhaps you could have answered the many questions Anthony asked. The article is quite good but is not intended to be a complete and comprehensive be-all-end-all guide to the Linux OS.

          Joydivision is right, the poster could do a little research himself rather than blasting the site with all those questions. It would have been just as easy to have typed those questions into a search engine and produced a usable answer.

          I guess some people just need to, or are used to, having everything handed to them or are just too stupid or lazy to make use of the resources available, in which case they should probably continue to use Windows and leave Linux alone.

          Reply
  6. i have to install apache tomcat and jdk in linux server. So, can tell be where to install the software?
    Also tell where to keep our developed application?

    Reply
    • Well, IMHO (In My Humble Opinion,) going to a library, while not as instantly gratifying as a search engine, like Google, I feel that in the end, you will be FAR more knowledgeable about your chosen topic, that it’s a self-empowering choice. I cannot see a reason that would cause regret in choosing to obtain knowledge in this manner.

      Reply
    • What’s above is termed the FHS (file hierarchy system) and that’s actually EXTREMELY detailed as it applies to ALL Linux systems, on any machine. If you use Kubuntu derived from Ubuntu derived from Debian, you’ll find the same EXACT file structure on all 3! Try that degree of uniformity over 3 versions of Windows or macOS. While they have an organized structure, it’s not defined that way!

      Reply
  7. The Post is really amazing and very helpful, however need some guidance on understanding the difference in between /var/log/lastlog and /var/log/dmesg
    Thank you.

    Reply
    • @Bhabani,

      The /var/log/lastlog file is used to keep succesful login information to the host, whereas /var/log/dmesg stores all Kernel ring buffers and system changes in real time.

      Reply
  8. Please help us understand how Linux can be secure when all the file structure is well known and the files can be easily changed if you know how to program. An explanation for an end user would be helpful so that it would promote Linux. A comparison of other OS’s would be helpful.

    Reply
  9. Good stuff, some stuff isnt accurate though, anything ending with a .d is a directory, like

    /etc/profile.d : Application script, executed after login.

    its a dir for a bunch of other scripts

    Reply
  10. Thanks for posting interesting article .can any one please help me that how we
    See the predefine structure definition in Ubuntu eg passwd

    Reply
    • Welcome Vivek, Keep Connected for more such posts.
      And i will be wriitng on /etc/passwd file format soon!

      Reply
  11. This is very informative, I am learning linux and become a fan of it. Found this very helpful to understand the file-system.
    Thanks for the post.

    Reply
  12. You could also see this in the documentation by viewing the “hier” man page. This also gives a description of the linux filesystem hierarchy. (man hier)

    Reply
      • Well done! Thanks!

        Isn’t it /proc/version instead of /version?

        And because this article is for the beginners, I would add as a general info that all commands have to be run with a preceded cat e.g cat /proc/version

        Reply
  13. nice work, but there is one little thing:

    /usr means “unix system resources” and has nothing to do with user resources. all files in /usr can used from different computers or jails at the same time.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.