Today's article has you playing with trees...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,134
Reaction score
8,706
Credits
83,806
Ever wanted to make a pretty directory tree? Well, you can! Not only can you make directory trees, with and without files listed, you can take that output stream and send it to a handy-dandy text document. If you've ever really need to understand a directory structure, the tree command is there for your directory tree needs!

Also, you probably have to install it. I briefly did some looking and I don't think it's installed by default in all that many distros. One could make a reasoned argument that it should be, but that's not up to me. Well, I could probably ask and have it included with Lubuntu - if I pestered 'em enough...


There's more that you can do with the tree command, but not that much more. If you do use the command, you could leave a comment (here or on the site itself, should you want a larger audience for your thoughts). I do enjoy feedback, but there's not a whole lot to the tree command.

Also, running it on the drive's root directory will take quite a while. I suspect it'd be faster on an NVMe drive, 'cause I also sent the output to a text file. Said text file was really quite large.
 


sphen

Well-Known Member
Joined
Dec 12, 2022
Messages
868
Reaction score
749
Credits
10,394
You are great at reminding me of old commands I once knew and used, but have long forgotten.

There is no predicting which distros have the tree command installed by default. In some cases, the "same" distro has it by default and others not. For example, the default Ubuntu 22.04 LTS on Oracle cloud has "tree" installed by default on ARM, but not AMD.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,134
Reaction score
8,706
Credits
83,806
There is no predicting which distros have the tree command installed by default.

It's a useful tool that's small in size. Well, it's useful for doing what it says on the tin. A subset of people will find that useful. I'd think it'd be most useful when you're working on a computer you didn't configure so that you can quickly get a lay of the land survey done.

You are great at reminding me of old commands I once knew and used, but have long forgotten.

Thanks. The goal is getting people up to speed, previously worded as 'making Linux approachable'.

There was a previous site that was on a TLD hated by search engines - and it wasn't really a great site. So, I decided to make this site and start writing an article every other day. It's a lot like work, but I also learn things along the way.
 

bob466

Well-Known Member
Joined
Oct 22, 2020
Messages
1,216
Reaction score
916
Credits
8,956
For me as an average user it's not something I'd need... just like creating a folder ( directory) with...mkdir...when I can right click and select Create New Folder.
m1213.gif


I do have a few commands that list files in a directory with options like...ls...ls /...ls ~...ls -d */...ls * and ls -s...which are handy to have if you like that sort of thing but it's not me...feels like the old days.
m0104.gif
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,134
Reaction score
8,706
Credits
83,806
For me as an average user it's not something I'd need...

You can always just toy with it, just for your own amusement.

I'm tempted to test 'writing the entire root directory' on an SSD and MVMe to see how much of a difference it makes with regard to time.

But, this is DEFINITELY not a command most folks are going to need.
 

osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
913
Reaction score
856
Credits
8,655
tree will find a file for the user, for example looking for the file "bar":
Code:
[flip@flop ~/lemon/file-exp]$ tree -P bar
.
├── anoth
│   ├── newdir
│   └── ots
│       └── Desktop
├── anoth2
│   └── anoth
│       ├── newdir
│       └── ots
├── copydir
├── dirfile
│   └── spaces
└── gzz
    ├── bar <---------------------------file
    └── baz

14 directories, 1 file
The output on this machine is colored, so all the names other than "bar" are visible in blue output since they are directories, with the file "bar", the only output in white, so it's very easy to see on screen, though less so in this post.
 

guiverc

Well-Known Member
Joined
Nov 17, 2021
Messages
155
Reaction score
262
Credits
1,968
I do prefer trees that have birds on them... (and I do mean the feathered variety)

That command reminds me of online scam videos on youtube etc.. as that command is often used (I think) to distract the victim as the scammer tells them it's scanning for malware and ....

Well, I could probably ask and have it included with Lubuntu - if I pestered 'em enough...

Anyway, tree was installed on this my primary Ubuntu/Lubuntu system; and I see it only the lunar or 23.04 manifest which could explain why

- https://cdimage.ubuntu.com/lubuntu/releases/lunar/release/lubuntu-23.04-desktop-amd64.manifest
Code:
tree    2.1.0-1

so maybe the Lubuntu team heard you?

Anyway; I'm going to go to a window & look at a real tree (which hopefully has some birds on it)
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,134
Reaction score
8,706
Credits
83,806
tree will find a file for the user, for example looking for the file "bar":

Nice! I have never used the command for that... I learn all sorts of new things by doing these articles. I typically (like for this article) base the article on something I've added in my notes.

so maybe the Lubuntu team heard you?

I seem to recall manually needing to install in 22.04. While I tested the snot out of 23.04, I don't have it installed anywhere.

For all the times I checked the manifest, I never noticed 'tree' but I probably wouldn't remember it. I just look to see what has been changed. There is no way I'll remember all of that.
 

guiverc

Well-Known Member
Joined
Nov 17, 2021
Messages
155
Reaction score
262
Credits
1,968
I seem to recall manually needing to install in 22.04. While I tested the snot out of 23.04, I don't have it installed anywhere.

For all the times I checked the manifest, I never noticed 'tree' but I probably wouldn't remember it. I just look to see what has been changed. There is no way I'll remember all of that.
I suspect (and I don't want to look why) it was pulled in as a depends rule as I don't see it, and can't imagine why it'd be in our seed file. As we don't seed it, differences between releases are more likely in my view. I did an apt-cache rdepends tree but nothing there 'grabbed me' as significant (alas quite a few I don't know). It maybe the Ubuntu base.

My system has it, this box was only purchased this year, thus had a lunar install, which is why I expected to find it on a lunar manifest (though as this box has other stuff installed inc. ubuntu-desktop & xubuntu-desktop so its far from a lean install).

I typed xubuntu manifest in my firefox browser, and it offered me (from my history) https://cdimage.ubuntu.com/xubuntu/releases/22.10/release/xubuntu-22.10-desktop-amd64.manifest and 'tree' is there. A quick search of a Xubuntu seed file (lunar was in my firefox history so I went with that) & not there. I do suspect it's base that causes its inclusion; but I don't intend looking further.

Those on lunar or kinetic were probably perfectly primed for your article, I don't know about jammy but I do see it on a current daily (https://cdimage.ubuntu.com/lubuntu/jammy/daily-live/current/jammy-desktop-amd64.manifest) [yeah it's me again using my firefox history]
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,134
Reaction score
8,706
Credits
83,806
[yeah it's me again using my firefox history]

You have some gems in your history! I don't ever delete my history unless it's done automatically when I use an incognito window. If I am doing that, it's not that I'm trying to hide from anyone local - it's that I want a clean session with no cookies.

I had immediately to hand a Mint install that I could check and tree wasn't there by default in that instance. I had to install it manually.
 

Staff online


Top