Skip to main content

Module 5: Disk & Storage

Lesson 52: shred Command

In this lesson, you'll learn how to use the shred command to securely overwrite and delete files in Linux.

The shred command overwrites a file to hide its contents, and can optionally delete it as well.

shred Command Syntax

$ shred [OPTIONS] FILE

shred Command Options

Option Description
-z Add a final overwrite with zeros to hide shredding
-v Enable display of operation progress
-u Truncate and remove the file after overwriting
-n N Specify the number of times to overwrite file content (default is 3)

1. Securely Overwrite and Delete a File

The following command securely overwrites and deletes a file called passwords.list with 5 passes of random data followed by a final zero overwrite.

$ shred -zvu -n 5 passwords.list
shred: passwords.list: pass 1/6 (random)...
shred: passwords.list: pass 2/6 (random)...
shred: passwords.list: pass 3/6 (random)...
shred: passwords.list: pass 4/6 (random)...
shred: passwords.list: pass 5/6 (random)...
shred: passwords.list: pass 6/6 (000000)...
shred: passwords.list: removing
shred: passwords.list: renamed to 00000000000000
shred: 00000000000000: renamed to 0000000000000
shred: 0000000000000: removed

In the command above, the options used are:

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’