ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ls命令剖析

2021-08-24 12:32:07  阅读:303  来源: 互联网

标签:bin etc mnt 剖析 命令 ls file directory


ls命令剖析

资料翻译

ls - list contents of directory

ls - 列出目录的内容

SYNOPSIS 使用方式

ls [ -ltasdruifg ] name ...

DESCRIPTION 说明

参数的说明

For each directory argument, ls lists the contents of the directory; for each file argument, ls repeats its name and
any other information requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents.
There are several options:

对于每个目录参数,ls列出目录内容;对于每个文件参数,ls重复其名称和要求的任何其他信息。输出已排序默认按字母顺序排列。当没有给出任何论据时,当前目录已列出。当几个参数给定,参数首先被适当地排序,但是文件参数出现在目录及其内容之前。有几种选择:

-l list in long format, giving mode, number of links,owner, size in bytes, and time of last modification for each file. (See below.) If the file is a special file
the size field will instead contain the major and minor device numbers.

-l 长格式列表,给出模式,链接数,所有者、字节大小和每个文件上次修改的时间(如果文件是特殊文件“大小”字段将改为包含“主要”和“次要”字段设备编号。

-t sort by time modified (latest first) instead of by name,as is normal.

-t 按修改的时间(最新的第一个)排序,而不是按名称排序,一切正常

-a list all entries; usually those beginning with `.' are suppressed

-a 列出所有条目;通常以“.”开头的被发表

-s give size in blocks for each entry

-s 为每个条目提供块大小

-d if argument is a directory, list only its name, not its contents (mostly used with -l to get status on directory)

-d 如果参数是目录,则只列出它的名称,而不列出它的内容(主要与-l一起使用以获取目录的状态)

-r reverse the order of sort to get reverse alphabetic or oldest first as appropriate

-r 颠倒排序顺序,以获得颠倒的字母顺序或最早的优先顺序(视情况而定)

-u use time of last access instead of last modification for sorting (-t) or printing (-l)

-u 使用上次访问的时间而不是上次修改
排序(-t)或打印(-l)

-i print i-number in first column of the report for each file listed

-i 在报告的第一列中为列出的每个文件打印i号

-f force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.

-f 强制将每个参数解释为目录和
列出每个插槽中找到的名称。此选项将关闭
-l、 -t、-s和-r,并打开-a;顺序是
条目在目录中出现的顺序。

-g Give group ID instead of owner ID in long listing.

-g 在长列表中提供组ID而不是所有者ID。

-l 参数字符的解释

The mode printed under the -l option contains 11 characters which are interpreted as follows: the first character is

在-l选项下打印的模式包含11个字符,解释如下:第一个字符是:

  1. d if the entry is a directory;
  2. b if the entry is a block-type special file;
  3. c if the entry is a character-type special file;
  4. (-) if the entry is a plain file.
  1. d 如果条目是目录;
  2. b 如果条目是块类型特殊文件;
  3. c 如果条目是字符类型的特殊文件;
  4. (-) 如果条目是普通文件。

文件权限的解释

The next 9 characters are interpreted as three sets of three bits each. The first set refers to owner permissions; the next to permissions to others in the same user-group; and the last to all others. Within each set the three characters indicate permission respectively to read, to write, or to execute the file as a program. For a directory, `execute' permission is interpreted to mean permission to search the directory for a specified file. The permissions are indicated as follows:

接下来的9个字符被解释为三组三个字符
每一位。第一组是所有者权限;同一用户组中其他用户的权限旁边的;最后一个给所有其他人。在每个集合中,三个字符分别表示读取、写入或作为程序执行文件的权限。对于目录,“execute”权限被解释为在目录中搜索指定文件的权限。权限如下所示:

  1. r if the file is readable
  2. w if the file is writable
  3. x if the file is executable
  4. (-) if if the indicated permission is not granted
  1. r if 如果文件可读
  2. w 如果文件是可写的
  3. x 如果文件是可执行的
  4. (-) 如果未授予指定的权限

The group-execute permission character is given as s if the file has set-group-ID mode; likewise the user-execute permission character is given as s if the file has set-user-ID mode.

如果文件已设置组ID模式;同样地,如果文件设置了用户ID,则用户执行权限字符被赋予s
模式。

The last character of the mode is normally blank but is printed as ``t'' if the 1000 bit of the mode is on. See
chmod (I) for the current meaning of this mode.

模式的最后一个字符通常为空,但为空
如果模式的1000位为on,则打印为“t”。看到了吗
chmod(I)表示该模式的当前含义。

FILES 文件夹

/etc/passwd

获取ls-l的用户ID

实战演练

ls 命令

# ls
bin
dev
etc
hpunix
lib
mnt
rkunix
rpunix
tmp
unix
usr

ls -l 命令

# ls -l
total 247
drwxrwxr-x  2 bin      1104 May 14 00:47 bin
drwxrwxr-x  2 bin      1824 Oct 10 12:35 dev
drwxrwxr-x  2 bin       496 Oct 10 12:53 etc
-rwxrwxrwx  1 root    29074 Oct 10 12:28 hpunix
drwxrwxr-x  2 bin       464 May 13 23:35 lib
drwxrwxr-x  2 bin        32 May 13 20:01 mnt
-rwxrwxrwx  1 root    28836 Oct 10 12:22 rkunix
-rwxrwxrwx  1 root    29020 Oct 10 12:25 rpunix
drwxrwxrwx  2 bin       272 Oct 10 13:43 tmp
-rwxrwxrwx  1 root    30346 Oct 10 12:32 unix
drwxrwxr-x 15 bin       240 Oct 10 12:36 usr

ls -t 命令

# ls -t
total 247
tmp
etc
usr
dev
unix
hpunix
rpunix
rkunix
bin
lib
mnt

ls -a 命令

# ls -a
.
..
bin
dev
etc
hpunix
lib
mnt
rkunix
rpunix
tmp
unix
usr

ls -s 命令

# ls -s
total 247
   3 bin
   4 dev
   1 etc
  58 hpunix
   1 lib
   1 mnt
  58 rkunix
  58 rpunix
   1 tmp
  61 unix
   1 usr

ls -d 命令

# ls -d
.

ls -r 命令

# ls -r
usr
unix
tmp
rpunix
rkunix
mnt
lib
hpunix
etc
dev
bin

ls -u 命令

# ls -u
bin
dev
etc
hpunix
lib
mnt
rkunix
rpunix
tmp
unix
usr

ls -i 命令

# ls -i
  101 bin
  100 dev
   99 etc
  397 hpunix
   98 lib
   97 mnt
  198 rkunix
  396 rpunix
   96 tmp
  363 unix
   95 usr

ls -g 命令

# ls -g
bin
dev
etc
hpunix
lib
mnt
rkunix
rpunix
tmp
unix
usr

标签:bin,etc,mnt,剖析,命令,ls,file,directory
来源: https://www.cnblogs.com/Huang-zihan/p/15179779.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有