1, seven file types
Common file types
One of the most common file types in Linux, including plain text files (ASCII); binary files (binary); data format files (data); various compressed files. The first attribute is [-]
Directory file
It is a directory, which can be entered with the # cd command. The first attribute is [d], for example [drwxrwxrwx]
Block device file
Block device file: It is an interface device that stores data for system access. In short, it is a hard disk. For example, the code of hard disk No. 1 is /dev/hda1 and other files. The first attribute is [b]
Character devices
Character device file: that is, the interface device of the serial port, such as keyboard, mouse and so on. The first attribute is [c]
Socket file
These files are commonly used in network data connections. A program can be started to monitor the client’s request, and the client can communicate data through the socket. The first attribute is [s], this file type is most often seen in the /var/run directory
Pipeline file
FIFO is also a special file type. Its main purpose is to solve errors caused by multiple programs accessing a file at the same time. FIFO is the abbreviation of first-in-first-out (first in first out). The first attribute is [p]
Linked files
Similar to the shortcuts under Windows. The first attribute is [l], for example [lrwxrwxrwx]
2. Three methods to view file types
①
ls-l/ls-ld or ll [ls-l — view file ls-ld — view path ll —-same as ls -l]
ll anaconda-ks.cfg //Look at the first character -rw-------. 1 root root 2460 Jun 1 23:37 anaconda-ks.cfg [root@localhost log]# ls -ld /etc drwxr-xr-x. 81 root root 4096 Jan 29 03:25 /etc
②
file command
[root@localhost data]# file a.txt a.txt: ASCII text
③
stat command
[root@localhost data]# stat a.txt //View detailed properties of the file (including file time properties) File: `a.txt' Size: 3 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 544365 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-01-28 20:56:01.965885036 + 0800 Modify: 2018-01-28 20:55:27.181876154 + 0800 Change: 2018-01-28 20:55:27.181876154 + 0800
3, file extensions in Linux
Windows distinguishes file types by their extensions. In Linux, the file extension has nothing to do with the file type. But in order to easily distinguish and be compatible with the user’s habit of using windows, we still use the extension to indicate the file type. Examples are as follows:
● Source code .tar, .tar.gz, .tgz, .zip, .tar.bz represent compressed files, and the creation commands are generally tar, gzip, zip, etc.
● .sh means a shell script file, a program developed through the shell language.
● .pl means a perl language file, a program developed by perl language.
● .py means a python language file, a program developed by python language.
● .html, .htm, .php, .jsp, .do indicate the language of the web page.
● .conf indicates the configuration file of the system service.
● .rpm indicates the rpm installation package file.
4, file attributes
[root@localhost /]# ls -lhi total 90K 12 dr-xr-xr-x. 2 root root 4.0K Jan 28 18:30 bin 2 dr-xr-xr-x. 5 root root 1.0K Aug 7 2016 boot 4 drwxr-xr-x. 18 root root 3.7K Jan 29 01:29 dev 652802 drwxr-xr-x. 81 root root 4.0K Jan 29 03:25 etc 130563 drwxr-xr-x. 3 root root 4.0K Jan 29 00:57 home 13 dr-xr-xr-x. 12 root root 4.0K Jan 28 18:30 lib 391685 dr-xr-xr-x. 9 root root 12K Jan 28 18:30 lib64 11 drwx------. 2 root root 16K Aug 7 2016 lost + found 130564 drwxr-xr-x. 2 root root 4.0K Sep 23 2011 media 391689 drwxr-xr-x. 2 root root 4.0K Sep 23 2011 mnt 130565 drwxr-xr-x. 3 root root 4.0K Aug 7 2016 opt 1 dr-xr-xr-x. 97 root root 0 Jan 29 2018 proc 391682 dr-xr-x---. 2 root root 4.0K Jan 28 21:08 root 130566 dr-xr-xr-x. 2 root root 12K Jan 28 18:30 sbin 1 drwxr-xr-x. 7 root root 0 Jan 29 2018 selinux 15 drwxr-xr-x. 2 root root 4.0K Sep 23 2011 srv 1 drwxr-xr-x. 13 root root 0 Jan 29 2018 sys 522242 drwxrwxrwt. 5 root root 4.0K Jan 29 05:15 tmp 522244 drwxr-xr-x. 14 root root 4.0K Jan 28 20:04 usr 261121 drwxr-xr-x. 20 root root 4.0K Aug 7 2016 var
544365 -rw-r–r–. 1 root root 3 Jan 28 20:55 a.txt
inode inode number: 544365
File type: The file type is ‘-‘, which means it is an ordinary file
File permissions: rw-r–r– indicates that the file is readable, writable, and executable, and the user group to which the file belongs can read and execute, and other users can read and execute
Number of hard links indicates that the file a.txt has no other hard links, because the number of links is 1, which is itself
The owner of the file indicates the user to which the file belongs, which means that the a.txt file is owned by the root user and is the first root user
The file belongs to the group indicates the user group to which the file belongs, here means that the a.txt file belongs to the root user group, which is the second root
File size The file size is 3 bytes
File modification time The time here is the time when the file was last updated (including file creation, content update, file name update, etc.) You can use the following commands to view the file modification, access, and creation time
[root@localhost data]# stat a.txt File: `a.txt' Size: 3 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 544365 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-01-28 20:56:01.965885036 + 0800 ----------Access time Modify: 2018-01-28 20:55:27.181876154 + 0800 ----------Modification time Change: 2018-01-28 20:55:27.181876154 + 0800 ----------Creation time
index node inode
Hard disk partition, format, create file system
The formatted disk is divided into two parts: The first part is Inode and the second part is block
block is used to store actual data, such as ordinary file data such as photos and videos
inode is used to store the attributes of these data (that is, the result of ls-l)
The attribute information contained in the inode includes file size, owner, user group, read and write permissions, asking price type, modification time, and the function of pointing to the file entity pointer (inode node—-block correspondence), but except the filename
Access a file [Find inode—->block by file name]
View inode size
[root@localhost ~]# dumpe2fs /dev/sda1|grep -i "Inode size" dumpe2fs 1.41.12 (17-May-2010) Inode size: 128
The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge Cloud native entry skill treeHomepageOverview 12871 people are learning systematically