blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

File system part II

In unix all files and directories are under a single parent directory called root. It is denoted by forward slash '/'.


The Filesystem Hierarchy Standard (FHS) defines the main directories and their contents in Linux operating systems.

Directory sturcture:

The majority of these directories exist in all UNIX operating systems and are generally used in much the same way; however, the explanations given here are aligned with the FHS standard.

The below table describes everything you need to know about the default directory structure provided by the linux/unix systems.

/bin/ Essential command libraries that are needed in single-user mode (eg:cat, ls)
These commands are accessible to both the admin and other users.
It usually doesn't contain subdirectories.
The following commands, or symbolic links to commands, are required in /bin.
Command Description
cat To concatenate files and print on std output.
chgrp To change file group ownership
chmod To change the file access permission
chown To change the file owner and group
cp To copy files and directories
date To print or set the system date and time
dd To convert and copy a file
df To report file system disk space usage
dmesg To print or control the kernal message buffer. Kernel output goes to the kernel ring buffer and not to stdout, because stdout is ess specific. To inspect messages on the kernel ring buffer, one can use the dmesg utility.
echo To display a line of text
hostname To show or set the system's host name
kill To send signals to processes
ln To link files
login To begin a session on the system
ls To display contents of directory
mkdir To create directories
mknod To make block or character special files
more To page through lengthy text
mount/unmount To mount/unmount a file system
mv To move or rename files
ps To report processes
pwd To print name of current working directory
rm To remove files or directories
rmdir To remove empty directories
sed The sed stream editior
sh The bourne command shell
stty To change and print terminal line settings
su To change user ID
sync To flush filesystem buffers
uname To print system information


/boot/ Boot loader files
/dev/ Location of special or device files. If you do cd /dev and then ls, you'll see a lot of yellow outlined in black. These are the devices that your system uses or can use. Everything is considered a file in Linux, so your hard disk is kept track of as a file that sits there. If you're using an IDE hard drive (as opposed to SCSI), your hard drive will be known as /dev/hda./dev must contain a command named
MAKEDEV, which can create devices as needed. It may also contain a MAKEDEV.local for any local devices.
/etc/ It contains configuration files. A "configuration file" is a local file used to control the operation of a program; it must be static and cannot be an executable binary .
/etc/opt/ Configuration files for /opt
/etc/X11/ Configuration for the X Window system. This directory is necessary to allow local control if /usr is mounted read only.
/etc/sgml/ Configuration for SGML
/etc/xml/ Configuration for XML
/home/ home is a fairly standard concept, but it is clearly a site-specific filesystem. In normal configurations, each user is given a directory in /home.
User specific configuration files for applications are stored in the user’s home directory in a file that starts with the ’.’ character (a "dot file"). If an application needs to create more than one dot file then they should be placed
in a subdirectory with a name starting with a ’.’ character, (a "dot directory"). In this case the configuration files should not start with the ’.’ character. To view the files cd /home and then ls -a.
/lib/ Libraries needed for system boot and for commands in /bin and /sbin. If loadable kernal modules (LKM) are used then they are put in /lib/modules
/media/ On modern Linux systems the /media directory will
contain the mount points for removable media such USB
drives, CD-ROMs, etc. that are mounted automatically at
insertion.
/mnt/ On older Linux systems, the /mnt directory contains mount
points for removable devices that have been mounted
manually.
/opt/ /opt is reserved for the installation of add-on application (mostly commercial) software packages.
/proc/ The /proc filesystem (is a special type of filesystem) was originally developed to provide information on the processes in a system. But given the filesystem's usefulness, many elements of the kernel use it both to report information and to enable dynamic runtime configuration.
The /proc filesystem contains directories (named by processid, each representing a process) and virtual files (used to transfer information from the kernal to the user and vice versa.
http://www.ibm.com/developerworks/linux/library/l-proc.html
/root/ Home directory for the root user (optional)
/sbin/ Utilities used for system administration (and other root-only commands) are stored in
/sbin,
/usr/sbin, and
/usr/local/sbin.
/sbin contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin.
Programs executed after /usr is successfully mounted are generally placed into /usr/sbin.
Locally-installed system administration programs should be placed into /usr/local/sbin.
Common cmds found under sbin are: shutdown, reboot, fdisk, fsck, halt, init, etc.
Difference between sbin and bin: he division between /bin and /sbin was not created for security reasons or to hide the OS, but to provide a good partition between binaries that everyone uses and ones that are primarily used for administration tasks. Though for certain cmds in sbin execute permission is given only to the administrator.
/srv/ Data for services provided by this system
/tmp/ The /tmp directory must be made available for programs that require temporary files.
Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.
/usr/ Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications.
/usr/bin/ Non-essential command binaries (not needed in single user mode); for all users.
/usr/include/ This is where all of the system’s general-use include files (header files) for the C programming language should be placed.
/usr/lib/ Libraries for the binaries in /usr/bin/ and /usr/sbin/.
/usr/sbin/ Programs executed after /usr is successfully mounted are generally placed into /usr/sbin. It mostly contains cmds for mounting, repair, recovery,etc.
/usr/share/ The /usr/share hierarchy is for all read-only architecture independent data files.
This hierarchy is intended to be shareable among all architecture platforms of a given OS; thus, for example, a site with i386, Alpha, and PPC platforms might maintain a single /usr/share directory that is centrally-mounted.
Note, however, that /usr/share is generally not intended to be shared by different OSes or by different releases of the same OS.
/usr/share/man : Manual pages
/usr/share/doc Most packages installed on the system will include some kind of documentation. In /usr/share/doc, we will
find documentation files organized by package.
/usr/src/ Source code may be place placed in this subdirectory, only for reference purposes.
/usr/X11R6 This hierarchy is reserved for the X Window System, version 11 release 6, and related files.
/usr/local/ The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. Programs compiled from source code
are normally installed in /usr/local/bin. On a newly
installed Linux system, this tree exists, but it will be empty
until the system administrator puts something in it.
/var/ /var contains variable data files. This includes spool directories and files, administrative and logging data, and
transient and temporary files.
/var/cache/ /var/cache is intended for cached data from applications. Such data is locally generated as a result of time-consuming I/O or calculation.
/var/lib/ This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host.
/var/lock/ Lock files for devices and other resources shared by multiple applications .
/var/log/ This directory contains miscellaneous log files. Most logs must be written to this directory or an appropriate subdirectory.
/var/mail/ The mail spool must be accessible through /var/mail and the mail spool files must take the form <username>.
/var/run/ This directory contains system information data describing the system since it was booted. Files under this directory must be cleared (removed or truncated as appropriate) at the beginning of the boot process.
/var/spool/ contains data which is awaiting some kind of later processing. Data in /var/spool represents work to be done in the future (by a program, user, or administrator); often data is deleted after it has been processed.
/var/tmp/ Temporary files preserved between system reboots
/lost+found Each formatted partition or device using a Linux file system,
such as ext3, will have this directory. It is used in the case
of a partial recovery from a file system corruption event.
Unless something really bad has happened to your system,
this directory will remain empty.

Click here to read File system part III

No comments:

Post a Comment