The UNIX files system internal structure
The boot block
The boot block is usually a part of the disk label. A special set of blocks containing information on the disk layout. The boot block holds the loader to boot the operating system.
The super block
Each UNIX partition usually contains a special block called the super block. The super block contains the basic information about the entire file system. This includes the size of the file system the list of free and allocated blocks the name of the partition, and the modification time of the file system.
Information about each file in the file system is kept in a special kernel structure called an inode. The inode contains a pointer to the disk blocks containing the data in the file, as well as other information such as the type of file, the permission bits, the owner and group, the file size, the file modification time, and so on. The inode does not however contain the name of the file. The name of each file is listed in the directory the file associated with. A directory is really just special type of file containing a list of filenames and associated Inodes; When a user attempts to access a given file by name, the name is looked up in the directory where the corresponding inode is found.
The inode structure is used to explain the difference between a hard link and a symbolic link. A hard link is just another directory entry corresponding to the inode of the file. Neither link is considered to be the real file; both of them are. By adding a hard link to a file, the file has multiple names associated with it. Any changes made to one will affect the other. A file is considered deleted when all of the hard links to it (including the original link to the file) are removed. Renaming one of the links or even the original file will not affect the validity of the other links.
By contrast, a symbolic link is actually a special type of file that contains the name of the file it points to. This file has its own inode and is distinct from the original; it contains only a reference to the pathname of the file
being linked to. When the kernel accessed a symbolic link, it recognizes that it is a pointer to another file, and attempts to find that file. This is why symbolic links will become bad if the original file is moved or deleted; they reference only the name of the original file, not the actual data of the file.
#ls –i displays inode values and file names.
Understanding the Red Hat Linux file system
Like other Unix systems, red hat Linux has a hierarchical file system. The top most directory known as root directory of the file system contains several other directories, sometimes called subdirectories. These directories in turn generally contain subdirectories and files.
The directory structure is not arbitrary. For packages to work properly, the location of important files and directories must be standardized.
The Root (/) Directory
The root directory (/) of a Linux system is the directory that contains all other directories and files. Other directories may be separately mounted and the may or may not be present at system startup. Therefore the file system that contains the root directory must contain all files necessary to operate the system in single user mode. The root directory also contains all files needed to shutdown and recovers or repairs the system.
The following directories are essential and must be part of the root file system.
/bin, which contains binary files used by the system administrators and other users.
/sbin, which contain binary files used by the system administrator
/dev, which contains device files
/etc, which contains host specific configuration data
/lib, which contains system libraries
Linux systems typically include several other directories, which may be used as mounting points for non root file systems or which may be used mounting points for non root file systems or which may contain directories and files that reside on the root file system. Some commonly used directories include
/boot, which contains files needed by the boot loader when booting the system. These files could be placed in the root partition. However, Red Hat, inc. recommends that they be placed in a separate partition to overcome common PC BIOS limitations on the location of boot data
/home, which contains users home directories
/lost + found, which contains files recovered during file system rebuilds
/mnt, which contains mount points for temporarily mounted file systems
/proc, which contains system information
/root, which contains the home directory of the root user.
/tmp, which contains temporary files
/usr, which contains shareable, files not essential to basic system operation
/var, which contains non shareable file snot essential to basic system operation
/media, which contains cdrom ,floppy drives only (only in EL-4)
/bin: The Essential Binary Files
It contains files that are generally commands.
Example: df, netstat, kill, su, ping, echo, pwd, touch, cat , ls, rm ,umount, rmdir, uname, chmod, mkdir, rpm, vi, cp, more
/boot: Boot Loader Files
Many PCs contain BIOS code that cannot load a boot record unless the boot record is stored below a given cylinder (usually 1024) of a disk drive. Red Hat recommends that you avoid boot problems by placing boot loader files in a separate partition and placing the partition on a region of the disk that is accessible to the BIOS
The /boot partition generally contains the first stage of the Linux loader (LILO) in its MBR, located on the first cylinder of the partition. It also contains files such as:
Boot.b, vmlinuz, etc.
/dev: Device Files
The Linux /dev directory includes a variety of device files. Most important device files are
1. /dev all device files resides in this directory.
/dev/lp0 parallel port 1 (LPT1 under DOS)
/dev/lp1 parallel port 2 (LPT2 under DOS)
/dev/sr* SCSI cdrom (* implies a,b,etc)
/dev/st* SCSI tape
/dev/md* RAID array (Redundant Array of Inexpensive Disk)
/dev/eth0 Ethernet card 1
/dev/eth1 Ethernet card 2
Device File Device
/dev/fd0, fd1 Implies 1st and 2nd floppy drive (ie, A:, B: under DOS or windows)
/dev/hd* IDE Hard disk or CD Rom
/dev/hda - primary master
/dev/hda1 - 1st partition of primary master (1,2,3,4, represents partition no:)
/dev/hdb - primary slave
/dev/hdb1 - 1st partition of primary slave
/dev/hdc - secondary master
/dev/hdc1 - 1st partition of secondary master.
/dev/hdd - secondary slave
/dev/hdd1 - 1st partition of secondary slave
/dev/sd* SCSI Hard Disk
/dev/sda -1st hard disk of SCSI
/dev/sda1 -1st partition of SCSI device
/dev/ttyS0 -serial communication port 1 (COM1 under DOS)
/dev/ttyS1 -serial communication port 2 (COM2 under DOS)
/dev/sr* SCSI CD Rom
/dev/st* SCSI Tape
/dev/lp* Parallel Port
/dev/ttyS* Serial Communication Port
/dev/md* RAID array
/etc: Host-Specific Configuration files
It contains files and directories that are specific to local host.
Important files in /etc
fstab File system table
fdprm Floppy disk parameters
gettydefs Login terminal characteristics
group User Groups
inittab System Startup Configuration
lilo.conf Linux Loader Configuration
motd Message of the day
mtab Mounted file system table
nsswith.conf List of sources for information on users, hosts, networks, and services
passwd User accounts
profile Shell initialization script
securetty List of secure login terminals
shadow User accounts encrypted passwords, if shadow password enabled
shells List of approved shells
syslog.conf System log configurations
exports List of nfs exports
ftp* FTP configurations files
host.conf Host name resolution configuration
hosts List of known hosts
host.allow List of hosts allowed access to services
host.deny Hosts denied access to services
host.eqiv List of trusted hosts
xinetd.conf List of internet super server
networks List of known networks
printcap Printer configuration
protocols List of known protocols
resolv.conf Host name resolution configuration
rpc List of rpc services
services List of TCP/IP services
Important subdirectories of /etc/
httpd Configuration of http service
pcmcia Configuration of PCMCIA slots and device
rc.d System initialization files
security Security configuration
skel User environment templates
sysconfig System configuration
X11 X windows system configuration
/home: User home directories
It contains home directories of users other than root users (whose home directory is /root). By default, a users home directory is a subdirectory of /home having the same name as user login.
/lib: Shared libraries and kernel modules
It contains libraries and modules needed to boot the system and run programs residing in the /sbin and /bin directories; other libraries resides in /usr/lib, /usr/X11R6/lib. Modules reside in subdirectories of /lib/modules. (Store files like .dll files in Windows)
/lost+found: Recovered files
When u recover a file system, files and data may be partially recovered resides in this directory.
/mnt: Mount point for temporarily mounted file systems
Mount point of CD-ROM (/mnt/cdrom) and floppy drive (/mnt/floppy)
/proc: System information virtual file system
It is a pseudo file system provided by the kernel that contains files and directories that let system administrators and programmers access system information.
File or Subdirectory Content
Cpuinfo Various architecture depend information
Devices Major device numbers and device group
Dma Registered ISA DMA channel in use
filesystems File system type supported by the kernel
interrupts Information on interrupts and IRQ
Kmsg Kernel message logs
Lodavg Average number of jobs in the urn queue
meminfo Memory allocation information
modules List of loaded modules
Net Network status information
Pci Configuration of PCI devices
Uptime System uptime and idle time
version The version number of running kernel
/sbin: Essential system binaries
It contains essential system binary files used by system administrator.
Halt, lilo, ifconfig, ifport, chkconfig, poweroff, init, probe, ctrlaltdel, shutdown, dump, e2fsck, mke2fs, ipchains, fdisk, fsck, reboot.
/tmp: Temporary files
It contains temporary files and subdirectories that are automatically deleted ( by default 10 days)
/usr: Sharable Files
./usr file may not be available, so it contains no files or directories that are essential for system operation. Soure codes are stored in /usr/src dir .
Important subdirectories of /usr
/usr/bin Commands used by the ordinary
/usr/include Header files
/usr/lib Programming libraries
/usr/man Man files
/usr/src Soruce code
/var: Non-sharable files
It may not be available, and so it contains no essential files or directories.
Important subdirectories of /var
/var/log Log and accounting files
/var/run System information files
/var/spool Spool files including lpd and sendmail
/var/pnp Temporary files
/var/yp NIS files