Tree Command in Termux | Install & Use Tree to View Directory Structure 🌳📁

If you've ever opened a folder containing hundreds of files inside Termux, you know how difficult it can be to understand what's inside just by using the ls command. It only shows you a list of files, and after a while everything starts looking messy. That's where the Tree command comes in. It displays your files and folders in a beautiful tree-like structure, making it much easier to understand how everything is organized.

Whether you're learning Linux, managing programming projects, or just exploring your Android storage, Tree is one of those small tools that you'll end up using all the time. If you're new to Linux, check out our guide to Basic Commands in Termux. In this tutorial, I'll show you how to install Tree in Termux along with some of the most useful commands you should know.


What is Tree in Termux?

Tree is a lightweight Linux utility that prints directories in a tree format instead of a normal list. Instead of seeing one folder at a time, you get a complete overview of your directory structure.

If you frequently browse large directories, you may also like the Ranger File Manager for Termux, which provides an interactive terminal-based file explorer.

For example, instead of seeing a flat text list like Downloads, Pictures, Music, Documents, the Tree command maps it out visually for you:

.
├── Downloads
│   ├── Movies
│   ├── APKs
│   └── ZIP Files
├── Pictures
│   ├── Camera
│   └── Screenshots
├── Music
└── Documents

As you can see, it's much easier to understand where your files are stored.


Install Tree in Termux

First of all, let's install the Tree package.

Before installing packages, make sure you're using the latest version of Termux.

Update your packages first by running this setup command:

pkg update && pkg upgrade -y

Now install Tree using this package command:

pkg install tree -y

Output Details

The system will read package lists, build the dependency tree, process the 52.3 kB archive, and complete the installation setup automatically.

Once the installation is complete, let's make sure everything installed correctly by checking the system version:

tree --version

Output Results

➔ system response: tree v2.2.1

Congratulations! 🎉

Tree is now installed successfully. 🥳


Basic Tree Commands


Display Current Directory

Simply type this default command to view everything in your present folder:

tree

Example Directory Summary: It will layout your active files and present a final count summary at the bottom, such as: 4 directories, 0 files.


Display a Specific Folder

If you want to view your internal storage, point the layout directly to that path:

tree /sdcard

Show Only Directories

If you don't want files to appear and want to hide them from the visual list, use the directory flag:

tree -d

Show Hidden Files

Hidden system items normally don't appear. 🤔 To force them to display in your terminal tree, use the all flag:

tree -a

Limit Directory Depth

Sometimes folders contain thousands of files. 😱 Instead of printing a massive never-ending stream, limit the structural depth layers:

tree -L 2

This command safely restricts the display output to only two folder levels deep.


Display Full File Paths

To view complete prefix path locations for every single file listed, run:

tree -f

Show File Sizes

To print the exact bytes or storage footprint sizes next to each item name, use:

tree -s

Display File Permissions

To check safety access rights and look at ownership permissions, execute:

tree -p

Save Output to a File

You can even export and save the entire structural tree map directly into a standard text document. 💾

tree > tree-output.txt

Now simply open up that newly generated text file anytime to check out the complete logs! 📄


Display Help

To review the complete system manual and see every single command variable available, run:

tree --help

Why Should You Use Tree?

The normal ls command only lists files horizontally, but Tree helps you visualize your entire setup much more clearly. 👀

It's an absolute game-changer when you are:

✅ Learning Linux commands
✅ Working on development projects using Clang or different programming languages in Termux
✅ Managing custom Bash scripts
✅ Deep organizing Android file systems
✅ Building projects inside an Ubuntu environment in Termux
✅ Exploring your filesystem before using tools like Termux Helper

Once you start sorting with Tree, it's honestly hard to go back to using simple list outputs. 💻🔥


Conclusion

Tree is one of those simple Linux tools that makes your life much easier. 🌟 It takes only a few seconds to install, but it helps you understand your folder structure instantly. Whether you're a beginner or an experienced Linux user, it's definitely worth keeping installed in Termux.

If you're customizing your setup, you may also enjoy Termux Aesthetics, Termux Styling, and LSD with File Icons, which pair perfectly with the Tree command.

I hope this tutorial helped you install and understand the Tree command in Termux. If you know any other useful Tree options, feel free to share them in the comments below.

Thanks for reading Guys.

Stay Inspired and as always Stay Ethical. 👾🛡️

Post a Comment

0 Comments

⚡ Get Complete Termux Course