We know that rm is generally used to delete files in Linux, but the rm command does not actually clear the contents of the data block that saves the file, instead, it only releases the index nodes and data blocks occupied by the file. Therefore, the files deleted with rm can be restored through some methods (such as debugfs and Google ). In some cases, we need to completely delete some files, which can be implemented using the shred command. shred is part of coreutils, so this command is basically used in Linux. Shred thoroughly
We know that rm is generally used to delete files in Linux, but the rm command does not actually clear the contents of the data block that saves the file, instead, it only releases the index nodes and data blocks occupied by the file. Therefore, the files deleted with rm can be restored through some methods (such as debugfs and Google ).
In some cases, we need to completely delete some files, which can be implemented using the shred command. shred is part of coreutils, so this command is basically used in Linux.
Shred:
$ Shred-u file
Shred will overwrite the node and data block where the file is located with some random content, and delete the file (-u parameter ).
If you want to clear it more thoroughly, you can add the-z parameter, which means to fill it with random data, and then fill it with 0.
$ Shred-u-z file
In addition, shred can also clear the entire partition or disk. for example, to completely clear the content of the/dev/sdb1 partition, you can do this:
$ Shred/dev/sdb1 (do not add the-u parameter)
Detailed shred parameters:
-F, -- force: change the permission to allow write (if necessary)
-N, -- iterations = N rewrite N times. The default value is 3 times.
-- Random-source = FILE: reads data from a specified FILE
-S, -- size = N to smash the file to a fixed size (suffixes such as K, M, and C can be used)
-U, -- remove rewrite and truncate and remove the file
-V, -- verbose shows the progress
-Z, -- zero-add overwrite data with 0
? Help show help
? Version: displays version information.