4.4.2 linux文件管理 : 文件综合操作 : 文件展示ls

本文深入解析Linux下文件管理的核心命令ls的详细用法,包括各种选项参数的意义及实际应用场景,如显示隐藏文件、文件类型识别、目录及文件权限查看等,是Linux系统管理者的必备指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

4.4.2 linux文件管理 : 文件综合操作 : 文件展示ls

常用命令:

$ ls -al
$ ls -al <regex>

常用只展示目录:

$ ls -al | grep "^d"
drwxrwxr-x.  6 sgx sgx   4096 Sep 27 17:08 .
drwxrwxr-x.  3 sgx sgx   4096 Sep 27 17:02 ..
drwxrwxr-x.  6 sgx sgx   4096 Sep 27 17:04 deps
drwxrwxr-x.  3 sgx sgx   4096 Sep 27 17:08 src
drwxrwxr-x. 10 sgx sgx   4096 Aug  4 06:44 tests
drwxrwxr-x.  8 sgx sgx   4096 Aug  4 06:44 utils
[sgx@localhost redis-4.0.11]$

文件类型:

“l”是链接文件,相当于windows的快捷方式;
“b”是块设备,硬盘就是一个例子;
“c”是字符设备文件,鼠标,键盘算是;
“d”是目录文件,相当于windows的文件夹。

命令详解:

-a, --all                                      do not ignore entries starting with .                    //不忽略.开头的文件
-A, --almost-all                               do not list implied . and ..                             //不列出.和..
    --author                                   with -l, print the author of each file                   //
-b, --escape                                   print C-style escapes for nongraphic characters          //
    --block-size=SIZE                          scale sizes by SIZE before printing them.  E.g.,         //扫描文件的SIZE,在打印之前
                                                 '--block-size=M' prints sizes in units of              //
                                                 1,048,576 bytes.  See SIZE format below.               //
-B, --ignore-backups                           do not list implied entries ending with ~                //
-c                                             with -lt: sort by, and show, ctime (time of last         //
                                                 modification of file status information)               //
                                                 with -l: show ctime and sort by name                   //
                                                 otherwise: sort by ctime, newest first                 //
-C                                             list entries by columns                                  //
    --color[=WHEN]                             colorize the output.  WHEN defaults to 'always'          //
                                                 or can be 'never' or 'auto'.  More info below          //
-d, --directory                                list directory entries instead of contents,              //
                                                 and do not dereference symbolic links                  //
-D, --dired                                    generate output designed for Emacs' dired mode           //
-f                                             do not sort, enable -aU, disable -ls --color             //
-F, --classify                                 append indicator (one of */=>@|) to entries              //
    --file-type                                likewise, except do not append '*'                       //
    --format=WORD                              across -x, commas -m, horizontal -x, long -l,            //
                                                 single-column -1, verbose -l, vertical -C              //
    --full-time                                like -l --time-style=full-iso                            //
-g                                             like -l, but do not list owner                           //
    --group-directories-first                                                                           //
                                                group directories before files.                         //
                                                  augment with a --sort option, but any                 //
                                                  use of --sort=none (-U) disables grouping             //
-G, --no-group                                  in a long listing, don't print group names              //
-h, --human-readable                            with -l, print sizes in human readable format           //
                                                  (e.g., 1K 234M 2G)                                    //
    --si                                        likewise, but use powers of 1000 not 1024               //
-H, --dereference-command-line                                                                          //
                                                follow symbolic links listed on the command line        //
    --dereference-command-line-symlink-to-dir                                                           //
                                                 follow each command line symbolic link                 //
                                                 that points to a directory                             //
    --hide=PATTERN                               do not list implied entries matching shell PATTERN     //
                                                   (overridden by -a or -A)                             //
    --indicator-style=WORD                        append indicator with style WORD to entry names:      //
                                                   none (default), slash (-p),                          //
                                                   file-type (--file-type), classify (-F)               //
-i, --inode                                      print the index number of each file                    //
-I, --ignore=PATTERN                             do not list implied entries matching shell PATTERN     //
-k, --kibibytes                                  use 1024-byte blocks                                   //
-l                                               use a long listing format                              //
-L, --dereference                                when showing file information for a symbolic           //
                                                   link, show information for the file the link         //
                                                   references rather than for the link itself           //
-m                                               fill width with a comma separated list of entries      //
-n, --numeric-uid-gid                            like -l, but list numeric user and group IDs           //
-N, --literal                                    print raw entry names (don't treat e.g. control        //
                                                   characters specially)                                //
-o                                               like -l, but do not list group information             //
-p, --indicator-style=slash                                                                             //
                                                 append / indicator to directories                      //
-q, --hide-control-chars                         print ? instead of non graphic characters              //
    --show-control-chars                         show non graphic characters as-is (default             //
                                                 unless program is 'ls' and output is a terminal)       //
-Q, --quote-name                                 enclose entry names in double quotes                   //
    --quoting-style=WORD                         use quoting style WORD for entry names:                //
                                                   literal, locale, shell, shell-always, c, escape      //
-r, --reverse                                    reverse order while sorting                            //
-R, --recursive                                  list subdirectories recursively                        //
-s, --size                                       print the allocated size of each file, in blocks       //打印美国文件分配的size
-S                                               sort by file size                                      //*根号文件的SIZE排序[默认是大的在前]
    --sort=WORD                                  sort by WORD instead of name: none -U,                 //*排序根据文件 --sort=none; --sort=extension; --sort=size; --sort=time
                                                 extension -X, size -S, time -t, version -v             //
    --time=WORD                                  with -l, show time as WORD instead of modification     //*排序根据时间 --time=atime;
                                                 time: atime -u, access -u, use -u, ctime -c,           //atime(access time)  ctime(change time)[权限修改时间]
                                                 or status -c; use specified time as sort key           //
                                                 if --sort=time                                         //
    --time-style=STYLE                           with -l, show times using style STYLE:                 //和-l搭配使用,展示时间使用style
                                                 full-iso, long-iso, iso, locale, +FORMAT.              //
                                                 FORMAT is interpreted like 'date'; if FORMAT is        //
                                                 FORMAT1<newline>FORMAT2, FORMAT1 applies to            //
                                                 non-recent files and FORMAT2 to recent files;          //
                                                 if STYLE is prefixed with 'posix-', STYLE              //
                                                 takes effect only outside the POSIX locale             //
-t                                               sort by modification time, newest first                //*排序根据修改的时间,新文件是第一个
-T, --tabsize=COLS                               assume tab stops at each COLS instead of 8             //
-u                                               with -lt: sort by, and show, access time               //*跟上-lt 展示访问时间,按访问时间排序
                                                   with -l: show access time and sort by name           //跟上-l   展示访问时间,按名称排序
                                                   otherwise: sort by access time                       //        根据访问时间排序
-U                                               do not sort; list entries in directory order           //不排序,根据文件系统的排序列出文件
-v                                               natural sort of (version) numbers within text          //
-w, --width=COLS                                 assume screen width instead of current value           //
-x                                               list entries by lines instead of by columns            //
-X                                               sort alphabetically by entry extension                 //*根据文件扩展名来排序【按类型排序】
-Z, --context                                    print any SELinux security context of each file        //
-1                                               list one file per line                                 //每行列出一个文件
    --help                                       display this help and exit                             //
    --version                                    output version information and exit                    //

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值