1

I could not see "Move to Trash" option on context menu, but only seeing "Delete" option that make the file completely removed (Are you sure you want to permanently delete “file.txt”?). I also tried chown/chmod on the files and folders that I am trying to move to trash. So, I can NOT remove files via Sublime Text 3 too.

If I do sudo nautilus and opening the file explorer then I can see "Move to Trash" option, but then can not see the file that I moved to trash using this option in "Trash".

E.g;

# kerem is superuser
sudo chown kerem:kerem /var/www/file.txt
sudo chmod 0777 /var/www/file.txt

Trash perms;

kerem@kerem:~/.local/share$ ls -la | grep Trash
drwx------  5 kerem kerem  4096 Ara 11 04:09 Trash

ubuntu-context-menu

Using 14.04 64bit, desktop version and /home and /var/www are on different partitions like sda1 and sda7 (both ext4 / -> /dev/sda6 and /home -> /dev/sda7). But no dual system alongside Ubuntu like Windows.

Thank you.

Kerem
  • 686
  • 9
  • 13
  • I'm assuming you're not running your file browser (eg nautilus) as superuser? What are the permissions and ownership of your home directory and your ~/.local/share/Trash directory? – thomasrutter Dec 11 '14 at 02:39
  • @neon_overload; kerem is root, so superuser. Also updated question, thanks. – Kerem Dec 11 '14 at 02:44
  • Not sure what you mean by that kerem is superuser - are you running nautilus (or whatever file browser you're using) as superuser? If so, why? And how - with sudo, or gksu, or some other way? – thomasrutter Dec 11 '14 at 03:02
  • @neon_overload; I updated my question, could you see it again please? – Kerem Dec 11 '14 at 11:45

2 Answers2

2

After wasting a few hours, here is the solution;

sudo -s
cd /

Work out your user account's id - it's usually 1000

getent passwd "username"

to get the UID and GID (for later use)

UID=$(getent passwd "username" | awk -F: '{print $3}')
GID=$(getent passwd "username" | awk -F: '{print $4}')

Make a new trash directory with the id we found above

mkdir .Trash-1000

Change the permissions of new directory to allow us to access it

chmod 777 .Trash-1000 && chown ${UID}:$GID .Trash-1000

Additionally, I can make a sym link into ~/.local/share/Trash to remember there is a trash more, so need to be emptied sometimes. :)

ln -s /.Trash-1000 ~/.local/share/Trash

Credits: https://askubuntu.com/a/516825/179045

waltinator
  • 36,399
Kerem
  • 686
  • 9
  • 13
  • Specifically, the Trash folder needs to be on the same partition as the files to be deleted, so they can be moved. So if /home is a separate partition, they need to go into /home, not / – Simon Richter Jun 27 '23 at 14:27
0

I had similar problem with Gnome Files.

For all folder and files in my home dir, Gnome Files shows Move to Trash in context menu. But for files/folder in another device the context menu shows Delete Permanently. For example, if folder /orange is mounted on a separate partition/disk then for all files/folders under it the Move to Trash is not enabled.

This is because Files auto creates Trash dir under $HOME/.local/share. However as there is no Trash for /orange mount point the Move to trash is not enabled for /orange. To overcome this create Trash folder for each user in /orange. If uid of user foo is 1000 then create /orange/.Trash-1000 and change its owner to foo.

sudo mkdir /orange/.Trash-1000
sudo chown foo:foo /orange/.Trash-1000

Now Move to Trash is enabled in context menu of all files/folders under /orange.