How to list directory structure in linux
Linux command tree can list the contents of directory in a tree-like format.
tree dirname
For example , below command show the structure of /tmp dir
root@ubuntu:~# tree /tmp /tmp ├── config-err-MDhyjU ├── ssh-JFUdmO6X9ocf │ └── agent.1716 ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-colord.service-B6tUTi │ └── tmp ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-ModemManager.service-5cDUVe │ └── tmp ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-switcheroo-control.service-5jqUPf │ └── tmp ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-systemd-logind.service-zjru2g │ └── tmp ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-systemd-resolved.service-UmlVHh │ └── tmp ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-systemd-timesyncd.service-KBYWwi │ └── tmp ├── systemd-private-e4ab54cd6bcc472a8d3976c48af1f03f-upower.service-DOS3Ef │ └── tmp ├── tracker-extract-files.1000 ├── tracker-extract-files.125 ├── VMwareDnD ├── vmware-j │ └── vmware-apploader-2033.log ├── vmware-root │ ├── vmware-apploader-1065.log │ ├── vmware-apploader-1100.log │ ├── vmware-apploader-1117.log │ ├── vmware-apploader-1163.log │ ├── vmware-apploader-1224.log │ ├── vmware-apploader-1231.log │ ├── vmware-apploader-1241.log │ ├── vmware-apploader-1256.log │ └── vmware-apploader-989.log └── vmware-root_1231-4248221706 21 directories, 12 files
To list directories only , use option “-d”
tree -d /tmp
Use option “-F” to add some “salt” for different type of files
-F Append a `/' for directories, a `=' for socket files, a `*' for exe-
cutable files, a `>' for doors (Solaris) and a `|' for FIFO's, as per ls
-F