English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux tree command

Comprehensive List of Linux Commands

The Linux tree command is used to list the contents of directories in a tree structure.

Execute the tree command, which will list all files under the specified directory, including files in subdirectories.

Syntax

tree [-aACdDfFgilnNpqstux][-I <template style>][-P <template style>][directory...]

Parameter Description:

  • -Display all files and directories.

  • -Use ASNI graphic characters to display the tree structure instead of ASCII character combinations.

  • -Add color to the list of files and directories to facilitate区分 different types.

  • -Display the directory name instead of the content.

  • -List the change time of the file or directory.

  • -Display the full relative path name before each file or directory.

  • -Add quotes to the names of files, directories, Sockets, symbolic links, pipe names, etc. when executing.*/Characters such as ",", "=", "@", and "|".

  • -List the group name of the file or directory, or display the group ID if there is no corresponding name.

  • -Do not list file or directory names in a stepped manner.

  • -Limit the display level of directories.

  • -If a directory is a symbolic link, list the original directory pointed to by the link directly.

  • -Do not add color to the list of files and directories.

  • -List the names of files and directories directly, including control characters.

  • -List the permission symbols.

  • -Only display file or directory names that match the template style.

  • -Replace control characters with "?" and list the names of files and directories.

  • -List the size of the file or directory.

  • -Sort files and directories by the time of change.

  • -List the owner's name of the file or directory, or display the user ID if there is no corresponding name.

  • -x Limit the scope to the current file system. If some subdirectories under the specified directory are stored on another file system, exclude these subdirectories from the search scope.

Online Examples

List the current directory structure in tree form. You can use the following command directly:

tree

The following output results are available for this command:

# tree  #List the current directory structure in tree form  
.  #Current Directory Structure  
|-- README  
|-- examples.desktop  
|-- file  
|-- file.new  
|-- index.htm  
|-- test  
| |-- README  
| |-- file  
| |-- testfile  
| |-- testfile1  
| |-- xaa  
| |-- xab  
| |-- xac  
| |-- xad  
| |-- xae  
| |-- xaf  
| |-- xag  
| |-- xah  
| `-- xai  
|-- test.tar.gz  
|-- test.zip  
|-- testfile  
|-- testfile.new  
|-- testfile.patch  
|-- testfile1  
|-- testfile2  
|-- testfile3  
|-- xaa  
|-- xab  
|-- xac  
|-- xad  
|-- xae  
|-- xaf  
|-- xag  
|-- xah  
|-- xai  
|-- \345\205\254\345\205\261\347\232\204  
|-- \345\233\276\347\211\207  
| |-- 075b5c2bb1628c1a5343c10a.jpg  
| |-- 0c978fe989ac787e799757095719d3c4.jpg  
| |-- 20050726194826866443.jpg  
| |-- 20061113171548785122.jpg  
| |-- 2007102221576687.jpg  
| |-- 39.jpg  
| |-- 434887ec4340916a78f0559a.jpg  
| |-- 498da016ac02fb2bc93d6d08.jpg  
| |-- 7b284f5a0f854da2f3bf90b204149a34.jpg  
| |-- 9196c030d342a68d5edf0e98.jpg  
| |-- a56c5a90de15c8a9a977a4cc.jpg  
| |-- c74f62167c9d2b244a90a79e.jpg  
| `-- img13.jpg  
|-- \346\226\207\346\241\243  
|-- \346\241\214\351\235\242  
|-- \346\250\241\346\235\277  
|-- \350\247\206\351\242\221  
`-- \351\237\263\344\271\220  
8 directories 48 files statistics, this directory contains8subdirectories48files

Comprehensive List of Linux Commands