Udemy logo

linuxvsunixIn this blog, we will start to learn the Linux directory structure, where you can find different components of the Linux operating system. We will also see how applications can use the same conventions as the Linux operating system for their directory structure as well.

Get started with Linux directory structures on Linux servers.

First, I’d like to share with you some of the most common top-level directories that you’ll see when using the Linux operating system. There might be several top-level directories to be aware of, but these first few are the most important, and they’re the ones that you’ll interact with the most often.

The Linux directory structure is like a tree. The base of the Linux file system hierarchy begins at the root. Directories will start to branch off at the root, but everything starts at a root. Let’s begin with important terminology you will need to master.

The directory separator in Linux is a forward slash. Most of the time, we just abbreviate this to ‘slash.’ Often, root is referred to as slash, since there are no other directories. If you hear someone say, “Look in slash,” or “That file is in slash,” they are referring to the root directory.

Bin, or /bin, is where you’ll find binary files, which are executable files. Programs are written in source code, and this is human-readable text. These text files are then compiled into machine-readable binaries. They’re called binaries because machine code is a string of zeroes and ones. Just know that applications that you can run are sometimes located in /bin.

/etc, or etcy, is where you can find configuration files. Configuration files control how the operating system or applications behave. For example, there’s a configuration file in /etc that tells the operating system whether to boot into a text mode or into a graphical mode.

/home is where user home directories live. So, for example, your home directory would be /home/<yourname>. Linux systems can, and often do have, multiple users or multiple user accounts, and the home directory is where you can separate your data from another account’s data. You can store anything you want to in your home directory. You could store documents, or music files, or your vacation pictures.

Opt is where optional or third-party software lives. Opt is for software that is not bundled with the operating system. For example, Google Earth is not part of the standard Linux operating system. So Google Earth gets installed in opt.

/tmp is called temp, and it’s for temporary space. Most Linux distributions clear /tmp at boot time, so if you put some files in temp and the Linux server gets rebooted, or your Linux desktop gets rebooted, your files will be gone. Now, temp is a great place to store temporary files, but do not put anything in temp that you want to keep long term.

/usr is called user, and this is where user-related programs live.

Each one of these directories can have sub-directories. For example, home is : /home/user name.

User is no different. There will be a sub-directory structure within user. And you’ll find binary programs and executables located in /usr/bin, user bin.

/var, also called var, is for variable data. Think of things that change often. Things that change often on a Linux system are typically log files that are generated either by the operating system itself or applications.

In Linux, we typically talk about directories. In other operating systems, they may call the similar concept ‘folders.’ If you think about it in terms of folders, then slash or root is the main folder and each one of these are sub-folders. Again, ‘folder’ and ‘directory’ is often used interchangeably. In Linux, again, we use the term ‘directory.

Understand Linux structures and distribution

To make it a little easier to understand, here’s another way to visualize this. For example, we can see /home/<yourname> has three directories: documents, downloads, and music.

Up until this point, we’ve only covered about a few top-level directories. However, when you actually get on a live Linux system, you’re going to see that there are several other top-level directories. I want to expose you to these other top-level directories so that you’re slightly familiar with them when you see them.

Let’s start with /cd-rom. Oftentimes, Linux distributions will use that directory as what is called a ‘melt point,’ and when you insert your CD-rom, it will get melted on /cd-rom. That is where you can access the files that are located on the CD-rom.

Other Linux distributions use /media. Again, this is where you could find files that are located on CD-roms or DVDs that you place inside your computer.

Some Linux operating systems use /srv as a location to place data that is served by the Linux server. For example, web files would be in /srv/www, or if it’s an ftp server, maybe the files would be located in /srv/ftp.

Let’s switch gears and start talking about application directory structures. You’ll find that some applications that are not bundled with the Linux operating system are installed in /usr/local, and often they’re installed in /usr/local/program name. From there, they’ll have their own sub-directory structure.

Take a Linux crash course at Udemy.com

Let’s use an example to get a better idea on what I’ve been explaining. For instance, CrashPlan is backup software that’s not bundled with the Linux operating system. If you were to install it from their website, it would install into /usr/local/crashplan. And if you wanted to find binary for this program, you would look in /usr/local/crashplan/bin. If you wanted to configure how the program behaves at run time, you would modify configuration files that are located in /usr/local/crashplan/etc. If you wanted to see the log files that the program is generating, again, look in log. /usr/local/crashplan/log.

We’ve already talked about how applications can be installed in opt. AVG is anti-virus software. It’s not bundled with the Linux operating system. And this particular application installs in opt. /opt/avg. Again, this is a common pattern. /opt/program name/bin.

Here is a slight variation that you’ll sometimes see applications follow. Let’s take this fictitious application called MyApp, for example. Even though the main MyApp program get installed in /opt/myapp, were maybe the binaries live and the libraries live, you’ll also see that it can install files in /etc/opt/myapp. And that’s where you would find the configuration files. The log files would be in /far/opt/myapp.

Sometimes, when applications get installed, they’re not given their own directory structure, they’re installed in a shared matter. So maybe MyApp gets installed in /usr/local. In this case, it would be /usr/local/bin/myapp. And the configuration file could be /usr/local/etc/myapp.com. /usr/local/bin would not only contain MyApp, but other applications that were installed in this shared manner.

Another common practice is to use /opt/company name, or /opt/organization name. For example, if you work for the Acme Corporation, and you logged on to one of their Linux servers, you may see something like /opt/acme/bin, where the software that was written for that company or by that company is installed.

Another slight variation on this theme is /opt/company name/product name. A real-life example is Google. When you install Google Chrome on Linux, it installs into /opt/google/chrome. Earth installs to /opt/google/earth.

Here’s yet another slight variation. /opt/organization name, or /opt/company/organization name, or even /usr/local/company name/organization name.

The most important thing to know about applications that are not shipped with the Linux operating system is that they’re typically found in /opt, called opt, or in /usr, called user. And when these applications are installed, they’re typically installed in user local, /usr/local.

The most common top-level directories that you’ll interact with on a Linux system are /, also called root, /bin, /etc, /home, /opt, /temp, /usr, and var.

And applications that are not shipped with the operating system are typically installed in /usr/local and /opt.

Hungry for more? Try this step-by-step, logical guide to Linux directory structures on Linux servers today!

Page Last Updated: April 2014

Top courses in Linux

Linux Administration: The Complete Linux Bootcamp for 2024
Andrei Dumitrescu, Crystal Mind Academy
4.7 (3,209)
Mastering Linux: The Comprehensive Guide
Jannis Seemann, Denis Panjuta
4.7 (760)
Linux Technical Interview Questions and Answers
Kashif Ali, Imran Afzal
4.6 (1,375)
Linux for Beginners: Linux Basics
Muharrem AYDIN
4.5 (446)
Ubuntu Linux Server Basics
Cody Ray Miller
4.7 (3,003)
Linux Diagnostics And Troubleshooting
Shikhar Verma • 85k+ Students Worldwide
4.4 (1,053)
Linux for Network Engineers: Practical Linux with GNS3
David Bombal, Experts with David Bombal
4.9 (4,537)

More Linux Courses

Linux students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo