在 Linux 中查看目录结构(也就是文件和文件夹的层级关系),常见方法如下:
tree 命令(直观)tree
tree /path/to/dir
tree -d
tree -L 2
如果提示
command not found,先安装:
# Ubuntu / Debian
sudo apt install tree
# CentOS / RHEL
sudo yum install tree
ls 命令ls -R
ls -l /path/to/dir
dudu -h --max-depth=2 /path
ncdu(终端图形化)sudo apt install ncdu
ncdu /
cd /
ls
| 需求 | 命令 |
|---|---|
| 最直观 | tree |
| 没装软件 | ls -R |
| 看大小 | du |
| 图形化 | ncdu |
如果你是服务器环境或想看某个具体目录,可以告诉我路径,我可以帮你写合适命令。