17

Both Nautilus and Nemo create hidden folders called .Trash-1000 in any mounted device, apparently to manage their Trash folder. This is mighty confusing in network drives that are mounted by other users, that may be using other operating systems or programmes that do not recognise this folder as a trash bin.

Moreover, this folder expands with the number of files deleted and can not be erased from Ubuntu:

$ sudo rm -rf ./.Trash-1000
rm: cannot remove './.Trash-1000/files': Directory not empty

To free space in such mounted volumes the .Trash-1000 folder must be deleted from a different system.

Is there any way to prevent Nemo or Nautilus from creating this folder in network drives? I can naturally simply not use them, but they are handy in many situations.

Luís de Sousa
  • 13,227
  • 26
  • 81
  • 128
  • 1
    @LuísdeSousa Now, I've provided an answer as to current state of affairs, that is currently it is not possible to have such feature. However, I would ask you to remain patient for next week or so, and I might return with a better solution. OK ? – Sergiy Kolodyazhnyy Feb 25 '19 at 09:27
  • As a workaround, you can create an empty .Trash-1000 folder yourself, and use chmod 000 .Trash-1000 and/or sudo chattr +i .Trash-1000 to prevent Nautilus from populating it. (I haven't actually tried this, but I would if I had this problem.) – pts Feb 25 '19 at 10:50
  • pts this is similar to the traditional workaround on thumb drives - create an empty file (not folder) called .Trash-1000 this confuses gnome enough to stop it. – don bright Feb 26 '19 at 01:53
  • @pts This will keep other users confused about it. Moreover, in Samba drives Linux permissions have no meaning. – Luís de Sousa Feb 26 '19 at 07:35
  • @LuísdeSousa: For Samba shares, do the chmod or chattr on the Samba server (https://www.samba.org/). I undertstand that each solution and workaround has its tradeoffs. Nevertheless, it's better to know about a workaround and its tradeoff than not to know. Hence I posted it as a comment. – pts Feb 26 '19 at 08:20
  • @pts Your "work-around" requires access to the Samba server. That is not the case in my work domain. With NFS the problem is similar. – Luís de Sousa Feb 26 '19 at 11:00

2 Answers2

16

After looking at Nautilus's source code and Michael Stumpfl's answer it becomes clear that trash folder creation, is something hard-coded in Nautilus's source code itself and is part of how libgio works - the library behind file manipulations in Gtk/GNOME applications. Therefore disabling such behavior is currently not possible without recompiling either the file manager itself or altering source code of the library ( which I wouldn't recommend doing, since other applications rely on it, so changes may affect other applications' behavior ).

Probably the best solution is to propose a feature request to Nautilus developers and wait until it is fixed. One could also resort to permanent deletion of files via Shift+Delete short cut or using command-line utilities such as mv (move to user's trash folder on / filesystem) or rm. Otherwise - switch to using different file manager for the time being.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • 1
    If this is hard coded in libgio would it make a difference to use an alternative file manager? – Luís de Sousa Feb 25 '19 at 10:43
  • 5
    @LuísdeSousa Not every file manager relies on libgio. Dolphin for example doesn't. Command-line file manager such as midnight-commander doesn't. In general, those applications that don't rely on Gtk toolkit don't come in contact with libgio. Of course, there could be exceptions. – Sergiy Kolodyazhnyy Feb 25 '19 at 10:47
0

This doesn't prevent the creation of the .Trash folder but it's a simple way of dealing with your stated problem.

This may seem overly simple but just use globbing. As in: rm -rf .Trash-1000/*

the pattern (*) is expanded by the shell and rm will descend into and remove any files and directories whose name matches that pattern. It will not attempt to delete the .Trash-1000 folder but will remove './.Trash-1000/files'. Of course normal permissions apply.

`

Elder Geek
  • 36,023
  • 25
  • 98
  • 183