命令tree 以樹狀圖列出目錄下的所有內容,包含子目錄裏的文件。
如何安裝命令tree
使用 yum install -y tree 進行安裝即可
語法:tree 選項 參數
例如:tree /tmp 會列出/tmp目錄下所有內容
[root@JSH-01 ~]# tree /tmp
/tmp
├── mysql.sock
├── systemd-private-1a3e9976b48345bfaf96e75ce6ecc31f-httpd.service-BDCdcy
│ └── tmp
└── systemd-private-1a3e9976b48345bfaf96e75ce6ecc31f-vmtoolsd.service-PlgMkB
└── tmp
└── vmware-root
5 directories, 1 file使用 man tree 查看 tree 的幫助文檔
tree -L n 其中選項-L 手動指定目錄深度,n爲深度)當目錄下內容較多時,爲了更好的查看,通常僅需要列出2級目錄即可。
例如查看 /boot 目錄下的2級目錄
[root@JSH-01 ~]# tree -L 2 /boot
/boot
├── config-3.10.0-514.el7.x86_64
├── grub
│ └── splash.xpm.gz
├── grub2
│ ├── device.map
│ ├── fonts
│ ├── grub.cfg
│ ├── grubenv
│ ├── i386-pc
│ ├── locale
│ └── themes
├── initramfs-0-rescue-16b3e1f1592341f8abd834add3b42bf5.img
├── initramfs-3.10.0-514.el7.x86_64.img
├── initramfs-3.10.0-514.el7.x86_64kdump.img
├── initrd-plymouth.img
├── symvers-3.10.0-514.el7.x86_64.gz
├── System.map-3.10.0-514.el7.x86_64
├── vmlinuz-0-rescue-16b3e1f1592341f8abd834add3b42bf5
└── vmlinuz-3.10.0-514.el7.x86_64
6 directories, 13 files