I don't have a trash can, what should I do?
Hello,
I'm on Windows 10 and I've installed a virtual Ubuntu machine along with all the related stuff.
When I delete a file from the file explorer (not from the command line), it disappears and I have no way to recover it. There's not even a recycle bin, which is quite annoying.
So, I thought that if I install trash-cli, the problem would be solved, but no, because it requires you to use
trash-put file_name
.... for me to see that file in my Trash/files folder.
If I delete files manually without using trash-put, I lose everything. What can I do, please?
12 réponses
Hello,
Normally you have a trash can, which corresponds to your folder ~/.local/share/Trash, where ~ denotes your home directory (e.g., /home/toto). In your file explorer (e.g., nautilus) you can directly access this folder via the URL trash:// Furthermore, it should be possible to add a trash can icon that opens this folder directly.
trash-cli is a command line trash can emulator (which is used instead of rm). As you can see here, it uses the same trash folder as your file explorer. You can therefore move items to the trash or empty the trash via your file explorer or via trash-cli as you wish, they are interchangeable. trash-cli has an advantage if you work in the command line, otherwise your file explorer is sufficient.
Good luck
Thank you for replying.
Actually, how do I get the Linux trash icon?
I have the trash icon on my Windows, but I would like to have it on my Ubuntu Linux virtual machine as well.
And I want that if I locally delete a file, it goes directly to trash/files because if I delete something, there’s nothing put in that folder despite the deletion (so the file is lost forever).
Hello,
As I explained to you in message #1, the trash on Linux is a special folder corresponding to the folder ~/.local/share/Trash, which also corresponds in your file explorer (nautilus, dolphin...) to the URL trash://.
So you just need to create a shortcut to this folder to have a trash icon. Have you tried creating this shortcut?
Then on Linux, there are two ways to delete:
- delete sends to the trash (therefore to ~/.local/share/Trash);
- shift+delete removes without going through the trash.
Good luck
Hi, I managed to create the trash icon on my desktop, thanks, but it doesn't solve my problem.
For example, in this photo, if I try to delete the nano directory, it shows me the following message:
Hello,
I think we're talking about two different things, because I see Windows windows. If I understood your question correctly, the goal is to have a trash can concept under Linux (in your virtual machine). However, in your screenshots, I see Windows windows. So unless those correspond to the folders in your virtual machine, we are not talking about the same thing. The folders I am referring to are located on the /home partition (of the virtual machine).
Can you clarify your question? What do you want to do? How did you install your virtual machine?
Yes, by default my computer runs Windows 10 and to install my virtual machine, I activated the Linux system on my Windows 10 and downloaded Ubuntu. So I can use Linux commands.
Yes, my question is about the trash in Linux on my virtual machine.
Yes, you are correct, the screenshot I showed you is located in my \\wsl.localhost\Ubuntu\home\Theo\.local\share\ and contains the items that are in the photo in my previous message.
I have my Windows trash and my Linux trash.
And the main purpose of my question is: why, when I manually delete something (like in the photo of my previous message), is the file or folder permanently deleted without going through the trash of my Linux virtual machine?
It's like under Windows, if you delete something, it goes straight to the trash, while under my virtual machine this is not the case. Do I need to make any specific configuration for my files/folders (that are in my Ubuntu (virtual machine)) that are deleted to go directly to my Linux trash?
Hello,
Okay, you’re on WSL, I understand better now, and that’s what I was starting to suspect.
On Linux:
- In text mode, the rm command does not go through the recycle bin; it’s a direct deletion. The only way to recreate the concept of a recycle bin is to use trash-cli. You can optionally create an alias in bash so that the rm command actually triggers trash-put.
- In a Linux file explorer (nautilus, konqueror, dolphin...), the del shortcut moves items to the recycle bin (equivalent to trash-put) while shift+del triggers a permanent deletion (equivalent to rm).
- Whether a file is sent to the recycle bin by trash-put or a file explorer in the VM, it will be placed in the recycle bin of the user who triggered the action. So in your VM, it will be in ~toto/.local/share/Trash.
By the definition of a VM, the file systems of the VM and the host machine are supposed to be independent. Therefore, the Linux recycle bin and the Windows recycle bin are also independent.
A VM can access the file system of the host machine and vice versa. However, this will not allow the Windows recycle bin to understand where a file deleted from the VM originated, thus preventing it from being restored if needed.
Good luck
Yes, I created an alias and when I run rm it puts it in the trash created by trash_cli
Okay, I see that since my file explorer is not on Linux, it doesn't work. Because if I press the Del key on my keyboard to delete something in my VM, it removes it permanently.
Nothing prevents you from installing a Linux file explorer in WSL, for example nautilus, and you should then have what you want. See this page.
Hello, actually I've tried everything but every time my Ubuntu displays: (org.gnome.Nautilus:38): Gtk-WARNING **: 09:26:55.244: cannot open display:
and yet I followed all the instructions from the link.
Hello,
According to this link, WSL for Windows 10 does not natively support displaying graphical applications. Windows 11 allows it through WSLg. According to this link, installing the driver associated with your GPU might unblock the situation, and that's what is suggested in the link I already provided you (see #9).
I can't tell you much more, I don't use WSL.
Good luck
Hello Theo_0055.
Thank you for your response. As a reminder, you can mark the topic as resolved. I'll take care of it.
Best wishes :-)