更新时间:2022-05-16 12:33:13
tree显示文件系统结构
yum install tree
man tree/ tree --help 显示帮助文档
man tree -L 2 显示文件二级结构
命令的存放:
/bin/ -----一般存放普通用户使用的命令
/sbin/ -----一般存放root用户使用的命令
/bin/做了软链接:/usr/bin/
/sbin/做了软链接:/usr/sbin/
查看依赖的库文件:
例如查看ls依赖的库文件:
ldd /bin/ls
绝对路径:从根开始的路径;文件所在的路径;
相对路径:相对于当前目录而言的路径;上一级或者下一级的路径。
查看当前路径:pwd
进入指定目录: cd
ls -l列出文件详细信息
[root@centos_1 ~]# ls -l
总用量 4
-rw-------. 1 root root 1417 11月 9 16:01 anaconda-ks.cfg
其中 1 是表示有多少个文件使用了相同的inode
ls -i 查看文件inode号
-rw-------. 1 root root 1417 11月 9 16:01 anaconda-ks.cfg
权限 有多少个文件使用了相同的inode 所有者 所属主 大小 日期 文件名
ls -lh 显示文件单位大小
[root@centos_1 ~]# ls -lh anaconda-ks.cfg
-rw-------. 1 root root 1.4K 11月 9 16:01 anaconda-ks.cfg
ls -la 显示所有文件包括隐藏文件
ls -a
ls -ld 显示目录的详细信息
[root@centos_1 ~]# ls -ld /root
dr-xr-x---. 3 root root 147 11月 11 22:54 /root
有3个目录文件使用了相同的inode号,也可以理解为当前有多少个目录,有3个目录。
[root@centos_1 ~]# ls -i /root/
67172258 anaconda-ks.cfg
[root@centos_1 ~]# ls -i .
67172258 anaconda-ks.cfg
[root@centos_1 ~]# ls -i .ssh/..
67172258 anaconda-ks.cfg
其实就是root目录
.是当前目录 ..是上一级目录;
总用量是指使用的inode号之和:
3可以理解为当前有3个目录 . .. .ssh目录
ls -t 是以时间的顺序排序。时间越早的排在上面。
ls -lta
ls -d 列出目录
ls -l 列出根目录所有文件
ls -ld列出目录
ll 是ls -l的别名(alias):
[root@centos_1 ~]# which ll
alias ll='ls -l --color=auto'
/usr/bin/ls
文件类型:(- d c l b s)
-普通文件 :文本文档,二进制文件
-rw-------. 1 root root 1417 11月 9 16:01 anaconda-ks.cfg
d目录文件;
drwxr-xr-x. 4 root root 80 11月 16 21:46 v4l
c 字符串设备文件;
crw-rw----. 1 root tty 7, 129 11月 16 21:46 vcsa1
l 软链接文件,快捷方式文件
lrwxrwxrwx. 1 root root 13 11月 16 21:46 fd -> /proc/self/fd
箭头后面是原来的文件
b (block)块设备文件:光盘、磁盘都是这种b文件
brw-rw----. 1 root disk 8, 2 11月 16 21:46 sda2
s (socket)文件:用于通信
srw-rw-rw-. 1 root root 0 11月 16 21:46 /dev/log
权限最前面第一个字符是文件类型。
查看别名:which
[root@centos_1 ~]# which ll
alias ll='ls -l --color=auto'
/usr/bin/ls
alias 查看有谁定义了别名:
[root@centos_1 ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
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 xiaobo='ls -lsa'
[root@centos_1 ~]# alias xiaobo='ls -lha'
[root@centos_1 ~]# xiaobo
总用量 28K
dr-xr-x---. 3 root root 147 11月 11 22:54 .
dr-xr-xr-x. 17 root root 224 11月 15 22:24 ..
-rw-------. 1 root root 1.4K 11月 9 16:01 anaconda-ks.cfg
-rw-------. 1 root root 2.8K 11月 17 02:26 .bash_history
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
drwx------. 2 root root 80 11月 16 22:19 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@centos_1 ~]#
取消别名:unalias xiaobo
[root@centos_1 ~]# unalias xiaobo