Like Windows, Linux also has a program called the tree that allows directories and lists of files to be displayed in a depth-indented. The tree command lists current directory contents. When directory is displayed, the tree command will list the files contained in that directory in turn.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux system tools queries.
In this context, we shall look into how to use the tree command in Linux.
More about the Linux tree command
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.
How to install tree command ?
You can run the below command to install the tree command:
$ sudo apt install tree
What is the syntax of the tree command ?
It is given below:
$ tree [options] [directory]
The tree command Options is explained below with examples
1. To list current directory contents, Navigate to the directory and run the command:
2. -a list all files:
$ tree -a
3. -f print the full path:
$ tree -f
4. -d list directories only:
$ tree -d
5. -p show each file access permission:
$ tree -p
6. -u print the username:
$ tree -u
[Need help in fixing Linux system issues ? We can help you. ]