linux ls

        Linux可以支持长达256个字符的文件名称,且文件名是区分大小写的,"abc”与"ABC"所代表的是不同文件。

1.1 文件类型

文件类型:

  • 普通文件(-):存放数据、程序等信息的文件,一般为文本文件和二进制文件。
  • 目录文件(d):文件系统中一个目录所包含的目录文件,包括文件名和子目录名。
  • 链接文件I):可以在不同的文件系统之间建立链接关系来实现对文件的访问。
  • 设备文件(c):把IO设备映射为一个设备文件。
  • 管道文件(p):主要用于在进程间传递数据。
1.2 文件权限

        所谓的文件权限,是指对文件访问权限,包括对文件的读、写、删除、执行操作。Linux是一个多用户操作系统,它运行多个用户同时登陆和工作,因此Linux将一个文件或者目录与一个用户和组联系起来。

 每项信息说明:

文件设定不同用户的读、写和执行权限,仅涉及到9位字符。

Linux系统中,文件有三种访问权限:

  • 读(r)-允许读取文件
  • 写(w)-允许写、修改和删除某个文件
  • 执行(x)-允许执行某个文件

2、ls命令选项使用

        Linux ls(英文全拼: list files)命令用于显示指定工作目录下之内容(列出目前工作目录所含之文件及子目录)。

语法:

ls [参数]
 
 
命令选项说明
-l以列表方式显示
-h以大小单位显示,默认是字节
-a显示隐藏文件和隐藏目录

