1.Concept of File System
File system is a System to manage and organize all the resource data which are included in file
- A file system is a set of files, directories, and other structures. File Systems maintain information and identify the location of a file or directory's data. An allocation group contains disk i-nodes and fragments.
Notes :
i-nodes : A directory is a file that contains a table listing the files contained within it, giving file names to the inode numbers in the list. An inode is a special file designed to be read by the kernel to learn the information about each file, ownership, date of creation and of last access and change, and the physical location of the data blocks on the disk containing the file.
1.1 . The Tree Structure
The association of directory can be shown by a structure of a tree. Every unit in this tree is a directory or a file. Rectangle in white demonstrates the directory and that in shadow demonstrates the file.
1.2. The file System Hierarchy
- UNIX system uses the architecture of tree. This tree begins with the root directory as the top, which is signed as "/" in the figure above.
- UNIX system has a lot of commands to organize the directory architecture. For example : We can use commands to create a new directory or copy a file from one directory to another one and so on.
- Meanings for each directory in UNIX system :
- / Root file system
- /usr Shareable operating system command, libraries, and documentation
- /opt Applications
- /var Dynamic information such as logs and spooler
- /stand Kernel and boot loader
- /tmp Operating system temporary files
- /home User directories
- /etc System configuration files
- /dev Device files
---------------------------------------------------------------------------------------------------------------
2. Path
Some basic related knowledge of path. It mainly covers the concept of absolute Path and relative Path, the command to create and delete a directory and some related commands.
- cd
Syntax :
cd dir - Change working directory
Example :
% cd
Change the current working directory to the HOME directory from any location in the file system
% cd /usr/local/lib/play.dir
Change the directory to /usr/local/lib/play.dir
% cd test/play.dir
Go to the directory test/play.dir in current directory
Description :
- ? : Wildcard for a single letter
- * : Wildcard for any letter(s)
- For example ,
- cd *2 means go to the test2
directory beyond current_dir
- cd ?est2 means go to the test2 , directory beyond current_dir
- Some Special Directories
Syntax :
- . - current directory
- .. - parent directory
Examples :
- .
- ./f1
- ..m1
- ../../tm
Description :
- . Stand for /home/current_dir
- ./f1 Stand for /home/current_dir/f1
- ../m1 Stand for /home/m1
- ../../tmp Stand for /tmp
- Absolute Path & Relative Path
The Absolute Path & Relative Path are describing as below :
- There are two different methods to access a directory, One is absolute path, the other is Relative Path.
For example , In the picture above, the current directory is f1 and the destination directory is f2 (Path (1) , We can use the Absolute Path method to do the job:
- cd /tmp/f2
On the other hand, We can use Relative method :
- cd ../f2
- If the current directory is a1 and the destination directory is a2 (Path (2) . We can use the Absolute path method to do the job :
- cd /a2
On the other hand, We can use Relative method :
- cd ../../a2
Anyway, Absolute path is always begin with root directory " / " .
--------------------------------------------------------------------------------------------------------------------
- pwd
Syntax :
pwd - show working directory name
Examples :
% pwd
Result show : /opt/informix
To show the current directory
----------------------------------------------------------------------------------------------------------------
- mkdir
Syntax :
mkdir dirname - make a directory
Examples :
- # mkdir /opt/informix
Create a new directory informix beneath existing directory opt in the root directory
- # mkdir informix/etc
Create a new directory etc beneath existing directory informix in the current directory
--------------------------------------------------------------------------------------------------------------------
- find
Syntax :
find pathname_list [expression]
The most commonly used expression is -name which means searching by name.
Examples:
#find / -name file1
To find file1 from / to all directories by name.
#find / -size +100c
To find files whose sizes is larger than 100 bytes.
--------------------------------------------------------------------------------------------------------------------
- mount
Syntax :
mount - Display the already mounted file
Examples:
% mount
Result :
----------------------------------------------------------------------------------------------------------------------
3. Concept of File
3.1.What is a File?
File is a container for data or a link to a device.
- Every file has a name and may hold data that resides on a disk.
- There are several different types of files :
- Regular files
. text, data (.txt)
. executable programs ( bin file, ftp)
- Directories
- Special files
Description :
- A file is a container or data or a link to a device. There are several types of UNIX files,
- Ordinary file includes plain text file, binary file, mails , images and source codes.
- Special file includes :
. Block device file and Character Device File
- Disks are block devices
- Serial Ports are Character devices
. Symbolic Links are pointers to some other files.
--------------------------------------------------------------------------------------------------------------------
3.2. File Characteristics
- The output of the command : ls -l
Description :
- -l : Lists in long format, giving mode, ACL indication, number of links, owner, group, size in bytes, and time of last modification for each file, if the file is a special file, the size field instead contains the major and minor device numbers. If the time of last modification is greater than six months ago, it is shown in the format "month date year " for the POSIX locale. When the LC_TIME locale category is not set to the POSIX locale, a different format of the time field may be used. Files modified within six months show "month date time" . If the file is a symbolic link, the filename is printed followed by "-> " and the path name of the referenced file.
- The mode printed under the -l option consists of ten characters. The first character may be one of the following :
- d : The entry is a directory;
- D : The entry is a door;
- l : the entry is a symbolic link;
- b : the entry is a block special file;
- p : the entry is a fifo (or "named pipe") special file;
- s : the entry is an AF_UNIX address family socket;
- - : the entry is an ordinary file;
Note : Pipes
- Programs normally have some input and some output. That is that some data has to be entered and some kind of analysis will come out afterward.The input to a program might come from a file, or might be typed into the program by the user. The output might appear on the screen, be sent to a file or to a printer. For most operating systems (not UNIX), that means the programmer has made some decision about where data comes from and goes to, or that the program has some kind of option built into it which the user can control, UNIX, however, is different.
- Programs for UNIX are usually written as though input is typed in by the user, and output appears on the screen. The "redirection" of the data, to or from files, to printers, to other programs is controlled by "pipes". The pipes channel streams of data to different places.
- The next 9 characters are interpreted as three sets of three bits each. The first set refers to the owner's permissions; the next to permissions of others in the user-group of the same group; the third to permissions of others in other group.
- Result Description :
- File permission or Mode : defines the file access permission
- Links : number of associated file names to a single data set
- Owner : the account name of the file owner
- Group : the group name in which members can access this file
- Timestamp : the time when this file was last modified
- File Name :
. Max. Length is 255 characters.
. Case Sensitive
. No Special Extension Name
Description :
- -a : List all entries, including those that begin with a dot (.) , which are normally not listed.
0 comments:
Post a Comment
If there is any comments,Please leave a comment at here.