The filesystem… explained

Taking a quick look in the command line, reveals a world a lot different from what you might be used to. If you come from a Windows/DOS box, it’s, well, a world apart!
So how does it work in Linux box? How’s the file system structure organized? How do we move around? Lets hope i can help… =)

The Linux filesystem structure follows a standard, the FHS (FileSystem Hierarchy Standard), and most distributions follow these directives (not all though). These are just a set of suggestions, of how you should organize everything in a strict way, so everything has a place.

It all starts with the ”root” directory (/), which is the big container, where the remaining filesystem lives. Making a quick “ls -la” (command lists directory contents, options include files starting with . and long list display) on my / (root) i get:ls -la /
So, let me briefly try to explain what this are:

. - refers to the current working directory (in this case, /)
.. - refers to the parent directory (what is before)
bin - where binaries for all users reside
boot - place where the kernel, the system map and the boot-loader files live
dev - devices files
etc - configuration files for almost everything in your system
home - user’s home directory (except for the super user, root)
lib - libraries and modules that are shared in the system
lost+found - where unlinked files found by fsck are stored
mnt - mount point (fancy word for directory) for detachable media (CD-ROMs, floppies, USB mass storage)
opt - third-party application software
proc - does not take space on disk, its generated and updated in real time in RAM, and represents kernel, hardware properties and processes information
root - super user root’s home
sbin - binaries (for root only)
tmp - temporary data, its world-writable, suitable for use by applications for storing interchangeable temporary data.
usr - often the biggest directory, its used to contain shared user applications and data. Its read-only.
var - variable data, that regularly changes, such as logs, web-pages, FTP, mail and printer spools, etc

More directories can exist, but these are the common ones.

So, exactly what goes where? The FHS does not allow programs to create their own unique directories inside the /usr directory, so a bunch of sub-directories exist, which are:

bin - it contains all the users commands
include - contains header files used in C programs
lib - contains libraries
local - local programs that are shared
sbin - system binaries, that do not have to be present for the system itself to work
share - contains data and programs for different architectures

One last thing about Linux filesystem. Hidden files/directories are just normal files/directories with a . in the beginning. For example the .ssh directory inside your home, its not viewable by a normal list command (remember when I used the ls -la), and can’t be deleted by commands such as rm -f *.*. Filenames can be composed by letters, numbers and characters, including the space character (some are not allowed, try it to discover for yourself), so its possible to have a file called mytestfile.txt, my.test.file.txt or my test file.txt! A warning though: if you use spaces in filenames, soon you’ll discover that these are a pain in the butt to work (in the CLI), because you have to put a \ (backslash) when you use space. Just use a _ it’s much simpler! There is no restriction on how name your files, you can even use numbers (nice for sorting), what ever suits you! Its also nice to remember that in Linux, case does matter, so my.test.file.txt and My.text.file.txt are different files; the extension is not a required parameter in file creation, but it’s useful to quickly identify the type of file, and also to manipulate (copy, move, delete…) files around.

I hope i didn’t forget nothing too important! Now its just a matter of using your system, to get used to everything. Later I’ll explain basic navigation inside this perfectly designed filesystem! Have phun exploring…! =)

LINKS: FHS official documentation (version 2.3)



   Share This

1 comment so far ↓

#1 dbugs.org » Blog Archive » Let’s surf! on 02.24.07 at 13:37

[...] last thing on moving.If I’m seeting in any directory (and as you remember from the FHS tutorial), you have a . and a .. corresponding to the current directory and to the parent [...]

Leave a Comment

Creative Commons License
dbugs.org by Marco Garcês is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.