Unix Directory Structure
Unix Directory Structure
Unix Directory Structure
Directiory is a file with special format where the information about other files is stored in
the system. Unix directory structure is very simple.
These files contain audio,video,executable file or help information.
So,Unix uses a hierarchical file system structure, much like an upside-down tree, with
root (/) at the base of the file system and all other directories spreading from there.
This tree structure contain many files which identified by path.
Means a Relative path (from the root point) and absolute path (from the current
location).
So, this unix structure is different from windows and MS DOS system. If youre coming
from Windows, The C:\ drive and drive letters are gone, replaced by a / and other sub
directories, most of which have three letter names.
Ex: a software named WinRAR , which is used for compression and decompression of
data.i sinstalled in our system. Files related to configuration , help and executable of
WinRAR are all stored together in windows, while in unix there are separate directories
for configuration , help and executable of program.
Other difference is that representation of format:
EX: path is represented by (windows use backslash)
Drive:\foldername\sub_folder_name\file.extension
In unix (use forward slash)
/foldername/sub_folder_name/file.extension
1. / Root
Every single file and directory starts from the root directory.
Everything on your Linux system is located under the / directory, known as the root
directory.
2. /bin User Binaries
7. /var Variable Files
Contains binaries, libraries, documentation, and source-code for second level programs.
/usr/local contains users programs that you install from source. For example, when you
install apache from source, it goes under /usr/local/apache2
Contains library files that supports the binaries located under /bin and /sbin
Contains shared library files and sometimes other kernel-related files
Names are helpful to humans but, the file system recognizes a file not by its name but by
a number. That number through which the operating system reaches the location and
other attributes of that file is called as an inode number
Inode: its a data structure that keeps track of all the information about a file. Each file
have a small table associated with a file called I-node.(index number)
You store your information in a file, and the operating system stores the information
about a file in an inode(sometimes called as an inode number).
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.
Inode number File nme
To check inode number of file use following command, first field in ouput is an inode number.
# ls -il tecadmin.txt
1150561 -rw-r--r-- 1 root root 0 Mar 10 01:06 tecadmin.txt
You can also use stat command to find out inode number and its attribute:
$ stat /etc/passwdOutput:
File: `/etc/passwd'
Size: 1988 Blocks: 8 IO Block: 4096 regular file
Device: 341h/833d Inode: 32820 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2005-11-10 01:26:01.000000000 +0530
Modify: 2005-10-27 13:26:56.000000000 +0530
Change: 2005-10-27 13:26:56.000000000 +0530