Shred Linux command to delete remove files more securely - Basic Linux Command.

 

Step by step using Shred command to delete remove files more securely.

 

Securely remove files on Linux system with shred command. The shred command is used to shred Linux files so that the files cannot be recover. This article show the step by step process on remove file from the system using shred command.

 

Linux command name: shred

 

Command Description:

To remove files on Linux system so that the files cannot be recover.

Command type:

external command.

 

The Linux 'shred' command is used to remove/delete file and overwrite the specified FILE(s) repeatedly, in order to make it harder for even very expensive hardware probing to recover the data, for example:

 

How to remove/delete files more securely with ‘shred’?

 

[root@linux fedora]# shred -fuvz install.log

shred: install.log: pass 1/26 (random)...
shred: install.log: pass 2/26 (555555)...
shred: install.log: pass 3/26 (999999)...
shred: install.log: pass 4/26 (6db6db)...
shred: install.log: pass 5/26 (924924)...
shred: install.log: pass 6/26 (bbbbbb)...
shred: install.log: pass 7/26 (dddddd)...
shred: install.log: pass 8/26 (aaaaaa)...
shred: install.log: pass 9/26 (111111)...
shred: install.log: pass 10/26 (444444)...
shred: install.log: pass 11/26 (b6db6d)...
shred: install.log: pass 12/26 (ffffff)...
shred: install.log: pass 13/26 (random)...
shred: install.log: pass 14/26 (cccccc)...
shred: install.log: pass 15/26 (888888)...
shred: install.log: pass 16/26 (249249)...
shred: install.log: pass 17/26 (222222)...
shred: install.log: pass 18/26 (777777)...
shred: install.log: pass 19/26 (333333)...
shred: install.log: pass 20/26 (000000)...
shred: install.log: pass 21/26 (492492)...
shred: install.log: pass 22/26 (db6db6)...
shred: install.log: pass 23/26 (eeeeee)...
shred: install.log: pass 24/26 (666666)...
shred: install.log: pass 25/26 (random)...
shred: install.log: pass 26/26 (000000)...
shred: install.log: removing
shred: install.log: renamed to 00000000000
shred: 00000000000: renamed to 0000000000
shred: 0000000000: renamed to 000000000
shred: 000000000: renamed to 00000000
shred: 00000000: renamed to 0000000
shred: 0000000: renamed to 000000
shred: 000000: renamed to 00000
shred: 00000: renamed to 0000
shred: 0000: renamed to 000
shred: 000: renamed to 00
shred: 00: renamed to 0
shred: install.log: removed

 

The command above securely remove / delete the file called install.log. Use ls command to confirm the deletion.

 

How to remove or delete multiple files at one go more securely with ‘shred’?

 

[root@linux fedora]# shred -fuvz messages messages.1 secure secure.1 wtmp

shred: kambing.log: pass 1/26 (random)...

shred: kambing.log: pass 2/26 (924924)...

shred: kambing.log: pass 3/26 (555555)...

+

++

+++

 

The ' shred ' command also can be used to remove or delete the several file at once, in this example five files is deleted at one go.

 

How to securely remove or delete files that use metacharacter (character that mean something to the shell) as file name?

 

