Display link dir in WSL

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
I've made a directory link in the WSL/Ubuntu environment.

I'm trying to display the links using the following:

sudo find / -type l
sudo find . -maxdepth 1 -type l

What was displayed is not just the links I've made but alot of permission errors.

Is there a way I display just my links ?

Thanks. Appreciate.
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
I've made a directory link in the WSL/Ubuntu environment.

I'm trying to display the links using the following:

sudo find / -type l
sudo find . -maxdepth 1 -type l

What was displayed is not just the links I've made but alot of permission errors.

Is there a way I display just my links ?

Thanks. Appreciate.
Pipe your error to /dev/null, errors are normally printed into the standard error stream.
Bash:
sudo find / -type l 2>/dev/null
sudo find . -maxdepth 1 -type l 2>/dev/null

#or

(sudo find / -type l; sudo find . -maxdepth 1 -type l) 2>/dev/null
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
Pipe your error to /dev/null, errors are normally printed into the standard error stream.
Bash:
sudo find / -type l 2>/dev/null
sudo find . -maxdepth 1 -type l 2>/dev/null

#or

(sudo find / -type l; sudo find . -maxdepth 1 -type l) 2>/dev/null

Thanks David. The command displays a lot of directories, I think all the directories not the links. The "-type l" doesn't seem to work.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Thanks David. The command displays a lot of directories, I think all the directories not the links. The "-type l" doesn't seem to work.
As I'm not using Windows with WSL myself, I probably don't experience the problem you are facing and I can't be sure too.
-type l does work properly on unix system, but I believe WSL may not be consistency implementing how the VFS works in M$ environment.

I did a search for you and apparently it seems like a known issue
https://github.com/microsoft/WSL/issues/5118
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
As I'm not using Windows with WSL myself, I probably don't experience the problem you are facing and I can't be sure too.
-type l does work properly on unix system, but I believe WSL may not be consistency implementing how the VFS works in M$ environment.

I did a search for you and apparently it seems like a known issue
https://github.com/microsoft/WSL/issues/5118

Wow. thanks very much for putting in the effort to help me.
Greatly appreciated.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Thanks David. The command displays a lot of directories, I think all the directories not the links. The "-type l" doesn't seem to work.
I think it works. I just installed WSL 1.0 on my Windows 10 VM and tried your command. It works when I plan it properly.
rnkO3BT.png


The problem is when I try to do what you are trying to do and attempt to recursively find symbolic links starting from the root directory
Bash:
find / type l

You will see alot of symbolic links under the prefix /mnt/c like this
stUdIKM.png


Look at the last bits of the image above, you will see
'/mnt/c/Program Files/Microsoft Office/root/Client/AppvIsvSubsystems32.dll' is a symbolic link.
M$ WSL created a lot of symbolic links

Is that what you have been experiencing ?

You can run this command and tell if the find command is working fine
Bash:
find / -type l -exec ls -al {} \; 2>/dev/null

I can tell all the listed files are symbolic links. So it is working fine.

:)
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
I think it works. I just installed WSL 1.0 on my Windows 10 VM and tried your command. It works when I plan it properly.
rnkO3BT.png


The problem is when I try to do what you are trying to do and attempt to recursively find symbolic links starting from the root directory
Bash:
find / type l

You will see alot of symbolic links under the prefix /mnt/c like this
stUdIKM.png


Look at the last bits of the image above, you will see
'/mnt/c/Program Files/Microsoft Office/root/Client/AppvIsvSubsystems32.dll' is a symbolic link.
M$ WSL created a lot of symbolic links

Is that what you have been experiencing ?

You can run this command and tell if the find command is working fine
Bash:
find / -type l -exec ls -al {} \; 2>/dev/null

I can tell all the listed files are symbolic links. So it is working fine.

:)

Ic.. but it defeat the purpose of me trying to find the specific link I have created. I then have to manually keep track of it to remove or amend.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Ic.. but it defeat the purpose of me trying to find the specific link I have created. I then have to manually keep track of it to remove or amend.

Your find starting point is the root directory. That most likely is wrong. If you are trying to keep track of something you created, shouldn’t it be in a more specific directory say for example /opt/myinstallation/ ?

Then you can use
find /opt/myinstallation -type l

It is still unclear what you are really trying to track. Perhaps you want to elaborate and be more specific

:)
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
Your find starting point is the root directory. That most likely is wrong. If you are trying to keep track of something you created, shouldn’t it be in a more specific directory say for example /opt/myinstallation/ ?

Then you can use
find /opt/myinstallation -type l

It is still unclear what you are really trying to track. Perhaps you want to elaborate and be more specific

:)

I guess I'm lazy on this point. I normally don't use mental power and throw it to the system to handle. That's why. My approach is generally to use a generic process to handle various situations so that I don't have to "remember too much".

What I wanted is to bridge the Windows env to the Linux env, to make it more Linux like. So I link a Window folder to my /home/..../ as if I'm now working on a Linux as I'm to prepare scripts for a Unix env (otherwise, I have to cd /mnt/d/xx/xx/xx/ which is native to Windows)

