I am using Ubuntu in Win10, but I can not find the trash folder, even when I use the command
mv ~/.Trash/foo ~/
mv: cannot stat '/home/man/.Trash/foo': No such file or directory
My question is that how can I open trash folder in Ubuntu/Win10?
I am using Ubuntu in Win10, but I can not find the trash folder, even when I use the command
mv ~/.Trash/foo ~/
mv: cannot stat '/home/man/.Trash/foo': No such file or directory
My question is that how can I open trash folder in Ubuntu/Win10?
Trash is located in
~/.local/share/Trash
, at least in Ubuntu.~/.local
– or more precisely,~/.local/share
– is where XDG-compliant programs store user data (e.g., fonts, mail messages) according to the XDG Base Directory specification.Ubuntu on WSL only provides you with a terminal and no GUI by default.
Whenever a file is deleted from a graphical file manager in Ubuntu like Nautilus or Thunar, they are actually moved into
~/.local/share/Trash
. Files are usually deleted usingrm
from the terminal, which doesn't move them to the Trash folder.So there is no trash folder in WSL unless you use a Linux graphical file manager.
My WSL (Ubuntu-20.04) didn't have a ~/.local/share/Trash folder. I followed the instructions here (https://github.com/sindresorhus/trash) and installed
trash
andtrash-cli
withnpm
.Things like these work now!
Tip: https://github.com/tldr-pages/tldr is a really cool tool to get practical examples of commands that manual pages usually don't have.
The Trash folder in Ubuntu is typically provided by
gio
(Gnome IO) and GVfs (the Gnome Virtual Filesystem). While applications like Nautilus act on the GVfs to access the trash, it can also be done directly from the command-line on WSL or Ubuntu Server, without any GUI, using thegio
commandline tool.It does, however, require a D-Bus user session, which does not run automatically under WSL since there's (a) no Systemd and (b) no concept of "login" during which to start user services.
While
gio
and D-bus are both installed by default in the WSL Ubuntu distribution, you do need to add thegvfs
package (at least on WSL):Then you need to launch your shell with D-Bus support. This can be done multiple ways, but perhaps the best option is to change your WSL launch command (in Windows Terminal or elsewhere) to:
At this point, you can use the Trash from the WSL command line. Example: