#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录、文件夹、文件权限),查看目录信息等等
[[email protected]_168_102_centos /]# ls bin data etc lib lost+found mnt proc sbin srv tmp var boot 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 -l total 24 drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a srwxrwxrwx 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.pid drwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi d //文件类型 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 -ld drwxr-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-212053 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a srwxrwxrwx 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.pid drwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi drwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan [[email protected]_168_102_centos tmp]# ls -rl total 24 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan drwxr-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.pid srwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sock drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a drwxr-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]# ls b [[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 -l total 24 drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a drwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi drwxr-xr-x 3 wanghan root 4096 Aug 4 20:41 wanghan [[email protected]_168_102_centos tmp]# ls -lh total 24K drwxr-xr-x 2 wanghan root 4.0K Aug 4 21:21 2014-08-04-212053 drwxr-xr-x 3 wanghan root 4.0K Aug 4 20:45 a drwxr-xr-x 2 wanghan root 4.0K Aug 4 20:44 ceshi drwxr-xr-x 3 wanghan root 4.0K Aug 4 20:41 wanghan
ls -i:显示出文件inode号
[[email protected]_168_102_centos tmp]# ls -li total 24 458762 drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053 458767 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a 458758 srwxrwxrwx 1 root root 0 Aug 9 10:05 agent_cmd.sock 458755 -rw------- 1 root root 105 Aug 2 11:36 ap_1002.pid 458756 -rw------- 1 root root 0 Aug 2 09:48 ap_1004.pid 458759 -rw------- 1 root root 103 Aug 2 11:36 ap_1005.pid 458760 -rw------- 1 root root 0 Aug 2 10:51 ap_1007.pid 458757 -rw------- 1 root root 0 Aug 2 10:09 ap_1008.pid 458761 -rw------- 1 root root 0 Aug 4 13:58 ap_1014.pid 458766 drwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi 458764 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 `-- test 11 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 `-- wanghan 4 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 `-- test 6 directories, 7 files [[email protected]_168_102_centos tmp]#
#alias命令:设置指令别名
单独使用alias直接显示当前shell中定义的所哟别名
[[email protected]_168_102_centos tmp]# 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‘ [[email protected]_168_102_centos tmp]#
定义指令别名:
alias 别名=‘原始指令’
[[email protected]_168_102_centos tmp]# alias test=ls [[email protected]_168_102_centos tmp]# test 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 wanghan [[email protected]_168_102_centos tmp]# alias test=‘ls -l‘ [[email protected]_168_102_centos tmp]# test total 24 drwxr-xr-x 2 wanghan root 4096 Aug 4 21:21 2014-08-04-212053 drwxr-xr-x 3 wanghan root 4096 Aug 4 20:45 a srwxrwxrwx 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.pid drwxr-xr-x 2 wanghan root 4096 Aug 4 20:44 ceshi drwxr-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
linux学习命令总结④
时间: 2024-11-10 01:31:24