Linux tree display of directories, tree command

Linux tree display of directories, tree command

Colleagues hello to all.

In today's article, we'll talk about a very handy tool for listing files and directories on the Linux command line called tree. This utility displays a tree-like list of files and directories in a human-readable form. The tree command recursively traverses all nested directories and files and displays information in a convenient tree-like format.

 

Article content:

  1. Installing the utility.
  2. Syntax of the tree command.
  3. Examples with the tree command.

 

1. Installing the utility.

The tree utility is not installed on Linux distributions and we need to install it first. To install, use the command:

$. yum install tree

linux_program_tree


 

2. Syntax of the tree.

command

tree [options] directory.

  • -a show all files, including hidden ones.
  • -d show directories only.
  • -h show size of files.
  • -u show owner or userid.
  • -g show group or group id.
  • -С turn on highlighting with different colors.
  • -D show date when a file or directory was last modified.

 

3. Examples with the tree command.

 

3.1. A simple example tree of files in the current directory. To do this, execute the tree command without any arguments.

$. tree

linux_program_tree

 

3.2. An example tree of files and their size, for this you need to use the (-h) parameter.

$. tree -h

linux_program_tree

 

3.3. An example showing the directories themselves without files, for this you need to use the (-d) parameter.

$. tree -d

linux_program_tree

 

3.4. An example showing the date of the last modification of a file or directory, for this you need to use the (-D) parameter.

$. tree -D

linux_program_tree

 

3.5. An example showing the size, owner, group and modification date of files and directories.

$. tree -hugD

linux_program_tree


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES

Linux wget command. Download files from the internet via SSH
Linux wget command. Download files from the internet via SSH
PROGRAMS
Read more
Linux - How to Install PHP Composer on CentOS 8
Linux - How to Install PHP Composer on CentOS 8
PROGRAMS
Read more