In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
I would like to share with you several file types in linux. I hope you will get something after reading this article. Let's discuss it together.
There are seven file types in linux: 1, ordinary file type; 2, directory file type; 3, block device file type; 4, character device type; 5, socket file type; 6, pipe file type; 7, link file type.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
On Linux systems, there are seven file types:
Normal file type
The most commonly used class of files, characterized by no structural information that contains file system information. Usually, the files that users come into contact with, such as graphics files, data files, document files and sound files, all belong to this kind of files. According to their internal structure, this type of files can be divided into plain text files (ASCII), binary files (binary), data format files (data), and various compressed files.
Plain text file (ASCII): this is the most common file type in Unix systems. It is called plain text file because of the data that the content can read directly, such as numbers, letters, and so on. Almost all of the setup files belong to this file type. For example, use the command "cat ~ / .bashrc" to see the contents of the file (cat is to read the contents of the file).
Binaries (binary): the system actually only knows and can execute binaries (binary file). Executable files in Linux (scripts, text-based batch files are not counted) are in this format. For example, the command cat is a binary file.
Data format files (data): some programs will read files in certain formats while running, and those files in a specific format can be called data files (data file). For example, when a user logs in, Linux records the login data in the / var/log/wtmp file, which is a data file that can be read through the last command. But when using cat, the garbled code will be read out. Because it belongs to a special format.
Directory file type
The file used to store the file name and its related information is the basic node of the file system organized by the kernel. A directory file can contain a lower-level file directory or a normal file. In Linux, a directory file is a file.
Can be accessed with the # cd command.
Block device file type
Block device file: an interface device that stores data for system access, simply a hard disk. For example, the code of hard disk No.1 is / dev/hda1 and other files.
Character device type
Character device file: the interface device of the serial port, such as keyboard, mouse, etc.
Socket file type
Such files are usually used for network data connections. You can start a program to listen to the client's requirements, and the client can communicate through sockets.
Pipe file type
Is a very special file, mainly used for different processes of information transmission. When two processes need to transfer data or information, a channel file can be used. One process writes the data or information that needs to be transmitted to one end of the pipeline, and the other process obtains the required data or information from the other end of the pipeline. Usually the pipeline is established in the adjustment cache.
Link file type
Is a special file, points to a real file link, similar to the shortcut under Windows, the different link file, can be divided into hard link file and symbolic link file.
Three ways 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 June 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 the detailed attributes of the file (including the file time attribute) File: `a.txt' Size: 3 Blocks: 8 IO Block: 4096 regular fileDevice: 803h/2051d Inode: 544365 Links: 1Access: (0644 root RWMART -) Uid: (0 / root) Gid: (0 / Root) Access: 2018-01-28 20 0800Modify 56 0800Change 01.965885036 + 0800Modify: 2018-01-28 20 V 55 V 27.1876 154 + 0800Change: 2018-01-28 20 20 V 27.1876 154 + File extension in 0800Linux
In windows, file types are distinguished by extension. There is no relationship between file extension and file type in linux. However, in order to easily distinguish and be compatible with users' habits of using windows, we still use extensions to represent file types. Examples are as follows:
● source code .tar, .tar.gz, .tgz, .zip, .tar.bz represent compressed files, and the creation command is generally tar,gzip,zip, and so on.
● .sh represents a shell script file, a program developed in the shell language.
● .pl represents a perl language file, a program developed by the perl language.
● .py represents a python language file, a program developed by the python language.
● .html, .htm, .php, .jsp, .do represent files in the web language.
● .conf represents the configuration file of the system service.
● .rpm represents the rpm installation package file.
File attributes [root@localhost /] # ls-lhitotal 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 dev652802 drwxr-xr-x. 81 root root 4.0K Jan 29 03:25 etc130563 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 lib391685 dr-xr-xr-x. 9 root root 12K Jan 28 18:30 lib64 11 drwx-. 2 root root 16K Aug 7 2016 lost+found130564 drwxr-xr-x. 2 root root 4.0K Sep 23 2011 media391689 drwxr-xr-x. 2 root root 4.0K Sep 23 2011 mnt130565 drwxr-xr-x. 3 root root 4.0K Aug 7 2016 opt 1 dr-xr-xr-x. 97 root root 0 Jan 29 2018 proc391682 dr-xr-x---. 2 root root 4.0K Jan 28 21:08 root130566 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 sys522242 drwxrwxrwt. 5 root root 4.0K Jan 29 05:15 tmp522244 drwxr-xr-x. 14 root root 4.0K Jan 28 20:04 usr261121 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'-', indicating that this is an ordinary file
File permissions: rw-r-r-- indicates that the file is readable, writable and executable, the user group to which the file belongs is readable and executable, and other users are readable and executable
The number of hard links means that there are no other hard links in the a.txt file, because the number of connections is 1, which is itself.
The file owner indicates the user to which the file belongs. This means that the a.txt file is owned by the root user and is the first root.
The file belonging group indicates the user group to which the file belongs. Here, the a.txt file belongs to the root user group and is the second root.
File size is 3 bytes
File modification 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 command to view the modification, access, and creation time of the file
[root@localhost data] # stat a.txt File: `a.txt' Size: 3 Blocks: 8 IO Block: 4096 regular fileDevice: 803h/2051d Inode: 544365 Links: 1Access: (0644) Uid: (0 / root) Gid: (0 / root) Access: 2018-01-28 20 56 IO Block 01.965885036 + 0800 -visit time Modify: 2018-01-28 20 55 purl 27.181876154 + 0800-Modification time Change: 2018-01-28 20 20 purge 55 purl 27.181876154 + 0800-creation time
Inode inode
Hard disk partition, formatting, creating 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 photos, videos and other ordinary file data.
Inode is used to store the attributes of this data (that is, the result of ls-l)
Inode contains attribute information such as file size, ownership, user group, read and write permissions, price type, modification time, and the function of pointing to the file entity (inode node-block correspondence), but does not include the file name.
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: 128After reading this article, I believe you have a certain understanding of "several file types in linux". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.