Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commands for Linux system to view file types

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Linux system to view file type commands, the article is very detailed, has a certain reference value, interested friends must read!

1. Seven file types, ordinary file types

One of the most common file types in Linux, including plain text files (ASCII), binary files (binary), data format files (data), and various compressed files. The first attribute is the [-] directory file

This is the directory, which can be accessed with the # cd command. The first attribute is [d], for example, [drwxrwxrwx] block device file

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. The first attribute is the [b] character device

Character device file: the interface device of the serial port, such as keyboard, mouse, etc. The first attribute is the [c] socket file

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. The first attribute is [s], which is most commonly seen in the / var/run directory

Pipe file

FIFO is also a special file type, and 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 the [p] linked file

Similar to the shortcut below Windows. The first property is [l], for example, [lrwxrwxrwx]

2. 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 1234 ② file Command

[root@localhost data] # file a.txt a.txt: ASCII text 12 ③ 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 file Device: 803h/2051d Inode: 544365 Links: 1 Access: (0644 root Musashi -) Uid: (0 / root) Gid: ( 0 / root) Access: 2018-01-28 20 Change 56 Access 01.965885036 + 0800 Modify: 2018-01-28 20 Change 55 Change 27.1876154 + 0800 123456783, File extension windows in Linux distinguishes file types 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.

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 12345678910111213141516171819202122

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 file Device: 803h/2051d Inode: 544365 Links: 1 Access: (0644 Gid) Uid: (0 / root) Gid: (0 / root) Access: 2018-01-28 20 Blocks 56 IO Block 01.965885036 + 0800-- -access time Modify: 2018-01-28 20 inode 55buret 27.181876154 + 0800-Modification time Change: 2018-01-28 20 20 purge 55VR 27.1876154 + 0800-creation time 12345678 index node

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, owner, user group to which it belongs, read and write permissions, price type, modification time, and functions to point to file entity pointers (inode node-block correspondence), but does not include file name access to a file [find inode-- > block through file name]

View inode size

[root@localhost ~] # dumpe2fs / dev/sda1 | grep-I "Inode size" dumpe2fs 1.41.12 (17-May-2010) Inode size: 128Thank you for reading all the contents of this article "what are the commands for checking file types on the Linux system?" Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report