File System in Brief


Computers use particular kinds of structure/systems to store and organize data on media, such as a hard drive, DVDs or in a flash drive called file system. Linux supports different file systems; eg: ext4, ext3, ext2, zfs, ntfs, smb etc.. This allows Linux to co-exist with many systems.


The Linux file system is a hierarchically structured tree where every location has its distinct meaning.

The Root File System ( / ): The root file system ( / ) is the parent of the entire file system. It is the first file system that is mounted when the kernel boots, unless from an initial ramdisk (initrd), and system will not function properly if the kernel detects corruption on this file system. Also, due to the nature of the boot process, this file system will eventually become writable. A root user is the master user in linux operating systems with the highest privileges.  Root user files are stored in /root. If /root is compromised, / will be compromised, so access to /root is by default set for only the root user for security reasons.

File types in Linux.
Linux will consider everything (files, directories, links, etc) as a file.  If something is not a file, it is a process. To start working on Linux, the user has to deal with different file types to effectively manage them.  

There are 7 file types;
Normal files
-
cat etc..



Directory files
d
mkdir, rmdir, rm-rf etc...



Character device file
c
Files inside /dev. Keyboard, Serial port Mouse etc.



Block device file
b
Device for which huge volume data can save. HDD



Socket file
s
If 2 or more programs work simultaneously in memory, for communicating with each other a local domain socket file will be used.



Named pipe file
p
When the local domain socket file start working, there will be a named pipe for the communication.



Link file
l
Softlink: A file/shortcut which is a pointer to another file; if the original file is deleted, the softlink will not work. Deleting the softlink does not affect the original file.

Hardlink: A duplicate entry for the original file with the same location.  Deleting the original file does not delete the file as long as there are any hardlinks associated with it.  And deleting the hardlink does not delete the original file too.

Classifications of File system.

Programs
All the programs


Library Calls
A program which is called to run another program.


Special Files
Hardware device file.


Miscellaneous Files
These are a number of files that control the behavior of C News, but are not essential. Newsgroups, localgroups, mailpaths, distributions, log, errlog, batchlog etc..


Kernel Routing
Kernel files were stored location.


System call
 Files which were calls for System kerenel.


Games
  All games programs


System Administrator Command
  Commands which are called for 
  administrative purposes.

System Required Locations

The system-required locations are locations cannot place on another file system medium because those locations are required by the mount command itself to function properly
  • /bin usually contains executable programs needed to bring the system up and running. Recently however, more and more distributions are moving all applications towards /usr/bin and are using symbolic links to transition towards this new structure.
  • /etc contains all the configuration files for the system (not the user-specific configurations)
  • /lib usually contains the system libraries necessary to successfully boot the system and run the commands which are located inside /bin. Recently however, these files are also being migrated towards /usr/lib.
  • /sbin, just like /bin, contains executable programs. However, whereas /bin has programs which users can use as well, /sbin contains programs solely for system administrative purposes.

Userland Locations

Userland locations are any location outside the kernel
  • /usr is the root of the userland locations (and usually the mount point of the separate medium).
  • /usr/X11R6 contains all the files necessary for the graphical window server (X11).
  • /usr/bin contains all the executable programs.
  • /usr/lib contains all the libraries for the above mentioned programs.
  • /usr/share contains all the application data for the various applications.
  • /usr/local is often a separate mount as well, containing programs specific to the local system.
  • /usr/sbin is, like /usr/bin, a location for executable programs, but just like /bin and /sbin, /usr/sbin contains programs for system administrative purposes only.

Special Kernel-provided File Systems

Some locations on the file system are not actually stored on a disk or partition, but are created and managed on-the-fly by the Linux kernel.
  • /proc contains information about the running system, kernel and processes
  • /sys contains information about the available hardware and kernel tasks
  • /dev contains device files

General Locations

General locations are, well, everything else which might be placed on a separate medium...
  • /home contains the home directories of all the local users.
  • /boot contains the static boot-related files, not actually necessary once the system is booted (for instance, it includes the bootloader configuration and kernel image)
  • /media contains the mount points for the various detachable storage (like USB disks, DVDs, ...)
  • /mnt is a location for temporarily mounted media (read: not worth the trouble of defining them in fstab)
  • /opt contains add-on packages and is usually used to install applications into which are not provided by your package manager natively (as those should reside in /usr) or build specific to the local system (/usr/local).
  • /tmp contains temporary files for the system tools. The location can be cleansed at boot up.
  • /var contains data that changes in size, such as log files, caches, etc.
Important Directories
Different distributions have different directory structures, despite attempts at standardization such as the the Linux Filesystem Hierarchy Standard (FHS) organization.
  • /bin  Commands needed for minimal system operability.
  • /boot Kernel and files needed to load the kernel.
  • /dev Device entries for disks, printers etc..
  • /etc Critical startup and configuration files.
  • /home Home directories for users.
  • /lib Libraries and part of the C Compiler.
  • /media Mount point for filesystems and removable media.
  • /opt Optional application software packages.
  • /proc Information about all running process.
  • /root Home directory of the superuser.
  • /sbin Commands for booting, repair and recovering the system.
  • /tmp Temporary files that may disappear between reboots.
  • /usr Hierarchy of secondary files and commands.
  • /usr/bin Most commands and executable files.
  • /usr/include Header files for compiling C programs.
  • /usr/lib Libraries and support files for standard programs.
  • /usr/local Local software (Software write or install by user).
  • /usr/local/bin Local executables.
  • /usr/local/etc Local system configuration files and commands.
  • /usr/local/lib Local support files.
  • /usr/local/sbin Statically linked local system maintenance commands.
  • /usr/local/src Source code for /usr/local/*
  • /usr/man Online manual pages.
  • /usr/sbin Less essential commands for system administration and repair.
  • /usr/share Items that might be common multiple systems.
  • /usr/share/man Online manual pages.
  • /usr/src Source code for nonlocal software packages.
  • /var System specific data and configuration files.
  • /var/adm Varies logs, system setup records, strange administrative bits.
  • /var/log Various system log files.
  • /var/spool Spooling directories for printers, mail,etc
  • /var/tmp More temporary space.                       

No comments:

Post a Comment