参数:


 
 
  1. [root@192 dgw] # ls --help
  2. 用法: ls [选项]... [文件]...
  3. List information about the FILEs (the current directory by default).
  4. Sort entries alphabetically if none of -cftuvSUX nor -- sort is specified.
  5. Mandatory arguments to long options are mandatory for short options too.
  6. -a, --all 不隐藏任何以. 开始的项目
  7. -A, --almost-all 列出除. 及.. 以外的任何项目
  8. --author 与-l 同时使用时列出每个文件的作者
  9. -b, --escape 以八进制溢出序列表示不可打印的字符
  10. --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
  11. '--block-size=M' prints sizes in units of
  12. 1,048,576 bytes; see SIZE format below
  13. -B, --ignore-backups do not list implied entries ending with ~
  14. -c with -lt: sort by, and show, ctime (time of last
  15. modification of file status information);
  16. with -l: show ctime and sort by name;
  17. otherwise: sort by ctime, newest first
  18. -C list entries by columns
  19. --color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
  20. or 'always' (the default); more info below
  21. -d, --directory list directories themselves, not their contents
  22. -D, --dired generate output designed for Emacs ' dired mode
  23. -f do not sort, enable -aU, disable -ls --color
  24. -F, --classify append indicator (one of */=>@|) to entries
  25. --file-type likewise, except do not append '* '
  26. --format=WORD across -x, commas -m, horizontal -x, long -l,
  27. single-column -1, verbose -l, vertical -C
  28. --full-time like -l --time-style=full-iso
  29. -g 类似-l,但不列出所有者
  30. --group-directories-first
  31. group directories before files;
  32. can be augmented with a --sort option, but any
  33. use of --sort=none (-U) disables grouping
  34. -G, --no-group 以一个长列表的形式,不输出组名
  35. -h, --human-readable 与-l 一起,以易于阅读的格式输出文件大小
  36. (例如 1K 234M 2G)
  37. --si 同上面类似,但是使用1000 为基底而非1024
  38. -H, --dereference-command-line
  39. follow symbolic links listed on the command line
  40. --dereference-command-line-symlink-to-dir
  41. follow each command line symbolic link
  42. that points to a directory
  43. --hide=PATTERN do not list implied entries matching shell PATTERN
  44. (overridden by -a or -A)
  45. --indicator-style=WORD append indicator with style WORD to entry names:
  46. none (default), slash (-p),
  47. file-type (--file-type), classify (-F)
  48. -i, --inode print the index number of each file
  49. -I, --ignore=PATTERN do not list implied entries matching shell PATTERN
  50. -k, --kibibytes default to 1024-byte blocks for disk usage
  51. -l 使用较长格式列出信息
  52. -L, --dereference 当显示符号链接的文件信息时,显示符号链接所指示
  53. 的对象而并非符号链接本身的信息
  54. -m 所有项目以逗号分隔,并填满整行行宽
  55. -n, --numeric-uid-gid 类似 -l,但列出UID 及GID 号
  56. -N, --literal 输出未经处理的项目名称 (如不特别处理控制字符)
  57. -o 类似 -l,但不列出有关组的信息
  58. -p, --indicator-style=slash 对目录加上表示符号"/"
  59. -q, --hide-control-chars print ? instead of nongraphic characters
  60. --show-control-chars show nongraphic characters as-is (the default,
  61. unless program is ' ls ' and output is a terminal)
  62. -Q, --quote-name enclose entry names in double quotes
  63. --quoting-style=WORD use quoting style WORD for entry names:
  64. literal, locale, shell, shell-always, c, escape
  65. -r, --reverse 逆序排列
  66. -R, --recursive 递归显示子目录
  67. -s, --size 以块数形式显示每个文件分配的尺寸
  68. -S sort by file size
  69. --sort=WORD sort by WORD instead of name: none (-U), size (-S),
  70. time (-t), version (-v), extension (-X)
  71. --time=WORD with -l, show time as WORD instead of default
  72. modification time: atime or access or use (-u)
  73. ctime or status (-c); also use specified time
  74. as sort key if --sort=time
  75. --time-style=STYLE with -l, show times using style STYLE:
  76. full-iso, long-iso, iso, locale, or +FORMAT;
  77. FORMAT is interpreted like in ' date '; if FORMAT
  78. is FORMAT1<newline>FORMAT2, then FORMAT1 applies
  79. to non-recent files and FORMAT2 to recent files;
  80. if STYLE is prefixed with 'posix- ', STYLE
  81. takes effect only outside the POSIX locale
  82. -t sort by modification time, newest first
  83. -T, --tabsize=COLS assume tab stops at each COLS instead of 8
  84. -u with -lt: sort by, and show, access time;
  85. with -l: show access time and sort by name;
  86. otherwise: sort by access time
  87. -U do not sort; list entries in directory order
  88. -v natural sort of (version) numbers within text
  89. -w, --width=COLS assume screen width instead of current value
  90. -x list entries by lines instead of by columns
  91. -X sort alphabetically by entry extension
  92. -1 list one file per line
  93. SELinux options:
  94. --lcontext Display security context. Enable -l. Lines
  95. will probably be too wide for most displays.
  96. -Z, --context Display security context so it fits on most
  97. displays. Displays only mode, user, group,
  98. security context and file name.
  99. --scontext Display only security context and file name.
  100. --help 显示此帮助信息并退出
  101. --version 显示版本信息并退出
  102. SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units
  103. are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
  104. 使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
  105. 使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
  106. LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。

3、操作效果展示图

3.1 ls -a

显示所有文件及目录(.开头的隐藏文件也会列出)。

3.2 ls -l 

除文件名称外,亦将文件型态、权限、拥有者、文件大小等资讯详细列出。

3.3 ls -h 

【ls -l -a -h  可以这样使用,也可以这样使用:ls -lah  没有顺序要求】

3.4 ls -R

若目录下有文件,则以下之文件亦皆依序列出。

3.5 ls -A

-A同-a,但不列出"."(目前目录)及".."(父目录)。

3.6 ls -r

将文件以相反次序显示(原定依英文字母次序)。

3.7 ls -t

将文件依建立时间之先后次序列出,默认。

3.8 ls -F

在列出的文件名称后加一符号;例如可执行档则加“*",目录则加""/"。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值