ls 命令
[root@localhost ~]# ls # 列出当前目录下所有的文件 [root@localhost ~]# ls /tmp # 列出指定目录下所有的文件 [root@localhost ~]# ls -a # -a 查看所有的文件,包括隐藏文件,以.开头的文件 [root@localhost ~]# ls -l # -l 用于以长格式列出文件,也可以写成ll ls -l filename = ll 查看一个文件的类型
-a 显示所有文件及目录 (ls内定将文件名或目录名称开头为“.”的视为隐藏档,不会列出)。
-l 除文件名称外,亦将文件型态、权限、拥有者、文件大小等资讯详细列出。
-t 将文件依建立时间之先后次序列出。
-R 若目录下有文件,则以下之文件亦皆依序列出。
ls -al # 表示以长格式列出当前目录的所有内容 包括隐藏文件内容 total 60 dr-xr-x---. 3 root root 4096 Nov 8 17:19 . dr-xr-xr-x. 20 root root 4096 Oct 19 06:02 .. -rw-------. 1 root root 828 Oct 19 06:05 anaconda-ks.cfg -rw-------. 1 root root 3303 Nov 8 20:41 .bash_history -rw-r--r--. 1 root root 18 May 27 16:48 .bash_logout -rw-r--r--. 1 root root 176 May 27 16:48 .bash_profile -rw-r--r--. 1 root root 176 May 27 16:48 .bashrc drwx------. 3 root root 4096 Oct 20 09:26 .config -rw-r--r--. 1 root root 100 May 27 16:48 .cshrc -rw-------. 1 root root 20 Oct 21 00:58 .lesshst -rw-------. 1 root root 12 Nov 8 17:19 .python_history -rw-r--r--. 1 root root 129 May 27 16:48 .tcshrc -rw-------. 1 root root 11797 Oct 21 01:14 .viminfo
[root@localhost ~]# ls -l 总用量 20 -rw-r--r--. 1 root root 1712 6月 2 23:23 1.txt -rw-------. 1 root root 899 6月 2 23:04 anaconda-ks.cfg -rw-r--r--. 1 root root 7995 6月 2 23:04 install.log -rw-r--r--. 1 root root 3384 6月 2 23:02 install.log.syslog 文件类型、文件权限 文件硬链接数 文件属主 文件属组 文件大小 文件创建/修改时间 文件名
ll -h 人性化显示
打印文件大小,以人类可读格式显示文件大小
[root@mysql opt]# ll total 31444 drwxr-xr-x. 35 7161 31415 4096 Oct 7 2018 mysql-5.6.36 -rw-r--r--. 1 root root 32192348 Mar 18 2017 mysql-5.6.36.tar.gz [root@mysql opt]# ll -h total 31M drwxr-xr-x. 35 7161 31415 4.0K Oct 7 2018 mysql-5.6.36 -rw-r--r--. 1 root root 31M Mar 18 2017 mysql-5.6.36.tar.gz
ls -i 查看inode节点
ll -i
[root@MongoDB ~]# ll -i total 4 8411620 -rw-------. 1 root root 1851 Mar 27 08:38 anaconda-ks.cfg 8411627 drwxr-xr-x 2 root root 6 May 18 07:54 dir1 12590293 drwxr-xr-x 2 root root 6 May 18 07:54 dir2 3287 drwxr-xr-x 2 root root 6 May 18 07:54 dir3 4218410 drwxr-xr-x 2 root root 6 May 18 07:54 dir4
. ls - d
功能:将目录象文件一样显示,而不是显示其下的文件;只显示当前文件夹
语法: # ls - d
# ls - ld(显示当前文件夹详细信息)
[root@localhost ~]# ls -d . [root@localhost ~]# ls -ld dr-xr-x---. 14 root root 4096 5月 10 21:49 .
-r:以文件名反序排列并输出目录内容列表;
-t:用文件和目录的更改时间排序;
列出目前工作目录下所有名称是a 开头的文件,愈新的排愈后面,可以使用如下命令:ls -tr a*
列出当前目录下的所有文件(包括隐藏文件)的绝对路径, 对目录不做递归:find $PWD -maxdepth 1|xargs ls -ld