I was learning about virtual environments and projects. While watching videos I encountered 'tree
command I installed tree
and then run it. But it is not working on other partition of my HDD other than /
partition.
When I use tree
in ~/Documents, I get desired results
$ tree -d
.
├── Desktop
└── Fix ‘No WiFi Adapter Found’ for HP Laptops with Ubuntu 18.04 _ UbuntuHandbook_files
2 directories
But when I use it in other partition, I get
sandeep@sandeep-HP-Laptop-15q-ds0xxx:/media/sandeep/sandeep files$ tree -d
. [error opening dir]
0 directories
TL;DR
If you want to continue using snap version of tree,
Alternatively use deb version of
tree
which can be installed using APT.Longer version:
Whenever a partition/removable media is mounted, the target point is usually /media/USER/UUID. But as per limitations of Snap, Snap applications can't guarantee the access of directories/files outside of current user's
$HOME
and that include directories such as /media and even /etc. From zyga's post:However,
tree
that is installed via APT can access those (DEBs don't have such limitations). So, if you needtree
to work in other partitions, either installtree
using APT. For that, runOr mount the partition in
$HOME
. For mounting a partition, you can use eithermount
command or edit/etc/fstab
.If using,
mount
,Create a directory in any subdirectory of
$HOME
, for example,test
in ~/Desktopmount
works only withsudo
privileges, therefore, run(Replace
/path/of/partition/
with the partition/device path, for example, /dev/sda3)This won't automatically mount partition in that folder. Thus if you mount and unmount partition again and again, the command needs to be re-run.
If editing
/etc/fstab
:Obtain UUID using
(Replace
/path/of/partition/
with the partition/device path, for example, /dev/sda3)Open
/etc/fstab
withsudo
privileges using a text editor such asnano
and add this line:where UUID is obtained from the previous command, mount point is ~/Desktop/test (lets say) and partition type is the type of partition such as ntfs or ext4.
This automatically mounts partition in the given mount point even after just a tap in Nautilus.
Once you're done you can use
tree
withsudo
privileges, since both will mount the partition withsudo
privileges and hence owner would beroot
.I got the same error. Here's what I did to resolve it:
Over time, I've found that snap causes a lot of issues.
This is just one example.
I'm a novice learning about ubuntu and linux today. My teacher showed me how to make directories using the:
mkdir -p mydir/mysubdir2/mysubdir3
and then using the tree command to get an overview that it was done. However, I didnt have the tree command installed, so I got it installed through "sudo apt install tree" but got the same error as you when I tried "tree mydir" from the directory I created them.
I played around and saw that I forgot an "/" at the end, so if I wrote "tree mydir/" it worked like a charm.
Not sure if that helped, but I hope so! :)