In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge of what linux's ll command means. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
In linux, the "ll" command refers to the "ls-l" command, which is an alias of the "ls-l" command, which is used to display a list of contents under the directory in a long format; the output information includes the file name, file type, permission mode, number of hard connections, owner, group, file size and the last modification time of the file from left to right.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Ll is not a basic command under linux, it's actually an alias for ls-l.
The meaning of "ls-l"
Displays a list of contents under the directory in a long format. The output information includes file name, file type, permission mode, number of hard connections, owner, group, file size and last modification time of the file from left to right.
As you can see, looking at a directory with the ls-l command results in a list of seven fields.
Line 1: total (total)
The number after Total refers to the sum of the space occupied by all the files in the current directory. You can view it using either ls-lh or ls-alh.
Field 1: file property field
-rw-r--r-- 1 root root 762 07-29 18:19 exit
The file properties field consists of a total of 10 letters; the first character represents the type of file.
The letter "-" indicates that the file is an ordinary file.
The letter "d" indicates that the file is a directory, and the letter "d" is an abbreviation for dirtectory (directory)
Note: a directory or a special file, which stores information about other files or directories
The letter "l" indicates that the file is a linked file. The letter "l" is an abbreviation for link (link), similar to a shortcut under windows
The letter "b" represents the block device file (block), which is generally placed in the / dev directory. The device file is the entry of ordinary files and programs to access hardware devices, and is a very special file. There is no file size, only a major number and a secondary number. A piece of data transferred at a time is called a block device, such as a hard disk, optical disc, and so on. The minimum unit of data transmission is a block (usually a block of 512 bytes)
The letter "c" indicates that the file is a character device file (character), which is generally placed in the / dev directory. A device that transmits one byte at a time is called a character device, such as a keyboard, character terminal, etc., and the smallest unit of data transmission is one byte.
The letter "p" indicates that the file is a command pipeline file. Files related to shell programming.
The letter "s" indicates that the file is a sock file. Files related to shell programming.
I would like to reiterate the important concept of file links:
The concept of linked files is similar to shortcuts in windows. Multiple linked files point to a "source file" at the same time. Linked files are divided into hard links or symbolic links.
In Linux's file system, files saved in disk partitions, regardless of type, are assigned a number called the index node number inode. Soft link, in fact, is to create a new file, this file is specifically used to point to other files (that is very close to the shortcut file under windows). The soft link produces a new file, but the function of this file is to point to a file. If you delete the soft link file, you will not need the connection and have nothing to do with the original existing entity original file, but if you delete the original file, the corresponding soft link will not be available (cat the soft link file will prompt "there is no such file or directory").
Hard links do not establish inode, it just adds another 1 to the original inode link count domain of the file, so hard links cannot cross the file system. On the contrary, the soft connection will re-establish an inode, of course, the structure of the inode is different from the others, it is just a string information indicating the source file. Once the source file is deleted, the soft connection becomes meaningless. When the hard link deletes the source file, the system call will check the value of inode link count. If it is greater than or equal to 1, then inode will not be recycled, so the contents of the file will not be deleted, which is equivalent to deleting an index.
A hard link is actually an alias for a file, and the linked file and the original file are actually the same file. You can check through ls-I, these two files have the same inode number, indicating that they are the same file, while the soft link establishes a point, that is, the contents of the linked file are pointers to the original file, and they are two files.
Soft link can cross the file system, hard link can not; soft link can be a non-existent file name (filename) link (of course, if you vi this soft link file, linux will automatically create a new file name filename file), hard link can not (the file must exist, inode must exist); soft link can be linked to the directory, hard link is not allowed. Both types of links can be created with the command ln. Ln creates hard links by default. Use the-s switch to create a soft link
The last nine letters of the first character represent the permission bits of the file or directory.
R table is read (Read), w means Write (write), x means eXecute (read)
The first three represent the permissions of the file owner, the middle three represent the permissions of the group to which the file belongs, and the last three represent the permissions of other users.
For example:
-rw-r--r-- 1 root root 762 07-29 18:19 exit
Indicates that root, the owner of the file, has read and write access to the file, while others (users in the same group and other users only have read permission)
In addition, there are some special representations for permission groups:
[root@localhost] # ll / usr/X11R6/bin/XFree86-rws--x--x 1 root root 1960262 2003-02-28 / usr/X11R6/bin/XFree86
S means that this is the network interface program "s" is the abbreviation of socket. The program opens a network interface during operation.
Other UNIX systems, such as FreeBSD, also have t permissions to represent a temporary (temporary) file
# ls-l / tmp can see this permission: drwxrwxrwt, its last digit is the letter "t"
Field 2: number of hard links to files
-rw-r--r-- 1 root root 762 07-29 18:19 exit
If a file is not a directory, this field indicates the number of hard links the file has
The value of the second field is 1, which means that the file has only one file name, exit. That is, there is only one hard link to the link.
If you use ln, make a hard link to the file and then view the file, the second field of the file will become 2
At this point exit and aexit are called hard links to each other. They point to the same file, and no matter which file is modified, the corresponding changes are made in the other, because in fact they point to the same file (that is, different file names of the same file).
Files that are hard linked to each other have the same file node.
As you can see, the two files have the same file node number: 162302
You can set symbolic links (soft links) in the following format
Ln-s source file target link file
Note: the file node number is different when soft link
If you know that a file has multiple file names (linked files), how to find out where its other file names are distributed?
You can first use ls-I to get its node number, and then use find to find it. For example, / etc/sysconfig/networking/ifcfg-eth0 has multiple file names, and you need to find the files that are hard-linked with it.
Get its node number is 452946
Then use find to find:
This gives you the location of different file names for the same file.
Field 3: file (directory) owner
Lrwxrwxrwx 1 root root 4 08-03 08:27 bexit-> exit
This field indicates which user this file belongs to. Linux-like systems are multi-user systems, and each file has its owner. Only the owner of the file has the right to change the attributes of the file. Of course, root users have the right to change any file attribute. For a directory, only the user who owns the directory or the user with write permission has the right to create files in the directory
If a user is deleted for some reason and the user's file still exists, viewing the file with ls-l will display a number that represents the ID number before the user exists.
First create a user test, add it to the wang user group, and switch with su, use ls-l to view the file owner, then delete the user test, use root to enter the test home directory, and view the file testing you just created.
As you can see, the third field becomes a number, which is the ID number of the original test user. Because the file system records the ID of the file owner, not the user name, for each file.
Field 4: the group of the file (directory) owner
Lrwxrwxrwx 1 root root 4 08-03 08:27 bexit-> exit
A user can join many groups, but one of them is the primary group, which is the name shown in field 4.
You can specify the primary group that the user belongs to with-g and other groups with-G during useradd
The format is as follows: Useradd-g group name and user name
Field 5: the space occupied by the file (in bytes)
Lrwxrwxrwx 1 root root 4 08-03 08:27 bexit-> exit
Field 5 represents the file size, or if it is a folder (directory), the size of the folder. Note that it is the size of the folder itself, not the total size of the folder and the files below it.
Many people do not understand the meaning of a folder as a special file, so it is more difficult to understand the meaning of folder size.
Field 6: the last access (modification) time of the file (directory)
Lrwxrwxrwx 1 root root 4 08-03 08:27 bexit-> exit
The time when the file was created can be modified with the touch command. Such as:
[root@localhost ~] # touch exit
You can change the creation time of the exit to the current time. In addition, a file has attributes such as the last access time, the last modification time and so on.
These properties can be displayed with other parameters of ls.
Field 7: file name
Lrwxrwxrwx 1 root root 4 08-03 08:27 bexit-> exit
If it is a symbolic link, there will be a "- >" arrow symbol followed by the file name it points to
The above is all the content of this article "what does the ll command of linux mean?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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: 226
*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.