Skip to main content

A quick introduction to the Linux filesystem for Windows users.

This quick tour offers a non-threatening introduction for DOS/Windows users to the not-so-different Linux filesystem structure.

If you've considered giving Linux a closer look but are put off by the slashes, dots, roots, mounts, and terminal weirdness, this introduction to the Linux filesystem structure explains it all from a DOS/Windows perspective. The only assumptions I've made is that you're somewhat familiar with the Windows filesystem layout, as well as some DOS or Command (CMD) Window navigation. You'll find that Linux isn't so different than Windows in many ways. We won't even touch on who stole what from who because it's apparent that inspiration comes from many places.

Just so we're clear, I know that Windows isn't based on DOS anymore. But both Linux and Windows have a command-line interface (CLI), and rather than calling it CMD, Command Window, or something else, it's easier to use the legacy term, DOS for the Windows CLI. I'm also using the terms filesystem and filesystem structure interchangeably. What I'm referring to is the layout of files, directories, configurations, paging, and so on, and not the bit-level formatting of the filesystem such as NTFS or XFS, for example.

First, both Linux and Windows (and Mac) have a hierarchical filesystem layout, meaning that there is a single "root" directory, and all other directories branch off of that. In Windows, your root directories are designated with letters, such as C: or D:. Windows can have many root directories In Linux, the root directory is designated as / and there is only one root directory per Linux computer. Some references call this layout a "tree" structure: When all the directories and subdirectories are expanded, the visual reference is an inverted tree.

Compare the two layouts below. Red Hat Enterprise Linux 8 is on the left and Microsoft Windows Server 2012 R2 is on the right. Note the similarities and differences between the two:

Image
File structure layouts of Linux (left) and Windows (right)

[Want to try out Red Hat Enterprise Linux? Download it now for free.]

Linux has several directories under root (/), while Windows has relatively few. This is because Windows keeps everything except applications under the C:\Windows directory. Applications reside either in the Program Files or the Program Files (x86) directories. Linux keeps its applications under the /usr directory. The Linux /home directory corresponds to the Windows C:\Users directory.

The following table shows important Linux directories and their functions (The -> is a symbolic link or Shortcut, in Windows terminology): 

Directory Purpose
bin -> /usr/bin Directory containing user binaries.
boot Directory containing bootloader files.
dev Directory containing device files.
etc Directory containing configuration files.
home Directory containing user home directories.
lib -> /usr/lib Directory containing system libraries.
lib64 -> /usr/lib64 Directory containing 64-bit system libraries.
media Where DVDs and removable devices are automounted.
mnt Directory used for temporarily mounting remote filesystems and other media.
opt Directory where some third-party software is installed.
proc Directory containing system process information.
root The root user's home directory.
run A runtime scratch directory (RAM-based).
sbin -> /usr/sbin Directory containing system binaries.
srv Directory containing service data.
sys Directory containing devices, kernel modules, filesystems, and other kernel component info.
tmp Directory containing temporary files.
usr Directory containing user programs.
var Directory containing variable files, such as logs and temporary files.

 

Notice that when you write directory names in Linux, you always include the root directory (/) and similarly, you included (C:\) in Windows. It is important to include the root directory references on both operating systems. For example, in Linux, there are directories such as /usr/bin, /usr/sbin, and /tmp. Windows can have multiple roots, so you might have C:\Temp, D:\Temp, and E:\Temp on the same system. You can see that just referring to tmp in Linux or Temp in Windows is confusing and not specific enough to clearly refer to a specific directory.

You'll also notice from my writing that the slashes for Linux are backslashes and Windows are forward slashes or "whacks." Ever wonder why backslash is one word but forward slash is two? In Linux, the backslash is an operator that means to ignore the next character, which would really mess up your file path. So, there are some differences in how you interact with the two operating systems, how you navigate, where things are located, and PATH designations, but you also see several similarities, too. 

While Windows stores configuration files in many different locations, most of them reside somewhere under the C:\Windows directory and its dozens of subdirectories. Linux almost exclusively uses the /etc directory for configurations. Applications in Linux often store their configuration files in their own etc subdirectory (you pronounce etc as et-see). In discussions, if you refer to the /etc directory, /tmp, /home, or any other first-level directory, you don't have to say "slash." Just say the "etc," "home," or "tmp" directory. If you're referring to a subdirectory, you can say "usr bin"(/usr/bin) or "usr local bin"(/usr/local/bin). And usr is pronounced "user." It's similar to the way you refer to the C:\Windows directory by saying, "the Windows directory" (C:\Windows) or to C:\Windows\System32 by saying, "the Windows System32 directory."

By the way, Windows also has an etc directory, but it's well hidden in C:\Windows\System32\drivers\etc. In this etc directory, you'll find files common to both operating systems such as hosts, lmhosts, protocol, networks, and services

At the command line, you navigate both systems using the cd command. The only thing you have to remember is which way the slashes go. As you transition into Linux, you'll find that navigation comes naturally, and the / key is much more conveniently located than the \ key is. Though slash direction won't be the biggest problem you have. Just wait until you type ls at a C:\> prompt and realize what you've done when you see 'ls' is not recognized as an internal or external command, operable program, or batch file error. Typing dir at a Linux command prompt is far less traumatic. Hint: dir is an alias for ls in Linux.

I think you'll find the Linux filesystem organized, easy to navigate, and a pleasure to manage. In future posts, we'll cover Linux permissions and show you how truly powerful and secure Linux is. For now, focus on familiarizing yourself with the layout and the locations of important files and directories.

What to read next

Topics:   Linux  
Author’s photo

Ken Hess

Ken Hess is an Enable SysAdmin Community Manager and an Enable SysAdmin contributor. Ken has used Red Hat Linux since 1996 and has written ebooks, whitepapers, actual books, thousands of exam review questions, and hundreds of articles on open source and other topics. More about me

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX