Skip to content

Delete Files

Brothers, I do not regard myself as yet having taken hold, but one thing I do. Forgetting the things which are behind, and reaching forward to the things which are ahead, I press on toward the goal for the prize of the high calling of God in Christ Jesus.

Phillippians 3:13-14 NHEB

Method 1: Command-Line

Delete any file or folder (you have permissions for) with the rm command
Open a Terminal [Ctrl]+[Alt]+[T] and type:
rm example
Delete multiple files
rm example1 example2
Use the * to delete all files with the same extension (like.txt)
rm /folder/*.txt
Delete a folder (directory) by adding -d
rm -d folder
Recursively delete a folder and everything inside by using -r
rm -r folder


Method 2: GUI

The Trash (or Wastebasket) should be visible in the File Manager (Thunar).

Trash in Thunar


Drag an item to the trash to throw it away

Drag file to Trash in Thunar


The icon changes here as well, to give you a visual reminder there is something (maybe several things) in the Trash

Trash in TYhunar


You may right-click individual files, several files, or all the files inside the Trash and choose Delete

Delete selection in drop-down menu


Or you may simply right-click the Trash and choose Empty Trash

Empty Trash in Thunar


You’ll need to confirm this is what you want to do (even when inside the Trash folder and deleting files separately)

Empty Trash confirmation


You may also right-click any file or folder (you have permissions for) and choose Move to Trash

Right-click a file and choose Move to Trash


On the Desktop, you’ll also have the option to choose to Delete a file (after confirmation) with a right-click

Delete a file (after confirmation) with a right-click


If you’d like that Delete function to be available to you elsewhere; from within Thunar, go to Edit > Preferences…

from within Thunar, go to Edit > Preferenc

Click the Behavior tab

Behavior tab


And at the bottom, under Context Menu, check the check box for Show action to permanently delete files and folders

Show action to permanently delete files and folders


The Trash (or Wastebasket) is not on the Desktop by default but you may easily change that

Trash on Desktop, Full


Simply right-click an empty spot on the Desktop and choose Desktop Settings…

Desktop Settings...


Then, click the Icons tab

Icons Tab


and click the check box to show the Trash on the Desktop

Trash on the Desktop check box


Right-click the Trash (or Wastebasket) and choose Empty Trash to permanently delete the items inside

Trash on Desktop


You may also skip the Trash (or Wastebasket) altogether by selecting the item(s) you’d like to remove, pressing and holding down the [Shift] key on the keyboard and tapping the [Delete] key. You’ll still need to confirm this is what you want to do by clicking the [Delete] button or pressing [Enter] on the keyboard.

Confirm Deletion


Deleting a file any of the ways above doesn’t actually remove it from your computer – it just removes the reference to the file – which is why it’s possible to recover files you may have accidentally deleted. It’s like removing a launcher (or shortcut). The file itself is still there, at least until it’s overwritten.

Secure Deletion purposely overwrites the file, usually several times, to make it much harder if not impossible to recover. There are many methods to accomplish this but the two below use software already on your C4C Ubuntu system.

Secure Delete


Securely Delete with dd
Securely delete a single file – provided you know the file size in bytes.

To find that out, open a Terminal [Ctrl]+[Alt]+[T] and type:
ls -l path/to/filename | awk '{print $5}'

Zero-out the data with:
dd status=progress bs=filesize-in-bytes count=1 if /dev/zero of=path/to/filename

Or, randomize the data with:
dd status=progress bs=filesize count=1 if /dev/urandom of=path/to/filename

And then delete the file with:
rm path/to/filename

Zero-out an entire HDD drive (do NOT use on SSD drives) by booting from C4C Ubuntu on USB, SD Card or DVD and issuing the following command where X = the drive you want to zero-out:
sudo dd if=/dev/zero of=/dev/sdX bs=1M

Use dd to zero-out an entire HDD drive


Securely Delete with shred
Securely delete a single file

To remove the file, display verbose information, replace the space with zeros with 3 deletion passes
Open a Terminal [Ctrl]+[Alt]+[T] and type:
shred -uvz n 2 path/to/filename

To do the same thing on every file in a folder, use the * wildcard:
shred -uvz n 2 path/to/folder/*.*

Shred an entire HDD drive (do NOT use on SSD drives) by booting from C4C Ubuntu on USB, SD Card or DVD and issuing the following command where X = the drive you want to zero-out:
sudo shred -vn 1 /dev/sdX

Shred an entire HDD drive

More Information See How to Delete a File in Ubuntu on Linux Hint and How to Remove Files & Directories in Ubuntu Linux on Orangeable. Recovery In case you’ve deleted something by accident, there is some hope you’ll be able to get it back. See 15 Linux Data Recovery ToolsDataRecoveryHow to Recover Deleted FilesPhotoRecPhotoRec TutorialRecover Damaged Memory CardSystemRescueCd and TestDisk. Also see 8 Simple Ways to Securely Delete Files in Linux at Make Tech Easier and How to Securely Delete Files in Linux at groovyPost.com