Seeing the forest with tree
Sorting Options
The sorting options are probably what distinguishes tree
most from ls
. The default is alphabetical order, but if you suspect a file or directory might be at the bottom of the alphabet, -r
will list results in reverse alphabetical order instead (Figure 5). Similarly, --dirfirst
can save you time by listing all the directories first if you are reasonably sure that what you are looking for is a directory.
Other handy sorting options include last modification time (-t
) and last status change (-c
). However, the option most likely to interest developers is version (-v
), which can help locate a particular generation of a file.
The Next Generation
The ls
command existed in the first version of Unix [3]. It remains a core command, and tree
is not immediately obvious as an enhanced, next generation replacement.
However, the minor advantages of tree
start to add up. In particular, its ability to exclude large portions of the directory structure and its extra sorting abilities make it slightly quicker for finding most files and directories.
Additionally, its visual representation of drives should not be underestimated. By desktop standards, tree
's representation of files and directories is primitive. Yet the tree is how people are taught to think about files and directories, and to see your mental representation on the screen only makes interacting with tree
easier.
The advantage of tree
is not great in any single case. However, the more you do file management at the command prompt, the more tree
's advantages mount. Take the time to learn it, and you might decide that ls
has had its day.
For more information, check out the extensive examples of how to use tree
from Barracuda Firewall [4].
Infos
- tree: http://mama.indstate.edu/users/ice/tree/
- strftime: http://linux.die.net/man/3/strftime
- ls: http://en.wikipedia.org/wiki/Ls
- View Fedora Linux directory with tree: http://www.labtestproject.com/basic_linux_commands/view_display_linux_fedora_directory_tree_using_tree_command
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs