欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Linux系統(tǒng)中l(wèi)s命令的用法有哪些

Linux系統(tǒng)中l(wèi)s命令的用法有哪些?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

創(chuàng)新互聯專業(yè)成都網站設計、成都做網站,集網站策劃、網站設計、網站制作于一體,網站seo、網站優(yōu)化、網站營銷、軟文營銷等專業(yè)人才根據搜索規(guī)律編程設計,讓網站在運行后,在搜索中有好的表現,專業(yè)設計制作為您帶來效益的網站!讓網站建設為您創(chuàng)造效益。

ls命令是Linux系統(tǒng)中最被頻繁使用的命令之一,我相信ls命令一定是你進入一臺Linux系統(tǒng)的電腦打開命令提示符后第一個使用的命令。我們每天都在頻繁地使用ls命令,即使我們可能沒有意識也從來用不到所有可用的選項
1. 不帶任何選項列出文件

不帶選項的ls命令來光禿禿地列出文件和目錄,我們是不能看到像文件類型、大小、修改日期和時間、權限以及鏈接這樣具體的信息的。

   

代碼如下:

# ls
   0001.pcap        Desktop    Downloads         index.html   install.log.syslog  Pictures  Templates
   anaconda-ks.cfg  Documents  fbcmd_update.php  install.log  Music               Public    Videos

2 帶 –l 選項列出文件列表

你看,ls -l(-l是字母不是“1”)就能展示出是文件還是目錄,它的大小、修改日期和時間、文件或目錄的名字以及文件的屬主和它的權限。

   

代碼如下:

# ls -l
   total 176
   -rw-r--r--. 1 root root   683 Aug 19 09:59 0001.pcap
   -rw-------. 1 root root  1586 Jul 31 02:17 anaconda-ks.cfg
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Desktop
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Documents
   drwxr-xr-x. 4 root root  4096 Aug 16 02:55 Downloads
   -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
   -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
   -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
   -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Music
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Pictures
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Public
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Templates
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Videos

3. 瀏覽隱藏文件

列出所有文件包括以‘.’開頭的隱藏文件。

   

代碼如下:

# ls -a
   .                .bashrc  Documents         .gconfd          install.log         .nautilus     .pulse-cookie
   ..               .cache   Downloads         .gnome2          install.log.syslog  .netstat.swp  .recently-used.xbel
   0001.pcap        .config  .elinks           .gnome2_private  .kde                .opera        .spice-vdagent
   anaconda-ks.cfg  .cshrc   .esd_auth         .gtk-bookmarks   .libreoffice        Pictures      .tcshrc
   .bash_history    .dbus    .fbcmd            .gvfs            .local              .pki          Templates
   .bash_logout     Desktop  fbcmd_update.php  .ICEauthority    .mozilla            Public        Videos
   .bash_profile    .digrc   .gconf            index.html       Music               .pulse        .wireshark

4. 用 -lh 選項來以易讀方式列出文件

用-lh組合選項,以易讀方式來顯示大小。

   

代碼如下:

# ls -lh
   total 176K
   -rw-r--r--. 1 root root  683 Aug 19 09:59 0001.pcap
   -rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents
   drwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads
   -rw-r--r--. 1 root root  21K Aug 12 12:42 fbcmd_update.php
   -rw-r--r--. 1 root root  46K Jul 31 09:58 index.html
   -rw-r--r--. 1 root root  48K Jul 31 02:17 install.log
   -rw-r--r--. 1 root root  12K Jul 31 02:13 install.log.syslog
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Music
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Pictures
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Public
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Templates
   drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Videos

5. 以尾部以‘/’字符結尾的方式列出文件和目錄

使用 ls 命令的 -F 選項,會在每個目錄的末尾添加“/”字符顯示。

   

代碼如下:

# ls -F
   0001.pcap        Desktop/    Downloads/        index.html   install.log.syslog  Pictures/  Templates/
   anaconda-ks.cfg  Documents/  fbcmd_update.php  install.log  Music/              Public/    Videos/

6. 倒序列出文件

ls -r 選項能以倒序方式顯示文件和目錄。

   

代碼如下:

# ls -r
   Videos     Public    Music               install.log  fbcmd_update.php  Documents  anaconda-ks.cfg
   Templates  Pictures  install.log.syslog  index.html   Downloads         Desktop    0001.pcap

7. 遞歸列出子目錄

ls -R 選項能列出非常長的目錄樹,來看看示例輸出:

   

代碼如下:

# ls -R
   total 1384
   -rw-------. 1 root     root      33408 Aug  8 17:25 anaconda.log
   -rw-------. 1 root     root      30508 Aug  8 17:25 anaconda.program.log
   ./httpd:
   total 132
   -rw-r--r--  1 root root     0 Aug 19 03:14 access_log
   -rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-20120812
   ./lighttpd:
   total 68
   -rw-r--r--  1 lighttpd lighttpd  7858 Aug 21 15:26 access.log
   -rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21 access.log-20120819
   ./nginx:
   total 12
   -rw-r--r--. 1 root root    0 Aug 12 03:17 access.log
   -rw-r--r--. 1 root root  390 Aug 12 03:17 access.log-20120812.gz

8. 以修改時間倒序列出

帶-ltr組合選項能以文件或目錄的最新修改時間的次序來顯示它們。

   