I can:

cd ~
find . -maxdepth 2 -type l

but I must maintain the discipline to link to the first level of my /home/xxx/ directory.

I just find it a waste that I couldn't have more freedom to link to anywhere and use a generic command on WSL to find it easily (if I use this approach). And if I make a mistake and link to somewhere, I won't be able to find it at all. :)
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
I guess I'm lazy on this point. I normally don't use mental power and throw it to the system to handle. That's why. My approach is generally to use a generic process to handle various situations so that I don't have to "remember too much".

What I wanted is to bridge the Windows env to the Linux env, to make it more Linux like. So I link a Window folder to my /home/..../ as if I'm now working on a Linux as I'm to prepare scripts for a Unix env (otherwise, I have to cd /mnt/d/xx/xx/xx/ which is native to Windows)

I can:

cd ~
find . -maxdepth 2 -type l

but I must maintain the discipline to link to the first level of my /home/xxx/ directory.

I just find it a waste that I couldn't have more freedom to link to anywhere and use a generic command on WSL to find it easily (if I use this approach). And if I make a mistake and link to somewhere, I won't be able to find it at all. :)

You have all the freedom in this aspect, but you are not doing things that make sense exclusively to you.
It is very very very common to have symbolic links even in a true native unix environments, so even without WSL involved, searching for symbolic links starting at your root directory will not work because symbolic links is not exclusive to you only.

You can obviously create symlink all the way from the /(root) say, /mydrive if that fancy you, but in the unix world there is an established way how things are distributed across the system and the / path is recommended for system wide installation and /home/<userid>/ directory is user specific. There are also other popular mountpoints like /usr/local/, /opt etc that you can use to place your stuff. In the case of a virtual or remote reference outside the local(which in the case of WSL could be vague), is that you can use /mnt/mywin/ as a mount branch to access elsewhere

As such, if you want to search anything in the Windows realm, you can simply just use find /mnt/mywin ...

I don't know what kind of stringent discipline you need to know where you put your stuff. It's part and parcel of using any system, just like you would normally search for your own stuffs inside C:\Users\YourAccount instead of just plainly searching the entire filesystem starting from C:\ because it will be a waste of cpu and I/O resources unless you narrow down your search space.

Unless you are not aware, it isn't a fast operation to search the entire filesystem. It looks fast to you in Windows because of Indexing Service. Off your Indexing Service and it will become a chore and takes a long time to search through the entire filesystem to find something.

In Unix, we have locate or the more secure slocate to perform filesystem indexing which allows you to search file quickly. Do read up on
http://manpages.ubuntu.com/manpages/bionic/man5/locatedb.5.htmlhttps://man7.org/linux/man-pages/man1/updatedb.1.htmlhttps://www.geekboots.com/story/how-linux-file-indexing-and-search-works
An example for you
Bash:
$ ls /home/ubuntu/aws
README.md  THIRD_PARTY_LICENSES  dist  install
$ locate THIRD_PARTY_LICENSES
/home/ubuntu/aws/THIRD_PARTY_LICENSES
 
Last edited:

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
You have all the freedom in this aspect, but you are not doing things that make sense exclusively to you.
It is very very very common to have symbolic links even in a true native unix environments, so even without WSL involved, searching for symbolic links starting at your root directory will not work because symbolic links is not exclusive to you only.

You can obviously create symlink all the way from the /(root) say, /mydrive if that fancy you, but in the unix world there is an established way how things are distributed across the system and the / path is recommended for system wide installation and /home/<userid>/ directory is user specific. There are also other popular mountpoints like /usr/local/, /opt etc that you can use to place your stuff. In the case of a virtual or remote reference outside the local(which in the case of WSL could be vague), is that you can use /mnt/mywin/ as a mount branch to access elsewhere

As such, if you want to search anything in the Windows realm, you can simply just use find /mnt/mywin ...

I don't know what kind of stringent discipline you need to know where you put your stuff. It's part and parcel of using any system, just like you would normally search for your own stuffs inside C:\Users\YourAccount instead of just plainly searching the entire filesystem starting from C:\ because it will be a waste of cpu and I/O resources unless you narrow down your search space.

Unless you are not aware, it isn't a fast operation to search the entire filesystem. It looks fast to you in Windows because of Indexing Service. Off your Indexing Service and it will become a chore and takes a long time to search through the entire filesystem to find something.

In Unix, we have locate or the more secure slocate to perform filesystem indexing which allows you to search file quickly. Do read up on
http://manpages.ubuntu.com/manpages/bionic/man5/locatedb.5.htmlhttps://man7.org/linux/man-pages/man1/updatedb.1.htmlhttps://www.geekboots.com/story/how-linux-file-indexing-and-search-works
An example for you
Bash:
$ ls /home/ubuntu/aws
README.md  THIRD_PARTY_LICENSES  dist  install
$ locate THIRD_PARTY_LICENSES
/home/ubuntu/aws/THIRD_PARTY_LICENSES

Thanks you! I've learnt another new thing: locate. :)
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top