Linux Classes
Share This With a Friend  

How Do Linux File Directories Work?



A Linux directory is a special file that acts as a container for other files and even other directories. You can create directories to hold groups of related files as an alternative to keeping all your files in one huge directory.

A Linux file system is like a filing cabinet with a bunch of folders, each of which can contain subfolders and files.

After installing Linux and creating a new hermie user account, you'll end up with a file system hierarchy like the one shown here.




              /                                   <-- The root of the file system
| | | | | | |
| | | | | | |
bin dev etc home sbin root usr <-- Directories below the root
| |
hermie sigmund <-- User home directories

As you can see, the file system resembles an upside-down tree and is very similar to the treelike directory structure in DOS. The top level is denoted by a slash (/) and is called the root directory. Several system-related directories such as bin, dev, and etc appear below the root directory--here's a summary of their purpose in life:

/bin Contains the Linux system commands and programs (also called binaries). Pronounced "slash bin."

/dev Contains special device files that correspond to hardware components. Pronounced "slash dev."

/etc Contains configuration files for Linux and other installed software. Pronounced "slash et-see."

/home Contains the home directories (personal storage) for each user on the system. Pronounced "slash home."

/sbin Contains more Linux binaries (special utilities not for general users). Pronounced "slash ess-bin."

/root The home directory for the root user; not to be confused with /. Some Linux systems use /home/root instead of /root. Pronounced "slash root."

/usr  Contains system programs and other files for general users such as games, online help, and documentation. By convention, a user should not put personal files in this directory. Pronounced "slash user."

Note: Unless you are an All-Knowing Linux Guru, you should never combine or delete any of the directories (or files therein) that appear just below the root directory. This could prevent your system from booting or operating properly.

Previous Lesson: Linux File Names
Next Lesson: Directory Terminology



Comments - most recent first
(Please feel free to answer questions posted by others!)

Fuzzle Irfan     (17 Mar 2012, 01:23)
My question pertains to the /dev directory. I installed Oracle Linux 5.7 on my machine with a single hard disk. The hard disk shows up /dev/sda. I'd like to add two USB sticks of 8 GB each and want to see them as /dev/sdb and /dev/sdc. How would I accomplish such a thing? Thank you in advance.
wednesday     (13 Mar 2012, 17:56)
Thank you so much for this tutorial! I was ready to throw in the towel on linux, but you saved me! :)
Ramy Al Zuhouri     (27 Feb 2012, 14:25)
I have ubuntu 10.10 and I have also other directories like for example selinux, opt, lost+found; What about these?
Bob Rankin     (30 Jan 2012, 09:09)
@mayur - Sorry, there is no hole in Linux.
mayur patre     (29 Jan 2012, 23:05)
i want hole information on linux
mache     (29 Jan 2012, 19:36)
Great explanation! Thank you!
Anthony     (23 Jan 2012, 18:06)
Microsoft stole the Unix file system and changed it just enough (using \ instead of / as separators) to not be charged with outright copying the file system idea? Come on! If you knew the truth you'd realize that Gates bought the OS for $50,000. It was no secret that Microsoft did not create MS-DOS, or the file system.

Symo kirui     (18 Nov 2011, 01:24)
The site is interactive n informative!gudos to all my pals!
aaron     (11 Oct 2011, 15:42)
I very much love this site! All your unix are belong to us!
isha     (08 Oct 2011, 03:14)
This is usefull for all so it's a "GREATE SITE"
Thanks for this service
johnson     (03 Sep 2011, 02:44)
yes what about the /boot and /var directories? there are also many other ones that i found when i ls my root directory
Steve     (17 Jun 2011, 17:13)
Mea Culpa ... looks like there is a /root and also a /boot.
Steve     (17 Jun 2011, 17:09)
Isn't Prasenjit right? Shouldn't "root" instead be "boot" (directory).
Mike     (01 Jun 2011, 15:54)
a great tutorial, best of all
thanx a million
love kaushik     (22 May 2011, 04:49)
really liked the tutorial a lot. thanks 4 maintaining such a great website. was looking 4 such web 4 long.
Prasenjit     (28 Mar 2011, 14:47)
What about /boot directory under / directory?
Mogge     (11 Mar 2011, 15:33)
Great site. Good tutorials :)
tpat     (03 Feb 2011, 10:26)
This website contains very useful info. for beginner. Thanks
Didier     (17 Jan 2011, 09:32)
I love so much LUNIX.
Nasir     (29 May 2010, 00:39)
this is very useful information here on this site.
can any one tells us about linux servers such as Asterisk, Qmail and others.

Bob Rankin     (17 May 2010, 12:03)
Nothing to do with the Google ads, really. Just that I have a 2-column layout in that part of the page. I've added a few blank lines to fix the problem.
Eric D     (17 May 2010, 09:56)

He is using Google Ads causing the page shift and causing the viewing issues.
Conor     (05 May 2010, 16:17)
I'm enjoying the tutorials but your directory structure isn'.t showing up properly - the lines are breaking in all the wrong places. Might have something to do with the width of my browser window but it doesn't look the same for everybody.

Perhaps you could put the diagram in image form? Of course, everybody viewing it from a terminal wouldn't be able to see it then...
chandana     (05 May 2010, 00:56)
Great tutorial, enjoyed every bit of it. Can u please deal with linux in dba perspective?
rp     (13 Apr 2010, 03:19)
what is the /var diractory
PJ     (24 Feb 2010, 02:19)
This is a very informative and well explained tutorial for beginners like me.Thanks a lot!!!!!!

I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But don't ask me to send what you already have. :-)

NO SPAM! If you post garbage, it will be deleted, and you will be banned.
Notify me about new comments on this page
Hide my email

Ask Bob Rankin - Free Tech Support

Copyright © by - Privacy Policy
All rights reserved - Redistribution is allowed only with permission.