在 CentOS 系统,我们经常实用 ls 命令查看文件目录结构,tree命令是另一个类似的工具,可以查看整个的目录结构。但是应用tree命令的时候先得安装它,下面小编就给大家分享一下在CentOS中如何安装tree命令。
-
yum 搜索 tree
# yum search tree
输出:
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 7.5 kB 00:00:00
* base: mirrors.aliyun.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/7): extras/7/x86_64/primary_db | 230 kB 00:00:00
(3/7): epel/x86_64/group_gz | 96 kB 00:00:00
(4/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(5/7): updates/7/x86_64/primary_db | 6.5 MB 00:00:00
(6/7): epel/x86_64/updateinfo | 1.0 MB 00:00:34
(7/7): epel/x86_64/primary_db
============================================================================================================= N/S matched: tree =============================================================================================================
ebtree.x86_64 : Elastic binary tree library
ebtree-devel.x86_64 : Development files for ebtree
geany-plugins-treebrowser.x86_64 : Alternate file browser plugin providing a tree view of directories
golang-github-smartystreets-assertions-unit-test.x86_64 : Unit tests for golang-github-smartystreets-assertions package
golang-github-smartystreets-goconvey-unit-test.x86_64 : Unit tests for golang-github-smartystreets-goconvey package
gomtree.x86_64 : Go CLI tool for mtree support
maven-dependency-tree.noarch : Maven dependency tree artifact
maven-dependency-tree-javadoc.noarch : Javadoc for maven-dependency-tree
nodejs-ascii-tree.noarch : A node module for generating a text tree in ASCII
nodejs-dtree.noarch : Command-line tool to view the dependency tree of any single js file
nodejs-freetree.noarch : A node module for creating tree data structure from text input
nodejs-mkfiletree.noarch : Nodejs module to make a tree of files and directories
ostree.x86_64 : Tool for managing bootable, immutable filesystem trees
ostree-devel.x86_64 : Development headers for ostree
ostree-fuse.x86_64 : FUSE utilities for ostree
ostree-grub2.x86_64 : GRUB2 integration for OSTree
perl-File-CheckTree.noarch : Run many file-test checks on a tree
perl-HTML-Tree.noarch : HTML tree handling modules for Perl
perl-Tree-DAG_Node.noarch : Class for representing nodes in a tree
perl-Tree-R.noarch : Perl extension for the R-tree data structure and algorithms
perl-XML-TreeBuilder.noarch : Parser that builds a tree of XML::Element objects
php-horde-Horde-Tree.noarch : Horde Tree API
python2-asciitree.noarch : Draws ASCII trees
python2-tree-format.noarch : Python library to generate nicely formatted trees, like the UNIX tree command
root-tree.x86_64 : Tree library for ROOT
root-tree-dataframe.x86_64 : A high level interface to ROOT trees
root-tree-player.x86_64 : Library to loop over a ROOT tree
root-tree-viewer.x86_64 : GUI to browse a ROOT tree
rubygem-comp_tree-doc.noarch : Documentation for rubygem-comp_tree
subscription-manager-plugin-ostree.x86_64 : A plugin for handling OSTree content.
texlive-pst-tree.noarch : Trees, using pstricks
texlive-pst-tree-doc.noarch : Documentation for pst-tree
tree.x86_64 : File system tree viewer
-
yum 安装 tree
# yum install tree.x86_64 -y
输出:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================================================================
Installing:
tree x86_64 1.6.0-10.el7 base 46 k
Transaction Summary
=============================================================================================================================================================================================================================================
Install 1 Package
Total download size: 46 k
Installed size: 87 k
Is this ok [y/d/N]: y
Downloading packages:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tree-1.6.0-10.el7.x86_64 1/1
Verifying : tree-1.6.0-10.el7.x86_64 1/1
Installed:
tree.x86_64 0:1.6.0-10.el7
Complete!
-
测试 tree 命令
# tree
.
├── data
├── log
├── nginx
├── redis
└── tmp
5 directories, 0 files
-
tree help
# tree -help
tree: Invalid argument -`e'.
usage: tree [-acdfghilnpqrstuvxACDFQNSUX] [-H baseHREF] [-T title ] [-L level [-R]]
[-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]
[--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]
[--filelimit[=]#] [--si] [--timefmt[=]<f>] [<directory list>]