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

ls命令剖析的更多相关文章

  1. 每天一个linux命令(1):ls命令

    1. 命令格式: ls [选项] [目录名] 2. 命令功能: 列出目标目录中所有的子目录和文件. 4. 常用范例: 例一:列出/home/peidachang文件夹下的所有文件和目录的详细资料 命令 ...

  2. Linux 常用命令 :ls命令

    ls命令是linux下最常用的命令.ls命令就是list的缩写缺省下ls用来打印出当前目录的清单如果ls指定其他目录那么就会显示指定目录里的文件及文件夹清单. 通过ls 命令不仅可以查看linu ...

  3. linux在home目录下使用ls命令卡死

    linux在home目录下使用ls命令卡死,原因可能是mount的某个服务器挂掉或出啥问题了,这个时候umount掉就正常了,如果umount提示device is busy,这时可以使用强制卸载   ...

  4. linux命令(1):ls命令

    ls命令是linux下最常用的命令. ls命令就是list的缩写,缺省下ls用来打印出当前目录的清单,如果ls指定其他目录,那么就会显示指定目录里的文件及文件夹清单. 通过ls 命令不仅可以查看lin ...

  5. 《The Linux Command Line》 读书笔记03 ls命令与长格式输出解释 文件权限

    ls命令与长格式输出解释 文件权限 ls命令 ls 命令用于列出目录内容,不带参数时列出当前工作目录的内容,也可以指定目标目录(可以指定多个),列出目标目录下的内容. ls命令的参数 ls -l 长格 ...

  6. Linux之ls命令

    s 命令可以说是linux下最常用的命令之一. -a 列出目录下的所有文件,包括以 . 开头的隐含文件.-b 把文件名中不可输出的字符用反斜杠加字符编号(就象在C语言里一样)的形式列出.-c 输出文件 ...

  7. 从零开始学习Linux(ls命令)

    学习Linux已经两年了,可是仍然是小白一个.用过很多命令,可是很多都没记住,基础不扎实,很大程度上是不记笔记,得过且过. 从今天起,开始整理Linux笔记. Linux每个命令都有--help这个选 ...

  8. Linux命令详解之–ls命令

    今天开始为大家介绍下Linux中常用的命令,首先给大家介绍下Linux中使用频率最高的命令--ls命令. 更多Linux命令详情请看:Linux命令速查手册 linux ls命令用于显示指定工作目录下 ...

  9. ls命令

    ls(list) 命令可以说是Linux下最常用的命令之一 #ls -l;列出文件的详细信息 #ll 以上两个命令一样,ll是ls -l的简写 #ls -al;列出目录下的所有文件,包括以 . 开头的 ...

随机推荐

  1. 巧用模糊实现视觉的 3D 效果

    本文较短,将介绍巧用模糊实现视觉 3D 效果的技巧. 我们都知道,在正常的视觉效果中,离我们越近的通常我们会看的越清晰,而离我们较远则相对没那么清晰~ 我们可以利用清晰与模糊两种状态来构建视差效果.像 ...

  2. RGB 与 HSB/HSV 的关系

    能理解 RGB 模式中确定数值的各种颜色,但怎么理解「明度」.「饱和度」.「色相」等概念? 从第一张图可以简单得出以下结论: 明度--这个最简单,rgb中,三色光的值,其加起来的和越大,明度就越大. ...

  3. RabbitMQ-进阶

    目录 过期时间TTL 设置队列TTL 消息确认机制的配置 死信队列 内存磁盘的监控 RabbitMQ的内存控制 命令的方式 配置文件方式 rabbitmq.conf RabbitMQ的内存换页 Rab ...

  4. JQ动画

    /* //基本 show([s,[e],[fn]]) 显示元素 hide([s,[e],[fn]]) 隐藏元素 //滑动 slideDown([s],[e],[fn]) 向下滑动 slideUp([s ...

  5. Pytest系列(22)- allure的特性,@allure.link()、@allure.issue()、@allure.testcase()的详细使用

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 上一篇文章介绍了两种allu ...

  6. 即时通讯网-TCPIP族关系图

  7. VUE003. 解决data中使用vue-i18n不更新视图问题(computed属性)

    案例 在国际化开发中,有一部分需要国际化的文字是由数据驱动的储存在data中,然而VUE的data存在很多无法实时更新视图的问题,比如v-for循环的标签,当数据层次过深,通过源数据数组的索引改变它的 ...

  8. go语言游戏服务端开发(二)——网络通信

    一.网络层 网络游戏客户端除了全局登录使用http请求外,一般通过socket长连接与服务端保持连接.go语言的net包提供网络socket长连接相关操作. 对于服务端,一般经历 Listen.Acc ...

  9. vue-router路由钩子

    路由跳转前后,需要做某些操作,这时就可以使用路由钩子来监听路由的变化. 接收三个参数: to: Route: 即将要进入的目标路由对象 from: Route: 当前导航正要离开的路由 next: F ...

  10. Java面向对象系列(1)- 什么是面向对象

    面向过程 & 面向对象 面向过程思想 步骤清晰清楚,第一步做什么,第二步做什么-- 面对过程适合处理一些较为简单的问题 面向对象思想 物以类聚,分类的思维模式,思考问题首先会解决问题需要哪些分 ...