Skip to Content
gnux

sha256sumx

Print or check SHA-256 (256-bit) checksums.

Mirrors GNU sha256sum. Run it as sha256sumx, or as gnux sha256sumx.

Synopsis

sha256sumx [OPTION]... [FILE]...

GNU reference

Description

sha256sumx prints or checks SHA-256 message digests (FIPS 180-4, 256 bits). For each FILE it prints one line: the digest in hexadecimal, a space, a mode mark (a space for text mode, '*' with -b), and the file name. With no FILE, or when FILE is -, it reads standard input. Files are always read as bytes, so -b and -t change only the mark; when both are given, -t wins. --tag prints BSD-style lines instead ('ALGORITHM (FILE) = DIGEST'). A file name containing a backslash, newline or carriage return is escaped and its line starts with a backslash, unless -z ends lines with NUL instead. -c reads such lines (in either style) from the FILEs and checks each listed file, printing 'FILE: OK' or 'FILE: FAILED' and a summary warning of mismatches, unreadable files and improperly formatted lines; --quiet drops the OK lines, --status prints nothing, --ignore-missing skips listed files that do not exist, -w warns about each improperly formatted line and --strict fails because of them. The exit status is 0 when everything was read (and, with -c, matched), 1 otherwise. On Windows a backslash in a file name is the path separator, so it is not escaped as GNU escapes it on Unix; a name with a newline is still escaped.

Permissions

Needs read permission on each FILE (and, with -c, on the checksum lists and every file they name) and search permission on the directories leading to them. Nothing is ever modified. On a terminal, gnux's terminal view colors OK and FAILED in -c output and ends each list with a count ('3 OK, 1 FAILED'); piped or redirected output is exactly GNU's, and --pretty=never or GNUX_PRETTY=never turns it off.

Use cases

  • Verifying a download against the checksum its publisher lists.
  • Recording digests of release artifacts so users can check them.
  • Detecting whether files changed between two points in time.
  • Finding duplicate files by comparing their digests.
  • Checking a backup or a copy against the original.

Flags

  -b, --binary                   read in binary mode
  -c, --check                    read checksums from the FILEs and check them
      --help                     display this help and exit
      --ignore-missing           don't fail or report status for missing files
      --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
      --quiet                    don't print OK for each successfully verified file
      --status                   don't output anything, status code shows success
      --strict                   exit non-zero for improperly formatted checksum lines
      --tag                      create a BSD-style checksum
  -t, --text                     read in text mode (default)
      --theme NAME               color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
      --version                  output version information and exit
  -w, --warn                     warn about improperly formatted checksum lines
  -z, --zero                     end each output line with NUL, not newline, and disable file name escaping

Examples

You downloaded an installer: print its digest to compare with the one on the website

sha256sumx ubuntu-24.04-desktop-amd64.iso

Verify the download against the publisher's checksum file, which lists other files too

sha256sumx -c --ignore-missing sha256.sums
Output
ubuntu-24.04-desktop-amd64.iso: OK

Publish checksums next to your release archives

sha256sumx dist/*.tar.gz > dist/sha256.sums

Check that a backup copied to a USB drive still matches the original

sha256sumx photos.tar /media/usb/photos.tar

Find duplicate photos in a folder: files with the same digest have the same content

sha256sumx *.jpg | sortx | uniqx -w 64 -D

In CI, fail the build when a vendored file was changed by hand

sha256sumx -c --status vendor.sha256sums || { echox 'vendored files changed' >&2; exit 1; }

Re-check a large archive set and show only what no longer matches

sha256sumx -c --quiet sha256.sums
Output
notes.txt: FAILED
sha256sumx: WARNING: 1 computed checksum did NOT match

Hash a token from a variable, without the newline echo would add

printfx '%s' "$TOKEN" | sha256sumx

Write lines that name the algorithm, so a mixed list can be checked with cksumx -c

sha256sumx --tag release.tar.gz >> CHECKSUMS

Refuse a checksum list with malformed lines instead of skipping them

sha256sumx -c --strict -w sha256.sums

Match the '*' binary-mode lines produced by tools on Windows

sha256sumx -b setup.exe

Record a digest next to the file in the portable gnux shell, the same on every OS

gnux shell -c 'sha256sumx file.iso > file.iso.sha256sum'

Options

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

  • -b, --binary: Read in binary mode.
  • -c, --check: Read checksums from the FILEs and check them.
  • --ignore-missing: Don't fail or report status for missing files.
  • --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.
  • --quiet: Don't print OK for each successfully verified file.
  • --status: Don't output anything, status code shows success.
  • --strict: Exit non-zero for improperly formatted checksum lines.
  • --tag: Create a BSD-style checksum.
  • -t, --text: Read in text mode (default).
  • --theme: Color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default.
  • -w, --warn: Warn about improperly formatted checksum lines.
  • -z, --zero: End each output line with NUL, not newline, and disable file name escaping.

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

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

See also

On this page