代碼如下:

# ls -ltr
   total 176
   -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
   -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
   -rw-------. 1 root root  1586 Jul 31 02:17 anaconda-ks.cfg
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Desktop
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Videos
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Templates
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Public
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Pictures
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Music
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Documents
   -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
   -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
   drwxr-xr-x. 4 root root  4096 Aug 16 02:55 Downloads
   -rw-r--r--. 1 root root   683 Aug 19 09:59 0001.pcap

9. 按文件大小排序

帶-lS組合選項能按文件從大到小的次序顯示。

   

代碼如下:

# ls -lS
   total 176
   -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
   -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
   -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
   -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Desktop
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Documents
   drwxr-xr-x. 4 root root  4096 Aug 16 02:55 Downloads
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Music
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Pictures
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Public
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Templates
   drwxr-xr-x. 2 root root  4096 Jul 31 02:48 Videos
   -rw-------. 1 root root  1586 Jul 31 02:17 anaconda-ks.cfg
   -rw-r--r--. 1 root root   683 Aug 19 09:59 0001.pcap

10. 顯示文件或目錄的索引節(jié)點號

我們有時候可以看到一些數字打印在文件或目錄名之前,帶-i選項就能列出文件或目錄的索引節(jié)點號。

   

代碼如下:

# ls -i
   20112 0001.pcap        23610 Documents         23793 index.html          23611 Music     23597 Templates
   23564 anaconda-ks.cfg  23595 Downloads            22 install.log         23612 Pictures  23613 Videos
   23594 Desktop          23585 fbcmd_update.php     35 install.log.syslog  23601 Public

11. 顯示ls命令的版本

查看ls命令的版本。

   

代碼如下:

# ls --version
   ls (GNU coreutils) 8.4
   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.
   Written by Richard M. Stallman and David MacKenzie.

12. 顯示幫助頁面

列出ls命令的選項幫助頁面。

   

代碼如下:

# ls --help
   Usage: ls [OPTION]... [FILE]...

13. 列出目錄信息

用ls -l命令列出/tmp目錄下的文件,其中-ld參數可以只顯示/tmp目錄的信息。

   

代碼如下:

# ls -l /tmp
   total 408
   drwx------. 2 narad narad   4096 Aug  2 02:00 CRX_75DAF8CB7768
   -r--------. 1 root  root  384683 Aug  4 12:28 htop-1.0.1.tar.gz
   drwx------. 2 root  root    4096 Aug  4 11:20 keyring-6Mfjnk
   drwx------. 2 root  root    4096 Aug 16 01:33 keyring-pioZJr
   drwx------. 2 gdm   gdm     4096 Aug 21 11:26 orbit-gdm
   drwx------. 2 root  root    4096 Aug 19 08:41 pulse-gl6o4ZdxQVrX
   drwx------. 2 narad narad   4096 Aug  4 08:16 pulse-UDH76ExwUVoU
   drwx------. 2 gdm   gdm     4096 Aug 21 11:26 pulse-wJtcweUCtvhn
   -rw-------. 1 root  root     300 Aug 16 03:34 yum_save_tx-2012-08-16-03-34LJTAa1.yumtx</p> <p>    # ls -ld /tmp/
   drwxrwxrwt. 13 root root 4096 Aug 21 12:48 /tmp/

14. 顯示文件的UID和GID

用ls -n命令來顯示文件和目錄的UID(譯者注:userid,用戶ID)和GID(譯者注:groupid,組ID)。

   

代碼如下:

# ls -n
   total 36
   drwxr-xr-x. 2 500 500 4096 Aug  2 01:52 Downloads
   drwxr-xr-x. 2 500 500 4096 Aug  2 01:52 Music
   drwxr-xr-x. 2 500 500 4096 Aug  2 01:52 Pictures
   -rw-rw-r--. 1 500 500   12 Aug 21 13:06 tmp.txt
   drwxr-xr-x. 2 500 500 4096 Aug  2 01:52 Videos

15. ls命令和它的別名

我們給ls命令設置如下別名之后,當我們執(zhí)行l(wèi)s命令的時候它會默認執(zhí)行-l選項并且像上文提到的那樣顯示長列表。

   

代碼如下:

# alias ls="ls -l"

注意:我們可以通過不加任何參數的alias命令來看到目前系統(tǒng)中可用的所有alias設置,當然它們同時也可以unalias來取消。

   

代碼如下:

# alias
   alias cp='cp -i'
   alias l.='ls -d .* --color=auto'
   alias ll='ls -l --color=auto'
   alias ls='ls --color=auto'
   alias mv='mv -i'
   alias rm='rm -i'
   alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

刪除一項之前定義的alias設置,只需用unalias命令即可。

   

代碼如下:

# unalias ls

關于Linux系統(tǒng)中l(wèi)s命令的用法有哪些問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注創(chuàng)新互聯行業(yè)資訊頻道了解更多相關知識。

本文題目:Linux系統(tǒng)中l(wèi)s命令的用法有哪些
文章轉載:http://chinadenli.net/article14/ppiege.html

成都網站建設公司_創(chuàng)新互聯,為您提供網站制作、電子商務、域名注冊、關鍵詞優(yōu)化、自適應網站、網站建設

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

成都網頁設計公司