Sunday, January 4, 2009

When setting up a fresh linux distribution it is often easier to just set up an entire hard drive as root partition. That root partition is represented as / in unix like operating systems including linux. The various directories exist usually within root, or /

The / directory or root directory is not to be confused with the root account. The root user's home directory or workspace is actually located at /root

Some other common directories that make up the basic linux directory structure are;

/boot (This is where the boot information is stored, as the name suggests)

/etc (Most programs including system programs keep their configuration files here, some of which can be hand edited with a program called VI, or VIM.)

Within /etc there are a few vital files that linux needs, those are /etc/inittab which is much like autoexec.bat or system.ini in dos/windows environments. It describes what processes are started at boot time.
and of course the all important /etc/fstab which contains information about various file systems for automounting at boot time. If this file did not exist you would have to mount file systems manually.

/bin and /usr/bin are more or less the same idea, they hold the executables such as 'ls' and 'cp' and 'mv' these executables are called from their path to do the various things that one would like to do when in a shell environment. These programs are often called upon by sub routines in programs to pipe or bring information to the program as variables that can be used for data manipulation. It really doesn't make a difference which of these to executable paths you choose to put your programs. When you type a command at the BASH prompt, BASH looks in both of these directories to see if the program exists.

/usr is kind of reserved for applications and their components, the source code, pictures, documentations etc. Even configuration files can be kept here although usually that kind of thing goes in /etc as described earlier.

/usr/doc is self explanitory, if it's not then you really should take up a nother hobby... :)
/usr/share contains config files, photos and other components that may be accessed by all users of the system.

/usr/src usually contains the source code for programs that you install.

/usr/include contains header files for use with C programs at compile time. Most C programs rely on these header files to build programs while you install them on your particular system.

/lib (contains libraries for programs, they can be dynamically linked just like DLL programs are in windows.)

/home (This is where all your users data will be stored. Whenever I format a new hard drive I always put this on it's own partition.)
So you will have a / partition for all the previously mentioned directories, and then you will have a /home that my look something like;

/home/user1
/home/user2
/home/user3 etc...

/var is an important place where files that change on a regular basis are stored. Such as log files etc.

/var/mail obviously for keeping in/outgoing mail for users.

/tmp writable by most programs and users, programs keep temporary files here while they are being executed.

/dev (Here is where all the hardware on your system is stored. The information about how your system can use the hardware is contained in the files.)

/mnt (This directory is for physical devices usually removables like floppy drives, cdrom drives and or usb mass storage devices.) On some more recent systems this is also stored in /media


/proc (This isn't really a directory it contains some information about the kernel and contains a bunch of numbers, each one associated with a process or running task on your system.

/lost+found (When your system crash's, files that were open and not yet properly written to the hard drive are kept here. This way you can restore files that may otherwise not be recoverable when the system powers down.

I know it's not an exhaustive list, but hopefully this gave you some sense of how the linux directory structure is layed out. People often ask me about this and at first it can be a bit confusing...

Cheers!

No comments:

Post a Comment