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. 前端调用后台接口下载word文档的两种方法

    1传统的ajax虽然能提交到后台,但是返回的数据被解析成json,html,text等字符串,无法响应浏览器下载.就算使用bob模拟下载,数据量大时也不方便 废话不多说:上代码(此处是Layui监听提 ...

  2. Servlet学习笔记(四)之请求转发与重定向(RequestDispatcher与sendRedirect)

    ServletContext可以实现请求转发(ServletContext请求转发相关内容见之前博客:http://blog.csdn.net/megustas_jjc/article/details ...

  3. ucosii操作系统内核源码学习第一篇

    根据书本理论介绍以及实际看内核源代码得出: 1. 操作系统默认定义了64个TCB块(为全局变量,编译时候以及分配了,创建一个任务就使用一个,删除一个任务就归还一个)(为什么最大只支持64个任务呢,我们 ...

  4. 多个mysql同时运行

    一.准备 mysql下载地址 https://dev.mysql.com/downloads/mysql/ 1.下载 2.解压缩 3.创建my.ini [Client] port = 3307 [my ...

  5. 操作系统的IO模型

    IO操作根据设备类型一般分为内存IO,网络IO,和磁盘IO.其中内存IO的速度大大快于后两者,计算机的性能瓶颈一般不在于内存IO. 尽管网络IO可通过购买独享带宽和高速网卡来提升速度,可以使用RAID ...

  6. 我的第一个npm包:wechat-menu-editor 基于Vue的微信自定义菜单编辑器

    wechat-menu-editor 微信自定义菜单编辑器 前言 在做微信公众号相关开发时,基本上会去开发的功能就是微信自定义菜单设置的功能,本着不重复造轮子的原则,于是基于Vue封装的一个微信自定义 ...

  7. [考试总结]noip模拟41

    发现长时间鸽博客会导致 rp--,所以今天来补一补 这个题目其实不是很毒瘤,然而是非常毒瘤... 题目不说请就是非常非常的烦人 首先 \(T1\) 就整整有两个歧义的地方,也就是说我们一共有 \(4\ ...

  8. C语言实现任务调度与定时器

    代码实现是在xl2tpd的源码中get到的,感觉很有意思的一段代码.基本功能就是实现定时器,时间到后从定时队列中取出,然后完成指定的任务. 1. schedule.c代码(自己添加了main函数,用来 ...

  9. SpringMVC基于注解开发

    一. 1.配置 适配器的作用就是规定怎么调控制器: 2.使用 controller代码 三.

  10. Vue设置全局cookies样式

    ''' 配置全局cookies样式 下载:cnpm install vue-cookies import cookies from 'vue-cookies' Vue.prototype.$cooki ...