I want to restrict my users on deleting files from trash. Also i dont want my users to delete files bypassing trash. Is there any way to do this?
We will change the attributes of the trashed files so only root can change it back and eventually delete then.
1) Edit /etc/rc.local to looks like this:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing # but desgua has changed it # to keep a copy of trashed files while [ "$var1" != "end" ] do sudo chattr +i /home/user_name/.local/share/Trash/files/* sleep 2 done exit 0
4) Make it executable.
sudo chmod +x /etc/rc.local
5) Reboot or logout and log back in.
ps-1: just to take it easy with the processor the attribute change is made every 2 seconds. You may change that as you like.
sudo chattr -i /home/user_name/.local/share/Trash/files/*
To disable bypassing trash.
1) Open gconf-editor.
2) Go to /apps/nautilus/preferences/enable_delete right click on it and "Set Mandatory".
We will mod keymap.
1) Create a file
2) Paste this and save:
keycode 119 = Delete BackSpace
obs.: use "xev" to check if you keyboard Del really is "keycode 119"
3) We sure don't want this file to be deleted, so:
sudo chattr +i ~/.Xmodmap
5) Reboot, logout or execute:
No, users will always be able to delete the files they own (modulo some complex ACL setups which are not feasible for a desktop).
The trash can in ubuntu is just a special subdirectory under the user's home folder, which by definition is owned by that user. Even if you change the file permissions, the user could change them back and then delete the file.
If you are trying to avoid data loss, a much better solution would be to set up automated backups - that way anything that did get deleted could be recovered.
I have not tested it thoroughly, but you should be able to do something like
Then you can move files to trash, but you can't view them there. But, of course, anyone can change the permissions back.
You have to restart your session/computer in order to apply this change.
desgua's answer covered all your requirements (and should be accepted answer, IMHO), but i think its important to highlight a few points:
My point is: no matter what to do, its the users files, its the user session, and they will be able to bypass any protection you do if they want (and know how) to. desgua's answer is amazing, but be aware that its cosmetic only, useful only if you have non-techinical users. Its meant to be a convenience rather than a true security measure.
Theres no true way to really achieve what you want unless you really change the whole distro in a very unusual way.
That said, why exatctly do you want this? For security or convenience? Isnt proper linux training to your users much better (and easier) than this?