Delete files rather than trash them

As you probably know, to delete a file (or files) you can right-click it and select Move to the Deleted Items folder, or just drag it to the trash icon at the bottom right of the screen. The only problem with this is that the files stick around in the trash until you opt to empty it, and this can present security issues with sensitive data.

To genuinely delete a file, rather than trash it, select it and then type (Shi ft )+(De1 ete]. You can also add a Delete option to the menu that appears when you right-click a file by opening gconf-editor, heading over to /apps/nautilus/preferences and checking the enable_delete key. This will do the same thing—permanently delete the file.

At the present time it's not possible to deactivate ubuntu's trash function so that files are automatically genuinely deleted, no matter how you choose to delete them. To get around this you can create a simple script that empties the trash, and then make it run periodically as an hourly scheduled task (a personal cron job).

Start by creating a new file in Gedit called .emptytrash in your /home folder (bear in mind this file will be invisible because the filename is preceded with a period). Type the following into it: #!/bin/bash

# Empty the GNOME trash by deleting the two relevant folders rm -rf /home/username/.local/share/Trash/{files,info}/

The script works by deleting the two folders that contain and index the trash files within the GNOME desktop. Once the folders are deleted, new empty versions are automatically recreated by GNOME the next time the trash facility is used. A more elegant solution is possible, but this script has the benefit of being quick and thorough. Obviously, you should replace username with your own username. Then save the file, quit Gedit, open a terminal window and mark the new script as executable, as follows: $ chmod +x -/.emptytrash

Following this, add a job to your personal cron file by typing crontab -e. This will open your cron file in the nano text editor. use the cursor keys to select a new line at the bottom of the file and then type the following, which will cause the script to periodically run one minute past the hour while Ubuntu is up and running:

Again, you should replace username with your own username. once done, hit [Ctrl ]+[^ to quit nano, and type y and then hit [Enter] to save the buffer (save the file).

Note that Ubuntu's desktop trash icon might still indicate it's full even though it's been emptied in this way.

Was this article helpful?

0 0

Post a comment