2

I am running a preinstalled version of ubuntu 18.04 but cannot find Trash folder. The typical places don't have the folder.

~/.local/share/Trash <-- does not exist
 /root/..../Trash <-- does not exit

The directory should most likely be here but it's not

 /home/$USER/.local/share/Trash  <---does not exist

Hmm ... so I ran a search as follows:

sudo find / -type d -iname Trash

The output was not nice:

find: ‘/run/user/1001/gvfs’: Permission denied
/home/$USER/.local/share/evolution/..../trash
/home/$USER/.cache/evolution/.../trash
/user/share/doc/HTML/.../trash

and that's it! By

...

I meant there are various directories ending with /trash. But that's useless to mention anyhow since we are not really finding the TRASH can.

(Note that I do see a Trash bin on my Desktop, which is ironic. And yes it is empty.)

Question is, where is my TRASH FOLDER ? And why do I receive the following output when I run the find command

find: ‘/run/user/1001/gvfs’: Permission denied
6
  • Try to delete some file, and see if they appear when you click on the Trash icon on desktop.
    – Prvt_Yadav
    Mar 16, 2019 at 16:16
  • I already did ffrom the Download folder .... and not sure where they end up. How to best trace them ? Grep ? or Find ? I don't see the deleted item in the desktop "Trash bin" ...
    – sam
    Mar 16, 2019 at 16:52
  • Adding now: I did the following "sudo find / -type d -iname deletedfile" and got as output find: ‘/run/user/1001/gvfs’: Permission denied
    – sam
    Mar 16, 2019 at 17:01
  • 1
    Use type -f instead of type -d, and then tell us.
    – Prvt_Yadav
    Mar 16, 2019 at 17:10
  • Just did and I get the same output as above.
    – sam
    Mar 16, 2019 at 18:57

3 Answers 3

4

The trash folder in your home directory is generated once a file from the same device that your home directory is stored on gets moved to the trash. In case you're deleting a file from another device, e.g. a different hard drive or USB stick, Ubuntu will use the (insert mountpoint)/Trash-(insert uid) directory. This is specified in FreeDesktop.org Trash Specification.

1
  1. Open terminal either via Ctrl+Alt+T shortcut key, or by searching for 'terminal' from app launcher.

  2. Run command to create and edit an empty file called trash.sh:

    gedit ~/Documents/trash.sh
    

    When the file opens, paste following lines and save it.

     #!/bin/bash
     icon=$HOME/.local/share/applications/trash.desktop
    
     while getopts "red" opt; do
       case $opt in
         r)
       if [ "$(gio list trash://)" ]; then
         echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon=user-trash-full\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$HOME/Documents/trash.sh -e'\n' > $icon
       fi
       ;;
         e)
       gio trash --empty && echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon=user-trash\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$HOME/Documents/trash.sh -e'\n' > $icon
       ;;
         d)
       while sleep 5; do ($HOME/Documents/trash.sh -r &) ; done
       ;;
       esac
     done
    
  3. Make the script file executable and run it via the 2 commands:

     my-machine:~$chmod +x ~/Documents/trash.sh
     my-machine:~./Documents/trash.sh -e
    
  4. Search for 'trash' in software launcher and select Add to Favorites in its context menu.

  5. Finally open Startup Applications, click Add to add a new startup app. In the modal in the Name field add trash icon and in the Command field add /home/YOUR_USER_NAME/Documents/trash.sh -d

  6. Reboot Ubuntu, and the trash can icon will change when it’s empty or not empty.

Reference: http://ubuntuhandbook.org/index.php/2018/08/add-trash-icon-dock-launcher-ubuntu-18-04/

-1

When trying to remove Trash's files, instead of doing:

rm -r /home/*/.local/share/Trash/files

I have done:

rm -r /home/*/.local/share/Trash

Then, the trash file disappeared when running:

ls /home/*/.local/share/Trash

As a result of that, I have done:

nano /home/*/Desktop/file

Then I have used the nautilus file manager in order to remove it by press on it and hit supr.

Finally, when I have done:

ls /home/*/.local/share/Trash/files

The created file was there !!

2
  • Please be extremely careful anytime you are running rm -r /home/*/... I presume that your intention is to do this for all users, perhaps as a cron job, but if so this should be pointed out very explicitly... Saying just do rm -r /home/*/anything is asking for trouble... Easy for a new user to read that without really understanding it and do some major self inflicted damage... Also, note that Linux doesn't really have a "Trash" folder quite the same was as Windows or Mac's do. Different apps, like in your case nautilus, may create a Trash folder on the device that your moving files from,
    – erwin
    Nov 23, 2021 at 11:25
  • 1
    @erwin I did not use /home/*/ , it just was a way to use any user (my user, your user, his user, her user... whatever) but thanks anyway !!
    – DBG
    Nov 24, 2021 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .