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.

Trash (or Wastebasket) is Empty in Thunar


Drag an item to the trash (or Wastebasket) to throw it away

Drag file to Trash (or Wastebasket) in Thunar


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

Trash (or Wastebasket) contains 1 File


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

Right-click and choose Delete


Or you may simply right-click the Trash (or Wastebasket) and choose Empty

Empty Trash (or Wastebasket) in Thunar


You’ll need to confirm this is what you want to do

Empty Trash (or Wastebasket) confirmation


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

Right-click a file and select Move to Trash (or Wastebasket)


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

Right-click to Delete a file (after confirmation) on the Desktop


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 > Preferences...

Click the Behavior (or Behaviour) tab

Behavior (or Behaviour) 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 (or Wastebasket) on Desktop, containing at least 1 file


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 (or Wastebasket) on the Desktop

Trash (or Wastebasket) on the Desktop check box


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

Trash (or Wastebasket) on the 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] key on the keyboard.

Confirm Deletion


Deleting a file any of the ways above doesn’t actually remove it from your computerit 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 Deletion


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 (do NOT use on SSD drives)


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 (do NOT use on SSD drives)

More Information | Delete See How to Delete a File in Ubuntu on Linux Hint, How to Remove Files & Directories in Ubuntu Linux on Orangeable, 8 Simple Ways to Securely Delete Files in Linux at Make Tech Easier, and How to Securely Delete Files in Linux at groovyPost.com More Information | Recover 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

One Way