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

相關文章
相關標籤/搜索