修改最后一次编辑的文件 最近修改的文件显示在最上面。
[root@localhost /]# ls -t
tmp root etc dev lib boot sys 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 -n
total 254
drwxr-xr-x 2 0 0 4096 Jun 12 04:03 bin
drwxr-xr-x 4 0 0 1024 Jun 15 14:45 boot
drwxr-xr-x 6 0 0 4096 Jun 12 10:26 data
drwxr-xr-x 10 0 0 3520 Sep 26 15:38 dev
drwxr-xr-x 75 0 0 4096 Oct 16 04:02 etc
drwxr-xr-x 4 0 0 4096 Jun 12 10:26 home
drwxr-xr-x 14 0 0 12288 Jun 16 04:02 lib
drwx------ 2 0 0 16384 Jun 11 22:46 lost+found
drwxr-xr-x 2 0 0 4096 May 11 2011 media
drwxr-xr-x 2 0 0 4096 Nov 8 2010 misc
drwxr-xr-x 2 0 0 4096 May 11 2011 mnt
drwxr-xr-x 2 0 0 4096 May 11 2011 opt
dr-xr-xr-x 232 0 0 0 Jun 15 11:04 proc
drwxr-x--- 4 0 0 4096 Oct 15 14:43 root
drwxr-xr-x 2 0 0 12288 Jun 12 04:03 sbin
drwxr-xr-x 2 0 0 4096 May 11 2011 selinux
drwxr-xr-x 2 0 0 4096 May 11 2011 srv
drwxr-xr-x 11 0 0 0 Jun 15 11:04 sys
drwxrwxrwt 3 0 0 98304 Oct 16 08:45 tmp
drwxr-xr-x 13 0 0 4096 Jun 11 23:38 usr
drwxr-xr-x 19 0 0 4096 Jun 11 23:38 var
列出文件和文件夹的详细信息
[root@localhost /]# ls -l
total 254
drwxr-xr-x 2 root root 4096 Jun 12 04:03 bin
drwxr-xr-x 4 root root 1024 Jun 15 14:45 boot
drwxr-xr-x 6 root root 4096 Jun 12 10:26 data
drwxr-xr-x 10 root root 3520 Sep 26 15:38 dev
drwxr-xr-x 75 root root 4096 Oct 16 04:02 etc
drwxr-xr-x 4 root root 4096 Jun 12 10:26 home
drwxr-xr-x 14 root root 12288 Jun 16 04:02 lib
drwx------ 2 root root 16384 Jun 11 22:46 lost+found
drwxr-xr-x 2 root root 4096 May 11 2011 media
drwxr-xr-x 2 root root 4096 Nov 8 2010 misc
drwxr-xr-x 2 root root 4096 May 11 2011 mnt
drwxr-xr-x 2 root root 4096 May 11 2011 opt
dr-xr-xr-x 232 root root 0 Jun 15 11:04 proc
drwxr-x--- 4 root root 4096 Oct 15 14:43 root
drwxr-xr-x 2 root root 12288 Jun 12 04:03 sbin
drwxr-xr-x 2 root root 4096 May 11 2011 selinux
drwxr-xr-x 2 root root 4096 May 11 2011 srv
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
drwxrwxrwt 3 root root 98304 Oct 16 08:48 tmp
drwxr-xr-x 13 root root 4096 Jun 11 23:38 usr
drwxr-xr-x 19 root root 4096 Jun 11 23:38 var
列出可读文件和文件夹详细信息
[root@localhost /]# ls -lh
total 254K
drwxr-xr-x 2 root root 4.0K Jun 12 04:03 bin
drwxr-xr-x 4 root root 1.0K Jun 15 14:45 boot
drwxr-xr-x 6 root root 4.0K Jun 12 10:26 data
drwxr-xr-x 10 root root 3.5K Sep 26 15:38 dev
drwxr-xr-x 75 root root 4.0K Oct 16 04:02 etc
drwxr-xr-x 4 root root 4.0K Jun 12 10:26 home
drwxr-xr-x 14 root root 12K Jun 16 04:02 lib
drwx------ 2 root root 16K Jun 11 22:46 lost+found
drwxr-xr-x 2 root root 4.0K May 11 2011 media
drwxr-xr-x 2 root root 4.0K Nov 8 2010 misc
drwxr-xr-x 2 root root 4.0K May 11 2011 mnt
drwxr-xr-x 2 root root 4.0K May 11 2011 opt
dr-xr-xr-x 235 root root 0 Jun 15 11:04 proc
drwxr-x--- 4 root root 4.0K Oct 15 14:43 root
drwxr-xr-x 2 root root 12K Jun 12 04:03 sbin
drwxr-xr-x 2 root root 4.0K May 11 2011 selinux
drwxr-xr-x 2 root root 4.0K May 11 2011 srv
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
drwxrwxrwt 3 root root 96K Oct 16 08:49 tmp
drwxr-xr-x 13 root root 4.0K Jun 11 23:38 usr
drwxr-xr-x 19 root root 4.0K Jun 11 23:38 var
显示文件夹信息
[root@localhost /]# ls -ld
/etc/ drwxr-xr-x 75 root root 4096 Oct 16 04:02 /etc/
按时间列出文件和文件夹详细信息
[root@localhost /]# ls -lt
total 254
drwxrwxrwt 3 root root 98304 Oct 16 08:53 tmp
drwxr-xr-x 75 root root 4096 Oct 16 04:02 etc
drwxr-x--- 4 root root 4096 Oct 15 14:43 root
drwxr-xr-x 10 root root 3520 Sep 26 15:38 dev
drwxr-xr-x 14 root root 12288 Jun 16 04:02 lib
drwxr-xr-x 4 root root 1024 Jun 15 14:45 boot
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
dr-xr-xr-x 232 root root 0 Jun 15 11:04 proc
drwxr-xr-x 6 root root 4096 Jun 12 10:26 data
drwxr-xr-x 4 root root 4096 Jun 12 10:26 home
drwxr-xr-x 2 root root 4096 Jun 12 04:03 bin
drwxr-xr-x 2 root root 12288 Jun 12 04:03 sbin
drwxr-xr-x 13 root root 4096 Jun 11 23:38 usr
drwxr-xr-x 19 root root 4096 Jun 11 23:38 var
drwx------ 2 root root 16384 Jun 11 22:46 lost+found
drwxr-xr-x 2 root root 4096 May 11 2011 media
drwxr-xr-x 2 root root 4096 May 11 2011 mnt
drwxr-xr-x 2 root root 4096 May 11 2011 opt
drwxr-xr-x 2 root root 4096 May 11 2011 selinux
drwxr-xr-x 2 root root 4096 May 11 2011 srv
drwxr-xr-x 2 root root 4096 Nov 8 2010 misc
按修改时间列出文件和文件夹详细信息
[root@localhost /]# ls -ltr
total 254
drwxr-xr-x 2 root root 4096 Nov 8 2010 misc
drwxr-xr-x 2 root root 4096 May 11 2011 srv
drwxr-xr-x 2 root root 4096 May 11 2011 selinux
drwxr-xr-x 2 root root 4096 May 11 2011 opt
drwxr-xr-x 2 root root 4096 May 11 2011 mnt
drwxr-xr-x 2 root root 4096 May 11 2011 media
drwx------ 2 root root 16384 Jun 11 22:46 lost+found
drwxr-xr-x 19 root root 4096 Jun 11 23:38 var
drwxr-xr-x 13 root root 4096 Jun 11 23:38 usr
drwxr-xr-x 2 root root 12288 Jun 12 04:03 sbin
drwxr-xr-x 2 root root 4096 Jun 12 04:03 bin
drwxr-xr-x 4 root root 4096 Jun 12 10:26 home
drwxr-xr-x 6 root root 4096 Jun 12 10:26 data
dr-xr-xr-x 232 root root 0 Jun 15 11:04 proc
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
drwxr-xr-x 4 root root 1024 Jun 15 14:45 boot
drwxr-xr-x 14 root root 12288 Jun 16 04:02 lib
drwxr-xr-x 10 root root 3520 Sep 26 15:38 dev
drwxr-x--- 4 root root 4096 Oct 15 14:43 root
drwxr-xr-x 75 root root 4096 Oct 16 04:02 etc
drwxrwxrwt 3 root root 98304 Oct 16 08:54 tmp
指令:要显示类型的指令。
实例
[root@localhost ~]# type ls
ls is aliased to `ls --color=tty'
[root@localhost ~]# type cd
cd is a shell builtin
[root@localhost ~]# type date
date is /bin/date
[root@localhost ~]# type mysql
mysql is /usr/bin/mysql
[root@localhost ~]# type nginx
-bash: type: nginx: not found
[root@localhost ~]# type if
if is a shell keyword
[root@localhost ~]# type which
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@localhost ~]# type -a cd
cd is a shell builtin
[root@localhost ~]# type -a grep
grep is /bin/grep
n:打印最近的n条历史命令。 实例
使用history命令显示最近使用的10条历史命令,输入如下命令:
[root@localhost ~]# history 10
92 ls
93 cd ..
94 ls
95 exit
96 ls -a
97 cd .ssh/
98 ls
99 cat known_hosts
100 exit
101 history 10