[root@linux fedora]# shred -fuvz ./*important*
shred: ./*important*: pass 1/26 (random)...
shred: ./*important*: pass 2/26 (492492)...
shred: ./*important*: pass 3/26 (000000)...
shred: ./*important*: pass 4/26 (cccccc)...
shred: ./*important*: pass 5/26 (249249)...
shred: ./*important*: pass 6/26 (777777)...
shred: ./*important*: pass 7/26 (111111)...
shred: ./*important*: pass 8/26 (bbbbbb)...
shred: ./*important*: pass 9/26 (b6db6d)...
shred: ./*important*: pass 10/26 (999999)...
shred: ./*important*: pass 11/26 (db6db6)...
shred: ./*important*: pass 12/26 (888888)...
shred: ./*important*: pass 13/26 (random)...
shred: ./*important*: pass 14/26 (ffffff)...
shred: ./*important*: pass 15/26 (444444)...
shred: ./*important*: pass 16/26 (333333)...
shred: ./*important*: pass 17/26 (dddddd)...
shred: ./*important*: pass 18/26 (eeeeee)...
shred: ./*important*: pass 19/26 (555555)...
shred: ./*important*: pass 20/26 (924924)...
shred: ./*important*: pass 21/26 (6db6db)...
shred: ./*important*: pass 22/26 (222222)...
shred: ./*important*: pass 23/26 (aaaaaa)...
shred: ./*important*: pass 24/26 (666666)...
shred: ./*important*: pass 25/26 (random)...
shred: ./*important*: pass 26/26 (000000)...
shred: ./*important*: removing
shred: ./*important*: renamed to ./00000000000
shred: ./00000000000: renamed to ./0000000000
shred: ./0000000000: renamed to ./000000000
shred: ./000000000: renamed to ./00000000
shred: ./00000000: renamed to ./0000000
shred: ./0000000: renamed to ./000000
shred: ./000000: renamed to ./00000
shred: ./00000: renamed to ./0000
shred: ./0000: renamed to ./000
shred: ./000: renamed to ./00
shred: ./00: renamed to ./0
shred: ./*important*: removed

 

In this example the shred command is used with the ( ./ ) remove or delete the "*important*" file securely.

 

[root@linux fedora]# shred -fuvz -- -file
shred: -file: pass 1/26 (random)...
shred: -file: pass 2/26 (db6db6)...
shred: -file: pass 3/26 (aaaaaa)...
shred: -file: pass 4/26 (6db6db)...
shred: -file: pass 5/26 (492492)...
shred: -file: pass 6/26 (b6db6d)...
shred: -file: pass 7/26 (eeeeee)...
shred: -file: pass 8/26 (bbbbbb)...
shred: -file: pass 9/26 (111111)...
shred: -file: pass 10/26 (888888)...
shred: -file: pass 11/26 (777777)...
shred: -file: pass 12/26 (cccccc)...
shred: -file: pass 13/26 (random)...
shred: -file: pass 14/26 (000000)...
shred: -file: pass 15/26 (444444)...
shred: -file: pass 16/26 (222222)...
shred: -file: pass 17/26 (333333)...
shred: -file: pass 18/26 (999999)...
shred: -file: pass 19/26 (555555)...
shred: -file: pass 20/26 (249249)...
shred: -file: pass 21/26 (666666)...
shred: -file: pass 22/26 (924924)...
shred: -file: pass 23/26 (dddddd)...
shred: -file: pass 24/26 (ffffff)...
shred: -file: pass 25/26 (random)...
shred: -file: pass 26/26 (000000)...
shred: -file: removing
shred: -file: renamed to 00000
shred: 00000: renamed to 0000
shred: 0000: renamed to 000
shred: 000: renamed to 00
shred: 00: renamed to 0
shred: -file: removed

 

In this example the shred command is used with the ( -- ) remove / delete the "-file" file securely.

 

[root@linux fedora]# shred -fuvz 'happy rock hacking.mp3'

shred: happy rock hacking.mp3: pass 1/26 (random)...
shred: happy rock hacking.mp3: pass 2/26 (222222)...
shred: happy rock hacking.mp3: pass 3/26 (666666)...
shred: happy rock hacking.mp3: pass 4/26 (dddddd)...
shred: happy rock hacking.mp3: pass 5/26 (492492)...
shred: happy rock hacking.mp3: pass 6/26 (999999)...
shred: happy rock hacking.mp3: pass 7/26 (6db6db)...
shred: happy rock hacking.mp3: pass 8/26 (555555)...
shred: happy rock hacking.mp3: pass 9/26 (000000)...
shred: happy rock hacking.mp3: pass 10/26 (111111)...
shred: happy rock hacking.mp3: pass 11/26 (bbbbbb)...
shred: happy rock hacking.mp3: pass 12/26 (aaaaaa)...
shred: happy rock hacking.mp3: pass 13/26 (random)...
shred: happy rock hacking.mp3: pass 14/26 (924924)...
shred: happy rock hacking.mp3: pass 15/26 (888888)...
shred: happy rock hacking.mp3: pass 16/26 (cccccc)...
shred: happy rock hacking.mp3: pass 17/26 (db6db6)...
shred: happy rock hacking.mp3: pass 18/26 (444444)...
shred: happy rock hacking.mp3: pass 19/26 (777777)...
shred: happy rock hacking.mp3: pass 20/26 (eeeeee)...
shred: happy rock hacking.mp3: pass 21/26 (b6db6d)...
shred: happy rock hacking.mp3: pass 22/26 (333333)...
shred: happy rock hacking.mp3: pass 23/26 (ffffff)...
shred: happy rock hacking.mp3: pass 24/26 (249249)...
shred: happy rock hacking.mp3: pass 25/26 (random)...
shred: happy rock hacking.mp3: pass 26/26 (000000)...
shred: happy rock hacking.mp3: removing
shred: happy rock hacking.mp3: renamed to 0000000000000000000000
shred: 0000000000000000000000: renamed to 000000000000000000000
shred: 000000000000000000000: renamed to 00000000000000000000
shred: 00000000000000000000: renamed to 0000000000000000000
shred: 0000000000000000000: renamed to 000000000000000000
shred: 000000000000000000: renamed to 00000000000000000
shred: 00000000000000000: renamed to 0000000000000000
shred: 0000000000000000: renamed to 000000000000000
shred: 000000000000000: renamed to 00000000000000
shred: 00000000000000: renamed to 0000000000000
shred: 0000000000000: renamed to 000000000000
shred: 000000000000: renamed to 00000000000
shred: 00000000000: renamed to 0000000000
shred: 0000000000: renamed to 000000000
shred: 000000000: renamed to 00000000
shred: 00000000: renamed to 0000000
shred: 0000000: renamed to 000000
shred: 000000: renamed to 00000
shred: 00000: renamed to 0000
shred: 0000: renamed to 000
shred: 000: renamed to 00
shred: 00: renamed to 0
shred: happy rock hacking.mp3: removed

 

Using ‘shred’ command to remove/delete file that contains a space or character which is used by the shell, put a single quotes around them or force it using the current directory sign ( ./ ) or used -- option.

 

How to remove or delete all files on floppy disk more securely with ‘shred’?

 

You might use the following command to erase all trace of the filesystem you'd created on the floppy disk in your first drive. The command may takes up to 20 minutes to erase a "1.44MB" (actually 1440 KiB) floppy.

 

[root@linux fedora]# shred --verbose /dev/fd0

 

How to remove or delete files on selected partition of the hard disk more securely with ‘shred’?

 

Similarly, to erase all data on a selected partition of your hard disk, you could give a command like this:

 

[root@linux fedora]# shred --verbose /dev/sda5

 

NOTE: An exit status of zero indicates success, and a nonzero value indicates failure.

 

The following are some of the flags and arguments that can be used with the 'shred' command:

 

Mandatory arguments to long options are mandatory for short options too.

-f, --force change permissions to allow writing if necessary

-n, --iterations=N Overwrite N times instead of the default (25)

-s, --size=N shred this many bytes (suffixes like K, M, G accepted)

-u, --remove truncate and remove file after overwriting

-v, --verbose show progress

-x, --exact do not round file sizes up to the next full block;

this is the default for non-regular files

-z, --zero add a final overwrite with zeros to hide shredding

shred standard output

--help display this help and exit

--version output version information and exit

 

Delete FILE(s) if --remove (-u) is specified. The default is not to remove the files because it is common to operate on device files like /dev/hda, and those files usually should not be removed. When operating on regular files, most people use the --remove option.

 

 

CAUTION: Note that shred relies on a very important assumption: that the filesystem overwrites data in place. This is the traditional way to do things, but many modern filesystem designs do not satisfy this assumption. The following are examples of filesystems on which shred is not effective:

 

* log-structured or journaled filesystems, such as those supplied with AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)

* filesystems that write redundant data and carry on even if some writes fail, such as RAID-based filesystems

* filesystems that make snapshots, such as Network Appliance's NFS server

* filesystems that cache in temporary locations, such as NFS version 3 clients

* compressed filesystems

 

In addition, file system backups and remote mirrors may contain copies of the file that cannot be removed, and that will allow a shredded file to be recovered later.

 

NAME

shred - delete a file securely, first overwriting it to hide its contents

Usage: shred [OPTIONS] FILE [...]

 

Need help or need more information use:

# info coreutils shred

# man shred

# shred --help

 

Step-by-step how to procedure above tested on:

Operating System: GNU/Linux Fedora Core 4

Kernel Name: Linux

Kernel Release: 2.6.11-1.1369_FC4

Kernel Version: #1 Thu Jun 2 22:55:56 EDT 2005

Machine Hardware: i686

Machine Processor: i686

Hardware Platform: i386

Shell: GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu)

Installation Type: Full Installation (Custom)

SELinux: Disable

 

Keywords: remove files, shred, using shred command, shred command, remove file, secure remove, delete file, shred files, linux shred file, files shreder, secure delete, delete files, remove linux file, delete linux file, shred linux files.

 

aaaaaaaaaaa