File System
File System
File System
• / : The slash / character alone denotes the root of the file system tree.
• /bin : Stands for “binaries” and contains certain fundamental utilities, such as ls or cp,
which are generally needed by all users.
• /boot : Contains all the files that are required for successful booting process.
• /dev : Stands for “devices”. Contains file representations of peripheral devices and
pseudo-devices.
• /etc : Contains system-wide configuration files and system databases. Originally also
contained “dangerous maintenance utilities” such as init, but these have typically
been moved to /sbin or elsewhere.
• /home : Contains the home directories for the users.
• /lib : Contains system libraries, and some critical files such as kernel modules or
device drivers.
• /media : Default mount point for removable devices, such as USB sticks, media
players, etc.
• /mnt : Stands for “mount”. Contains filesystem mount points. These are used, for
example, if the system uses multiple hard disks or hard disk partitions. It is also
often used for remote (network) filesystems, CD-ROM/DVD drives, and so on.
• /root : The home directory for the superuser “root” – that is, the system
administrator. This account’s home directory is usually on the initial filesystem, and
hence not in /home (which may be a mount point for another filesystem) in case
specific maintenance needs to be performed, during which other filesystems are
not available. Such a case could occur, for example, if a hard disk drive suffers
physical failures and cannot be properly mounted.
Mounting
• Mounting makes file systems, files, directories, devices and special
files available for use and available to the user.
• Its counterpart umount instructs the operating system that the file
system should be disassociated from its mount point, making it no
longer accessible and may be removed from the computer.
• /tmp : A place for temporary files. Many systems clear this directory
upon startup; it might have tmpfs mounted atop it, in which case its
contents do not survive a reboot, or it might be explicitly cleared by a
startup script at boot time.
• /sbin: Contains binary (executable) files, usually for system
administration. For example, fdisk and ifconfig utilities
• /kernel : Contains kernel files
• /usr : Originally the directory holding user home directories, its use has changed.
It now holds executables, libraries, and shared resources that are not system
critical, like the X Window System, KDE, Perl, etc. However, on some Unix
systems, some user accounts may still have a home directory that is a direct
subdirectory of /usr, such as the default as in Minix. (on modern systems, these
user accounts are often related to server or system use, and not directly used by
a person).
• /usr/bin : This directory stores all binary programs distributed with the operating
system not residing in /bin, /sbin or (rarely) /etc.
On UNIX systems there are two flavors of special files for each device,
• character special files and
• block special files :
• When a character special file is used for device Input/Output(I/O),
data is transferred one character at a time. This type of access is
called raw device access.
• When a block special file is used for device Input/Output(I/O), data is
transferred in large fixed-size blocks. This type of access is called
block device access.
Pipes
• Pipes – UNIX allows you to link commands together using a pipe.
The pipe acts a temporary file which only exists to hold data from
one command until it is read by another.
• A Unix pipe provides a one-way flow of data. The output or result of
the first command sequence is used as the input to the second
command sequence.
• To make a pipe, put a vertical bar (|) on the command line between
two commands. For example: who | wc -l
• In long-format output of ls –l , named pipes are marked by the “p”
symbol.
File Attributes
File attributes
• file name: the name associated with the file (recall, this can be any type of file)
• modification date: the date the file was last modified, i.e. a "time-stamp". If
the file has not been modified within the last year (or six months for Linux),
the year of last modification is displayed.
• size: the size of the file in bytes (i.e. characters).2
• group: associated group for the file
• owner: the owner of the file
• number of links: the number of other links associated with this file
• permission modes: the permissions assigned to the file for the owner, the
group and all others.
Modifying File Permissions
inode
• An Inode number is a uniquely existing number for all the files in
Linux and all Unix type systems.
• When a file is created on a system, a file name and Inode number is
assigned to it.
• Generally, to access a file, a user uses the file name but internally file
name is first mapped with respective Inode number stored in a table.
• In Unix based operating system each file is indexed by an Inode. Inode
are special disk blocks they are created when the file system is
created. The number of Inode limits the total number of
files/directories that can be stored in the file system.
• Inode number is also known as index number. An inode is a unique
number assigned to files and directories while it is created. The inode
number will be unique to entire filesystem.
• When a file is created inside a directory then the file-name and Inode
number are assigned to file. These two entries are associated with every file
in a directory. The user might think that the directory contains the complete
file and all the extra information related to it but this might not be the case
always. So we see that a directory associates a file name with its Inode
number.
• When a user tries to access the file or any information related to the file
then he/she uses the file name to do so but internally the file-name is first
mapped with its Inode number stored in a table. Then through that Inode
number the corresponding Inode is accessed. There is a table (Inode table)
where this mapping of Inode numbers with the respective Inodes is
provided.
When are Inodes created?
• The Inode table contains all the Inodes and is created when file
system is created. The df -i command can be used to check how many
inodes are free and left unused in the filesystem.
• df -i
Inode Number
• Each Inode has a unique number and Inode number can be seen with
the help of ls -li command.
• Ls –li disk1
https://linoxide.com/linux-command/linux-inode/#:~:text=For%20example%2C%20the%20inode%20contains,decided
%20at%20filesystem%20creation%20time.