Skip to Content
gnux

shredx

Overwrite a file to hide its contents, and optionally delete it.

Mirrors GNU shred. Run it as shredx, or as gnux shredx.

Synopsis

shredx [OPTION]... FILE...

GNU reference

Description

shredx overwrites each FILE several times (3 unless -n says otherwise), so that its old contents are harder to recover, flushing each pass to disk. The passes mix random data with fixed bit patterns, as GNU shred chooses them; -z adds a last pass of zeros so that the shredding is less obvious. A regular file is overwritten up to the end of its last block (-x keeps to its exact size), and -s limits the overwriting to that many bytes. With -u (or --remove=wipesync) the file is then truncated, renamed to ever shorter names of zeros to hide its name too, and removed; --remove=wipe skips flushing the directory after each rename, and --remove=unlink removes the file without renaming it. -f makes a read-only file writable first. A FILE of - shreds standard output, which must be a file opened for reading and writing, not for appending. Random bytes come from the system's generator, or from --random-source; the order of the passes differs from GNU's run for run, as GNU's own does. CAUTION: on journaled, copy-on-write and log-structured file systems, on SSDs, and on anything with backups or snapshots, the old data may survive elsewhere; shredx cannot reach it.

gnux's terminal view (BR-13): when standard error is a terminal, -v draws each pass as one line rewritten in place, GNU's words followed by a bar, the percentage and the amount written of the size, five times a second, ending on 100%; the renaming and removal reports are GNU's lines. --pretty[=WHEN] and --theme=NAME, options of gnux's own, choose the view (GNUX_PRETTY, GNUX_THEME); --pretty=never, or standard error redirected, gives GNU's lines, one every five seconds.

Permissions

Needs write permission on each FILE (or ownership of it, with -f), and write permission on its directory to remove it. Overwrites the data in place: what it shreds cannot be recovered.

Use cases

  • Destroying a private key or a password file before giving a machine away.
  • Wiping a disk image or a USB stick device before reusing it.
  • Removing a file with sensitive contents more thoroughly than rmx does.

Flags

  -x, --exact                     do not round file sizes up to the next full block; this is the default for non-regular files
  -f, --force                     change permissions to allow writing if necessary
      --help                      display this help and exit
  -n, --iterations N              overwrite N times instead of the default (3)
      --pretty WHEN[="always"]    the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
      --random-source FILE        get random bytes from FILE
  -u, --remove HOW[="wipesync"]   deallocate and remove file after overwriting; -u is --remove=wipesync, and HOW may be unlink, wipe or wipesync
  -s, --size string               shred this many bytes (suffixes like K, M, G accepted)
      --theme NAME                color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
  -v, --verbose                   show progress
      --version                   output version information and exit
  -z, --zero                      add a final overwrite with zeros to hide shredding

Examples

Overwrite a secret file and delete it, showing each pass

shredx -v -u secrets.txt
Output
shredx: secrets.txt: pass 1/3 (random)...
shredx: secrets.txt: pass 2/3 (random)...
shredx: secrets.txt: pass 3/3 (random)...
shredx: secrets.txt: removing
shredx: secrets.txt: renamed to 00000000000
...
shredx: secrets.txt: removed

One random pass and then zeros, quicker for a large file

shredx -n 1 -z backup.img

Wipe a whole USB stick before reusing it (Linux)

sudo shredx -v -n 1 /dev/sdX

Shred a read-only key file

shredx -f -u id_ed25519

Shred every log file in a directory

findx logs -type f -name '*.log' -exec shredx -u {} +

Options

Each option has a page of its own, with its usage and examples.

  • -x, --exact: Do not round file sizes up to the next full block; this is the default for non-regular files.
  • -f, --force: Change permissions to allow writing if necessary.
  • -n, --iterations: Overwrite N times instead of the default (3).
  • --pretty: The gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default.
  • --random-source: Get random bytes from FILE.
  • -u, --remove: Deallocate and remove file after overwriting; -u is --remove=wipesync, and HOW may be unlink, wipe or wipesync.
  • -s, --size: Shred this many bytes (suffixes like K, M, G accepted).
  • --theme: Color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default.
  • -v, --verbose: Show progress.
  • -z, --zero: Add a final overwrite with zeros to hide shredding.

Exit status

StatusMeaning
0success: every operand was processed
1failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake

Help in the terminal

shredx --help                # options, first examples, exit status
gnux help shredx             # this page: the full manual
gnux help shredx --OPTION    # one option in depth, with its examples

See also

On this page