標籤:linux
#ls命令:通過ls 命令不僅可以查看linux檔案夾包含的檔案,而且可以查看檔案許可權(包括目錄、檔案夾、檔案許可權),查看目錄資訊等等
[[email protected]_168_102_centos /]# lsbin data etc lib lost+found mnt proc sbin srv tmp varboot dev home lib64 media opt root selinux sys usr
ls –a:顯示所有檔案,包含.開頭的隱藏檔案
[[email protected]_168_102_centos /]# ls -a. .readahead_collect dev lib64 opt selinux usr.. bin etc lost+found proc srv var.autofsck boot home media root sys.autorelabel data lib mnt sbin tmp
ls –l:列出檔案的詳細資料
[[email protected]_168_102_centos tmp]# ls -ltotal 24drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 asrwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sock-rw------- 1 root root 105 Aug 2 11:36 ap_1002.pid-rw------- 1 root root 0 Aug 2 09:48 ap_1004.pid-rw------- 1 root root 103 Aug 2 11:36 ap_1005.pid-rw------- 1 root root 0 Aug 2 10:51 ap_1007.pid-rw------- 1 root root 0 Aug 2 10:09 ap_1008.pid-rw------- 1 root root 0 Aug 4 13:58 ap_1014.piddrwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshid //檔案類型 rwxr-xr-x //檔案許可權 3 //永久連結數 wanghan //屬主 root //屬組 4096 Aug 4 20:41 //最近一次修改時間 wanghan //檔案名稱
ls –d:顯示目錄自身的資訊,結合-l使用直接查看目錄自身詳細資料
[[email protected]_168_102_centos etc]# ls -d.[[email protected]_168_102_centos etc]# ls -lddrwxr-xr-x 75 root root 4096 Aug 9 03:28 .[[email protected]_168_102_centos etc]#
ls -r:逆序顯示
drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 asrwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sock-rw------- 1 root root 105 Aug 2 11:36 ap_1002.pid-rw------- 1 root root 0 Aug 2 09:48 ap_1004.pid-rw------- 1 root root 103 Aug 2 11:36 ap_1005.pid-rw------- 1 root root 0 Aug 2 10:51 ap_1007.pid-rw------- 1 root root 0 Aug 2 10:09 ap_1008.pid-rw------- 1 root root 0 Aug 4 13:58 ap_1014.piddrwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshidrwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan[[email protected]_168_102_centos tmp]# ls -rltotal 24drwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghandrwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi-rw------- 1 root root 0 Aug 4 13:58 ap_1014.pid-rw------- 1 root root 0 Aug 2 10:09 ap_1008.pid-rw------- 1 root root 0 Aug 2 10:51 ap_1007.pid-rw------- 1 root root 103 Aug 2 11:36 ap_1005.pid-rw------- 1 root root 0 Aug 2 09:48 ap_1004.pid-rw------- 1 root root 105 Aug 2 11:36 ap_1002.pidsrwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sockdrwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 adrwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053[[email protected]_168_102_centos tmp]#
ls -R:同時顯示其下子目錄檔案
[[email protected]_168_102_centos tmp]# cd a[[email protected]_168_102_centos a]# lsb[[email protected]_168_102_centos a]# ls -R.:b./b:c./b/c:d./b/c/d:e./b/c/d/e:f./b/c/d/e/f:abcd./b/c/d/e/f/abcd:[[email protected]_168_102_centos a]#
ls -h:以容易理解的方式顯示檔案大小
[[email protected]_168_102_centos tmp]# ls -ltotal 24drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 adrwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshidrwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan[[email protected]_168_102_centos tmp]# ls -lhtotal 24Kdrwxr-xr-x 2 wanghan root 4.0K Aug 4 21:21 2014-08-04-212053drwxr-xr-x 3 wanghan root 4.0K Aug 4 20:45 adrwxr-xr-x 2 wanghan root 4.0K Aug 4 20:44 ceshidrwxr-xr-x 3 wanghan root 4.0K Aug 4 20:41 wanghan
ls -i:顯示出檔案inode號
[[email protected]_168_102_centos tmp]# ls -litotal 24458762 drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053458767 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a458758 srwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sock458755 -rw------- 1 root root 105 Aug 2 11:36 ap_1002.pid458756 -rw------- 1 root root 0 Aug 2 09:48 ap_1004.pid458759 -rw------- 1 root root 103 Aug 2 11:36 ap_1005.pid458760 -rw------- 1 root root 0 Aug 2 10:51 ap_1007.pid458757 -rw------- 1 root root 0 Aug 2 10:09 ap_1008.pid458761 -rw------- 1 root root 0 Aug 4 13:58 ap_1014.pid458766 drwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi458764 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan// 458764 inode號
#tree命令:顯示磁碟目錄結構
[[email protected]_168_102_centos tmp]# tree.|-- 2014-08-04-212053|-- a| `-- b| `-- c| `-- d| `-- e| `-- f| `-- abcd|-- agent_cmd.sock|-- ap_1002.pid|-- ap_1004.pid|-- ap_1005.pid|-- ap_1007.pid|-- ap_1008.pid|-- ap_1014.pid|-- ceshi`-- wanghan `-- test11 directories, 7 files[[email protected]_168_102_centos tmp]#
tree –L #:顯示目前的目錄下指定最大深度的目錄結構
[[email protected]_168_102_centos tmp]# tree -L 1.|-- 2014-08-04-212053|-- a|-- agent_cmd.sock|-- ap_1002.pid|-- ap_1004.pid|-- ap_1005.pid|-- ap_1007.pid|-- ap_1008.pid|-- ap_1014.pid|-- ceshi`-- wanghan4 directories, 7 files[[email protected]_168_102_centos tmp]# tree -L 2.|-- 2014-08-04-212053|-- a| `-- b|-- agent_cmd.sock|-- ap_1002.pid|-- ap_1004.pid|-- ap_1005.pid|-- ap_1007.pid|-- ap_1008.pid|-- ap_1014.pid|-- ceshi`-- wanghan `-- test6 directories, 7 files[[email protected]_168_102_centos tmp]#
#alias命令:設定指令別名
單獨使用alias直接顯示當前shell中定義的所喲別名
[[email protected]_168_102_centos tmp]# aliasalias 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‘[[email protected]_168_102_centos tmp]#
定義指令別名:
alias 別名=‘原始指令’
[[email protected]_168_102_centos tmp]# alias test=ls [[email protected]_168_102_centos tmp]# test2014-08-04-212053 a agent_cmd.sock ap_1002.pid ap_1004.pid ap_1005.pid ap_1007.pid ap_1008.pid ap_1014.pid ceshi wanghan[[email protected]_168_102_centos tmp]# alias test=‘ls -l‘[[email protected]_168_102_centos tmp]# testtotal 24drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 asrwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sock-rw------- 1 root root 105 Aug 2 11:36 ap_1002.pid-rw------- 1 root root 0 Aug 2 09:48 ap_1004.pid-rw------- 1 root root 103 Aug 2 11:36 ap_1005.pid-rw------- 1 root root 0 Aug 2 10:51 ap_1007.pid-rw------- 1 root root 0 Aug 2 10:09 ap_1008.pid-rw------- 1 root root 0 Aug 4 13:58 ap_1014.piddrwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshidrwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan[[email protected]_168_102_centos tmp]#
取消指令別名:
[[email protected]_168_102_centos tmp]# unalias test[[email protected]_168_102_centos tmp]# tes