linux 中ls命令详解

2019-09-23 09:02:58丽君

参数

目录:指定要显示列表的目录,也可以是具体的文件。

实例

显示当前目录下非影藏文件与目录

[root@localhost ~]# lsanaconda-ks.cfg install.log install.log.syslog satools

显示当前目录下包括影藏文件在内的所有文件列表

[root@localhost ~]# ls -a
.  anaconda-ks.cfg .bash_logout  .bashrc install.log     .mysql_history <span style="color:#0000cd;">satools</span> .tcshrc  .vimrc
.. .bash_history  .bash_profile .cshrc  install.log.syslog .rnd      .<span class='wp_keywordlink'><a href="http://man.linuxde.net/ssh" rel="external nofollow" title="ssh命令" target="_blank">ssh</a></span>   .viminfo

输出长格式列表

[root@localhost ~]# ls -1anaconda-ks.cfginstall.loginstall.log.syslogsatools

显示文件的inode信息

索引节点(index inode简称为“inode”)是Linux中一个特殊的概念,具有相同的索引节点号的两个文本本质上是同一个文件(除文件名不同外)。

[root@localhost ~]# ls -i -l anaconda-ks.cfg install.log
2345481 -rw------- 1 root root  859 Jun 11 22:49 anaconda-ks.cfg
2345474 -rw-r--r-- 1 root root 13837 Jun 11 22:49 install.log

水平输出文件列表

[root@localhost /]# ls -m
bin, boot, data, dev, etc, home, lib, lost+found, media, misc, mnt, opt, proc, root, sbin, selinux, srv, sys, tmp, usr, var

修改最后一次编辑的文件

最近修改的文件显示在最上面。

[root@localhost /]# ls -ttmp root 
etc dev lib boot s
ys proc data home bin sbin 
usr var lost+found 
media mnt 
opt selinux srv misc

显示递归文件

[root@localhost ~]# 
ls -R.:anaconda-ks.cfg 
install.log 
install.log.syslog 
satools./satools:black.txt freemem.sh 
iptables.sh 
lnmp.sh mysql 
php502_check.sh 
ssh_safe.sh

打印文件的UID和GID

[root@localhost /]# ls -ntotal 254drwxr-xr-x  
2 0 0 4096 Jun 12 04:03 bindrwxr-xr-x  
4 0 0 1024 Jun 15 14:45 bootdrwxr-xr-x  
6 0 0 4096 Jun 12 10:26 datadrwxr-xr-x 
10 0 0 3520 Sep 26 15:38 devdrwxr-xr-x 
75 0 0 4096 Oct 16 04:02 etcdrwxr-xr-x 
 4 0 0 4096 Jun 12 10:26 homedrwxr-xr-x 
14 0 0 12288 Jun 16 04:02 libdrwx------ 
 2 0 0 16384 Jun 11 22:46 lost+founddrwxr-xr-x 
 2 0 0 4096 May 11 2011 mediadrwxr-xr-x  
2 0 0 4096 Nov 8 2010 miscdrwxr-xr-x 
 2 0 0 4096 May 11 2011 mntdrwxr-xr-x 
 2 0 0 4096 May 11 2011 optdr-xr-xr-x 
232 0 0   0 Jun 15 11:04 procdrwxr-x---  
4 0 0 4096 Oct 15 14:43 rootdrwxr-xr-x  
2 0 0 12288 Jun 12 04:03 sbindrwxr-xr-x  
2 0 0 4096 May 11 2011 selinuxdrwxr-xr-x  
2 0 0 4096 May 11 2011 srvdrwxr-xr-x 
11 0 0  
 0 Jun 15 11:04 sysdrwxrwxrwt  
3 0 0 98304 Oct 16 08:45 tmpdrwxr-xr-x 
13 0 0 4096 Jun 11 23:38 usrdrwxr-xr-x 
 19 0 0 4096 Jun 11 23:38 var

列出文件和文件夹的详细信息