Linux 101: Demystifying the Linux directory structure

2 weeks ago 4
ARTICLE AD BOX

Jack Wallen helps you to understand what is housed in each of the directories found under the root directory in Linux.

Linux written on paper sitting on folder

Image: Hadayeva Sviatlana/Shutterstock

Some new users have trouble understanding the Linux directory structure, so I thought I'd take a moment to demystify those strange folder names. It's not nearly as complicated as you might think. Once you understand what's what, it all starts to make sense. 

SEE: C++ programming language: How it became the foundation for everything, and what's next (free PDF) (TechRepublic)

That said, let's take a look at these strange directories. 

  • First is the root directory, which is often noted by a forward slash (/). This houses everything on your Linux system, so it's pretty important. 
  • Next up is /bin, which contains all essential executable binaries that are required for a system to function in single-user mode. These executables aren't user applications, but essential commands that are used by the system (but can also be used by users), such as less and ip
  • Next is /boot, which contains all the files required for the system to boot. You'll then find /dev, which contains several special device files, such as /dev/sda, which represent hardware and virtual devices. 
  • The /etc drive is where all of the system-wide configuration files for applications and services are. 
  • The home directory, which is /home, houses all directories for users. 
  • Library files (which are used by essential binaries) are found in /lib. 
  • There's also the /lost+found directory, which stores recovered files that are used in case of a system crash. 
  • The /media directory contains all subdirectories for removable devices (such as external drives). 
  • The /opt directory is for optional packages and serves as a common location for proprietary software that doesn't tend to follow the standard file system hierarchy. 
  • System and process information files are stored in /proc. 
  • The Root user home directory is isolated from home and is found in /root. 
  • Applications can store transient files for sockets and process IDs in the /run directory. 
  • The /sbin directory houses more executable binary files, but these are those that are used primarily for system administration. 
  • The Service Data folder (/srv) is a location that houses data for services that are provided by the system (such as for the Apache webserver). 
  • All temporary files are stored in /tmp and are deleted when the system is restarted. 
  • User binaries (applications used only by the user and not by the system) are stored in /usr. 
  • And finally, the /var directory houses all variable data files, such as log files (in /var/log) as well as the Apache document root (in /var/www/html/). 

And that's the Linux directory structure demystified. Once you understand how this structure is laid out, Linux becomes considerably easier.

Subscribe to TechRepublic's How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Open Source Weekly Newsletter

You don't want to miss our tips, tutorials, and commentary on the Linux OS and open source applications. Delivered Tuesdays

Sign up today

Also see

Read Entire Article