tree lists the contents of directories in a tree-like format. It can display the structure of your file system.

Description

tree is a recursive directory listing program that produces a depth-indented listing of files (which is colorized 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. tree then returns the total number of files and/or directories listed.

  • Description
  • Syntax
  • Options
  • Examples
  • Related commands
  • Linux commands help

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 follows the path of the symbolic link as if it were a real directory.

Syntax

tree [-adfgilnopqrstuxACDFNS] [-L level [-R]] [-H baseHREF] [-T title] [-o file name] [–nolinks] [-P pattern] [-I pattern] [–inodes] [–device] [–noreport] [–dirsfirst] [–version] [–help] [–filelimit #] [–si] [–prune] [–du] [–timefmt format] [directory …]

Options

Examples

tree

Displays the contents of the current directory and subdirectories in a tree. The output takes a graphical form which resembles the following example:

. ├── config.dat ├── data │ ├── data1.bin │ ├── data2.sql │ └── data3.inf ├── images │ ├── background.jpg │ ├── icon.gif │ └── logo.jpg ├── program.exe └── readme.txt 2 directories, 9 files

tree -I ’example*|bin|lib'

Displays a tree without anything beginning with example or containing ‘bin’ or ’lib’ as specified in the pattern.

tree -P ’t*’

With an uppercase “P,” you can list files with a pattern. This pattern example displays a tree only containing directories beginning with t or directories containing files that begin with t.

tree -p

With a lowercase “p,” you can list a tree that also shows the file permissions.

ls — List the contents of a directory or directories.