ls 命令实例

ls Linux 命令

在 Linux 是一个经常使用的命令。咱们这里说一些经常使用的命令参数,让你对linux操做更方便html

1.显示全部文件

# ls
file1 file2 file3 file4 file5 simplyadir linux

2.显示详细信息

# ls -l
total 24
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file1
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file2
-rw-r--r-- 1 root root 42 2014-01-29 09:37 file3
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file4
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file5
drwxr-xr-x 4 root root 4096 2014-01-29 11:49 simplyadir redis

3.按文件大小排列

# ls -lS
total 24K
drwxr-xr-x 4 root root 4.0K 2014-01-29 11:49 simplyadir
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file1
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file2
-rw-r--r-- 1 root root 42 2014-01-29 09:37 file3
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file4
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file5 .net

4.显示ls版本

# ls --version
ls (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. server

Written by Richard M. Stallman and David MacKenzie. htm

5.按最后修改时间排列

# ls -lt
-rw-r--r-- 1 root root 42 2014-01-29 09:37 file3
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file5
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file4
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file2
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file1 递归

6.打开上一次编辑过的文件

# vi ls -t | head -1 get

7.单行显示文件

# ls -1
file1
file2
file3
file4
file5 it

7.显示隐藏文件

# ls -al
total 28
drwxr-xr-x 2 root root 4096 2014-01-29 09:42 .
drwxr-xr-x 38 root root 4096 2014-01-29 09:19 ..
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file1
-rw-r--r-- 1 root root 42 2014-01-29 09:25 file2
-rw-r--r-- 1 root root 42 2014-01-29 09:37 file3
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file4
-rw-r--r-- 1 root root 42 2014-01-29 09:28 file5
-rw-r--r-- 1 root root 0 2014-01-29 11:43 .test> io

8.递归显示文件

root@server :~# ls -R /root/test/simplyadir
/root/test/simplyadir:
dir1 dir2

/root/test/simplyadir/dir1:
1.txt 2.txt

/root/test/simplyadir/dir2:
abc xyz

9.显示帮助页面

# ls --help

相关文章
相关标签/搜索