How to list contents of directories in a tree-like format in Linux
Tree is a recursive directory listing program that produces a depth indented listing of files, which is colorized ala dircolors if the LS_COLORS environment variable is set and output is to tty. With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories listed.
By default, when a symbolic link is encountered, the path that the symbolic link refers to is printed after the name of the link in the format:
name -> real-path
If the `-l’ option is given and the symbolic link refers to an actual directory, then tree will follow the path of the symbolic link as if it were a real directory.
Install tree in Linux
sudo apt install tree
Use
Example
Without any parameters and specific location, tree command only display all directory structures (including files) in the current location
To display the specific directory structures, you add -d parameter to tree command
You use -L (Descend only level directories deep) parameter to specify the number of display levels