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. springboot系列总结(二)---springboot的常用注解

    上一篇文章我们简单讲了一下@SpringBootApplication这个注解,申明让spring boot自动给程序进行必要的配置,他是一个组合注解,包含了@ComponentScan.@Confi ...

  2. 自定义Listener

    前言 为什么要自定义Listener? 通过自定义,可以在程序启动过程中监听特定事件,再回调处理逻辑. 自定义SpringApplicationRunListener 1.创建自定义SpringApp ...

  3. 你的 JVM 基础“大厦”稳健吗?

    [从 1 开始学 JVM 系列] JVM 对于每位 Java 语言编程者来说无疑是"重中之重",尽管我们每天都在与它打交道,却很少来审视它.了解它,慢慢地,它成为了我们" ...

  4. charles 抓包修改app页面数据

    1,首先给手机安装Charles证书,安装官方的来,在无线网配置项目,输入手动代理地址,后开启飞行模式刷新网络, 2,在浏览器输入chls.pro/ssl 下载并安装证书,此时电脑端charles 会 ...

  5. unity渲染篇:烘焙模型贴图

    今天要来做一件有趣的事情,那就是把一个模型数据烘焙到贴图上! 什么意思?就是下面酱紫,把这只小喵从第一张图拍扁,变成第二张图的样子(似乎有点残忍~) 可能你经常会从美术那边听到"烘焙光照贴图 ...

  6. PPP协议、PPPoE协议、L2TP协议的关系

    1. 简述 首先对这3中协议做一个简单的描述: 协议 协议类型 描述 PPP 点对点链路层协议 应用最广泛的点对点协议,可应用在多种网络,改善了SLIP协议的不足 PPPoE 点对点链路层协议 对PP ...

  7. LVS负载均衡集群--DR模式部署

    目录: 一.LVS-DR数据包流向分析 二.DR 模式的特点 三.LVS-DR中的ARP问题 四.DR模式 LVS负载均衡群集部署 一.LVS-DR数据包流向分析 1.为方便进行原理分析,将clien ...

  8. Mybatis公司开发常用!

    Mybatis核心 本文重点:注解开发,mybatis多表操作,动态SQL(WHERE,SET,IF,SQL-ID减少复用) 代码地址--https://gitee.com/zhangjzm/my-b ...

  9. 一文带你了解.Net读写锁

    本文主要讲解.Net基于ReaderWriterLockSlim讲解读写锁 基础概念 读写锁是一个具有特殊用途的线程锁,适用于频繁读取且读取需要一定时间的场景,共享资源的读取操作通常是可以同时执行的, ...

  10. 一文看懂String类中的常用方法

    1.int length(): 返回字符串的长度: return value.length 2.char charAt(int index): 返回某索引处的字符return value[index] ...