{"id":12570,"date":"2021-11-29T08:27:06","date_gmt":"2021-11-29T08:27:06","guid":{"rendered":"https:\/\/linuxways.net\/?p=12570"},"modified":"2021-12-07T04:12:28","modified_gmt":"2021-12-07T04:12:28","slug":"tree-command-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/tree-command-in-linux\/","title":{"rendered":"Tree Command in Linux"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Like Windows, Linux also has a program called the tree that allows directories and lists of files to be displayed in a depth-indented. The tree command lists current directory contents. When directory is displayed, the tree command will list the files contained in that directory in turn.<\/p>\n<p>And we will guide you on how to use the tree command in Linux as we did below. Hope you understand.<\/p>\n<h2>Installing tree command<\/h2>\n<p>Run apt command to install:<\/p>\n<pre>$ sudo apt install tree<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1043\" height=\"392\" class=\"wp-image-12571\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-589.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-589.png 1043w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-589-300x113.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-589-1024x385.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-589-768x289.png 768w\" sizes=\"auto, (max-width: 1043px) 100vw, 1043px\" \/><\/p>\n<h2>The syntax of the tree command<\/h2>\n<pre>$ tree [options] [directory]<\/pre>\n<p><strong>options:<\/strong><\/p>\n<p><strong>1. <\/strong>list current directory contents. Navigate to the directory and run:<\/p>\n<pre>$ tree<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1042\" height=\"147\" class=\"wp-image-12572\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-590.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-590.png 1042w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-590-300x42.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-590-1024x144.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-590-768x108.png 768w\" sizes=\"auto, (max-width: 1042px) 100vw, 1042px\" \/><\/p>\n<p><strong>2. -a <\/strong> list all files<\/p>\n<pre>$ tree -a<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1043\" height=\"638\" class=\"wp-image-12573\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-591.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-591.png 1043w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-591-300x184.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-591-1024x626.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-591-768x470.png 768w\" sizes=\"auto, (max-width: 1043px) 100vw, 1043px\" \/><\/p>\n<p><strong>3. -f<\/strong> print the full path<\/p>\n<pre>$ tree -f<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1044\" height=\"331\" class=\"wp-image-12574\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-592.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-592.png 1044w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-592-300x95.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-592-1024x325.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-592-768x243.png 768w\" sizes=\"auto, (max-width: 1044px) 100vw, 1044px\" \/><\/p>\n<p><strong>4. -d <\/strong> list directories only<\/p>\n<pre>$ tree -d<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1042\" height=\"632\" class=\"wp-image-12575\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-593.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-593.png 1042w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-593-300x182.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-593-1024x621.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-593-768x466.png 768w\" sizes=\"auto, (max-width: 1042px) 100vw, 1042px\" \/><\/p>\n<p><strong>5. -p<\/strong> show each file access permission<\/p>\n<pre>$ tree -p<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1042\" height=\"634\" class=\"wp-image-12576\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-594.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-594.png 1042w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-594-300x183.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-594-1024x623.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-594-768x467.png 768w\" sizes=\"auto, (max-width: 1042px) 100vw, 1042px\" \/><\/p>\n<p><strong>6. -u <\/strong> print the username<\/p>\n<pre>$ tree -u<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1042\" height=\"229\" class=\"wp-image-12577\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-595.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-595.png 1042w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-595-300x66.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-595-1024x225.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-595-768x169.png 768w\" sizes=\"auto, (max-width: 1042px) 100vw, 1042px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>We have shown you how to use the tree command in Linux.<\/p>\n<p>Thanks for referring!<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction Like Windows, Linux also has a program called the tree that allows directories and lists of files to be displayed in a depth-indented. The tree command lists&hellip;<\/p>","protected":false},"author":1,"featured_media":12774,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[35,720],"class_list":["post-12570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-linux","tag-tree-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=12570"}],"version-history":[{"count":1,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12570\/revisions"}],"predecessor-version":[{"id":12578,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12570\/revisions\/12578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/12774"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=12570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=12570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=12570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}