1.每日一個Linux命令----ls

命令:lsurl

描述:ls 命令用於查看文件,相似DOS下的dir命令。code

用法:ls [選項] 文件或目錄名排序

經常使用選項遞歸

-a:列出目錄下的全部文件包括以"."開頭的隱藏文件;it

-l:列出文件的詳細信息;io

-d:只顯示目錄自己擴展

-i:列出文件的i節點的信息;plugin

-h:人性化的顯示文件的大小;map

-R:遞歸的顯示目錄及子目錄下的文件;im

-t[-u-S]:以文件被修改的時間[文件上次被訪問的時間/文件由大到小]排序;

-r :對目錄反向排序;

-s :在每一個文件名後輸出該文件的大小;

-X:以文件的擴展名(最後一個 . 後的字符)排序。

示例

1.列出/boot目錄下的文件,並按文件大小從大到小排列。

[root@share21 ~]# ls -lhS /boot
total 87M
-rw-r--r--. 1 root root  38M Jan 15 10:31 initramfs-0-rescue-73577d33b1304b8aa806c3118f3f241c.img
-rw-------. 1 root root  19M Jan 19 11:24 initramfs-3.10.0-229.el7.x86_64kdump.img
-rw-r--r--. 1 root root  18M Jan 15 10:41 initramfs-3.10.0-229.el7.x86_64.img
-rwxr-xr-x. 1 root root 4.8M Jan 15 10:31 vmlinuz-0-rescue-73577d33b1304b8aa806c3118f3f241c
-rwxr-xr-x. 1 root root 4.8M Mar  6  2015 vmlinuz-3.10.0-229.el7.x86_64
-rw-------. 1 root root 2.8M Mar  6  2015 System.map-3.10.0-229.el7.x86_64
-rw-r--r--. 1 root root 582K Jan 15 10:29 initrd-plymouth.img
-rw-r--r--. 1 root root 235K Mar  6  2015 symvers-3.10.0-229.el7.x86_64.gz
-rw-r--r--. 1 root root 121K Mar  6  2015 config-3.10.0-229.el7.x86_64
drwx------. 2 root root  12K Jan 15 10:27 lost+found
drwxr-xr-x. 2 root root 1.0K Jan 15 10:29 grub
drwxr-xr-x. 6 root root 1.0K Jan 15 10:32 grub2

2.列出/etc下「y"開頭的全部文件及目錄的詳細信息。

[root@share21 etc]# ls -l /etc/y*
-rw-r--r--. 1 root root  970 Mar 10  2015 /etc/yum.conf

/etc/yum:
total 12
drwxr-xr-x. 2 root root    6 Mar 10  2015 fssnap.d
drwxr-xr-x. 2 root root   52 Jan 15 10:31 pluginconf.d
drwxr-xr-x. 2 root root   25 Mar 10  2015 protected.d
drwxr-xr-x. 2 root root   18 Mar 10  2015 vars
-rw-r--r--. 1 root root  444 Mar 10  2015 version-groups.conf
-rw-r--r--. 1 root root 2537 Mar 10  2015 yum-cron.conf
-rw-r--r--. 1 root root 2499 Mar 10  2015 yum-cron-hourly.conf

/etc/yum.repos.d:
total 4
drwxr-xr-x. 2 root root   76 Jan 26 10:09 bak
-rw-r--r--. 1 root root 1570 Jan 26 10:11 Centos7.base.repo
相關文章
相關標籤/搜索