What is the linux ll command

ll is not a basic command under linux, it is actually an alias of ls -l.

# 查看指定目录下的内容,默认查看当前目录下内容
ls [-ald] [目录名]
# 目录名不填写,默认为当前目录。
# -a:列出的全部的文件,包括隐藏文件
# -l:列举出全部的信息=》ll并不是linux下一个基本的命令,它实际上是ls -l的一个别名。
# -d:仅查看目录本身
# -h:以人们方便阅读的形式显示文件大小

insert image description here

drwxr-xr-x   19 root root 3.0K Feb 16 22:44 dev

Line 1: Total (total)

The number after Total refers to the sum of the space occupied by all files in the current directory.

Specific information is as follows:

Field 1: File attribute fielddrwxr-xr-x

The file attribute field consists of 10 letters in total;

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 the abbreviation of dirtectory (directory); Note: a directory or a special file, this special file stores information about other files or directories
  • The letter "l" indicates that the file is a linked file. The letter "l" is the abbreviation of link (link), which is similar to the shortcut under windows. Link files are divided into hard links or symbolic links.
  • The letter "b" indicates a block device file (block), which is generally placed in the /dev directory. The device file is an entry for ordinary files and programs to access hardware devices, and is a very special file. There is no file size, only a major and a minor number. A device that transmits data as a whole block at a time is called a block device, such as a hard disk, an optical disk, and so on. The minimum data transmission unit is a data block (usually the size of a data block is 512 bytes)
  • The letter "c" indicates that the file is a character device file (character), which is generally placed in the /dev directory. The device that transmits one byte at a time is called a character device, such as a keyboard, a character terminal, etc., and the smallest unit of data transmission for 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.

The 9 letters after the first character indicate the permission bit of the file or directory.

r means read (Read), w means write (Write), x means execute (eXecute),
among which the first three represent the permissions of the file owner, the middle three represent the permissions owned by the group to which the file belongs, and the last three represent the permissions owned by other users permission.

Field 2: Number of hard links to files19

If a file is not a directory, this field indicates the number of hard links the file has. So what is the difference between hard links and soft links? How to Create
The ln command is used to create a link to a file. According to the characteristics of the file stored in the Linux system, the linking method is divided into the following two types:

  • Soft link: similar to creating a shortcut to a file in the Windows system, that is, a special file is generated, which is used to point to another file. This link method is also applicable to directories.
  • Hard link: We know that the basic information of the file is stored in the inode, and the hard link refers to assigning multiple file names to the inode of a file. Through any file name, the inode of the file can be found, so as to read The data information of the file.
  • Simply put, even if you modify the hard link file, the original file will also be modified
[root@localhost ~]# ln [选项] 源文件 目标文件
-s:建立软链接文件。如果不加 "-s" 选项,则建立硬链接文件;
-f:强制。如果目标文件已经存在,则删除目标文件后再建立链接文件;

[root@hecs-37169 test]# touch testfile
[root@hecs-37169 test]# ln /www/test/testfile /www/test/testfileying
[root@hecs-37169 test]# ln -s /www/test/testfile /www/test/testfilruan
[root@hecs-37169 test]# ll
total 0
-rw-r--r-- 2 root root  0 May  4 09:59 testfile
-rw-r--r-- 2 root root  0 May  4 09:59 testfileying
lrwxrwxrwx 1 root root 18 May  4 10:00 testfilruan -> /www/test/testfile

It should be noted here that the source file of the soft link file must be written as an absolute path, not a relative path (there is no such requirement for hard links); otherwise, the soft link file will report an error. This is a very easy mistake for beginners to make.

Field 3: File (directory) ownerroot

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 modify file attributes. Of course, the root user has the right to change any file attributes. For a directory, only users who own the directory, or users with write permissions, have the right to create files in the directory

Field 4: The group of the file (directory) ownerroot

A user can join many groups, but one of them is the main group, which is the name displayed in the fourth field.

You can use -g to specify the main group where the user is in when useradd, and use -G to specify other groups

The format is as follows: Useradd –g group name user name

Field 5: The space occupied by the file (in bytes)3.0K

The fifth field indicates the file size, if it is a folder (directory), it indicates the size of the folder. Please note that it is the size of the folder itself, not the total size of the folder and the files under it.

Many people can't understand the meaning of a folder as a special file, so it is more difficult to understand the meaning of the folder size.

Field 6: file (directory) last access (modification) time

The time of file creation can be modified by the touch command

Field 7: File name

If it is a symbolic link, there will be a "->" arrow symbol, followed by a file name it points to

Guess you like

Origin blog.csdn.net/weixin_44797182/article/details/130480855