TREE COMMAND IN LINUX
- This command is used to display the files and folders in the current directory / user specified directory in the tree order.
- This command is not installed by default. So you need to install it on your machine based on the linux distribution before using this command.
Syntax
tree
(OR)
tree options folder-name
Where
- Options can be -f, -d, -a, -s, -p, -X, -C, etc,.
- Folder-name can be the current directory or user specified directory.
Examples
- Listing Files and Folders in Current Directory
- Listing Files and Folders in User Specified Directory
- Listing Files and Folders in Full Path
- Listing Only Directories
- Listing Files in XML view
- Turn Colorization on using the option -C
- Displaying the size of files and folders
- Displaying the protection levels
Example 1 – Listing Files and Folders in Current Directory
- The tree command without any option -a can be used to display the files and folders in tree order.
- The input directory here used is current directory
Example 1 – Listing Files and Folders in Current Directory (Continue)
Example 2 – Listing Files and Folders in User Specified Directory
- The tree command without any option -a can be used to display the files and folders in tree order.
- The input directory here used is user specified directory named test5.
Example 3 – Listing Files and Folders with Full Path
- The option -f can be used with the tree command to show the files and folders with full path.
- The input directory can be the current directory or user specified directory.
Example 4 – Listing Only Directories
- The option -d can be used to display only the directories
- The input directory can be the current directory or user specified directory.
Example 5 – Listing Files and Folders in the XML View
- The option -x can be used with the tree command to show the files and folders in XML format
- The input directory can be the current directory or user specified directory.
Example 6 – Turn Colorization on
- The option -C can be used with the tree command to turn the colorization for files and folders
- The input directory can be the current directory or user specified directory.
Example 7 – Displaying the size of files and folders
- Here size of files and folders can be displayed using the special option -s
- The input directory can be the current directory or user specified directory.
Example 8 – Displaying the protection levels
- The option -p can be used with the tree command to show the protection levels of files and folders
- The input directory can be the current directory or user specified directory.