SHASUMS AND grep in verifying Ubuntu download

SHASUMS AND grep in verifying Ubuntu download



I'm trying to better understand the use of "SHA256SUMS" and "grep." The Ubuntu verify and authenticate tutorial uses the following term: "sha256sum -c SHA256SUMS 2>&1 | grep OK" to verify the download hasn't been corrupted.



I understand it's checking at the SHA256SUMS file that contains two hash values, one for the Desktop version and one for the Live. The usage worked, and I checked it by manually verifying the hash values.



My question is what is the "SHA256SUMS 2>&1" portion doing? Also, it appears to be a part of the "SHA256SUMS" command, though I don't see that usage on the man page I use. Then somehow the result is piped to "grep" to pattern-match with no options.



I'd like to understand it well enough to use the technique in verifying that other software downloads haven't been corrupted.






Related: What do these symbols “$@”>/dev/null 2>&1" after a command mean?

– steeldriver
Sep 8 '18 at 13:44






The command is sha256sum -c SHA256SUMS ; 2>&1 is a shell redirection that combines the command's standard error stream 2 with its standard output stream 1 so that both are piped to the grep command

– steeldriver
Sep 8 '18 at 13:47


sha256sum -c SHA256SUMS


2>&1


2


1


grep




1 Answer
1



The grep command is just there to clean up the output for you. The hash checker checks against all the disk images, so the grep command keeps things simple.


grep



With grep:

ubuntu-core-16-amd64.img.xz: OK



ubuntu-core-16-amd64.img.xz: OK



Without grep:

ubuntu-core-16-amd64.img.xz: OK
sha256sum: ubuntu-core-16-cm3.img.xz: No such file or directory
ubuntu-core-16-cm3.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-dragonboard-410c.img.xz: No such file or directory
ubuntu-core-16-dragonboard-410c.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-dragonboard.img.xz: No such file or directory
ubuntu-core-16-dragonboard.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-i386.img.xz: No such file or directory
ubuntu-core-16-i386.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-pi2.img.xz: No such file or directory
ubuntu-core-16-pi2.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-pi3.img.xz: No such file or directory
ubuntu-core-16-pi3.img.xz: FAILED open or read
sha256sum: WARNING: 6 listed files could not be read



ubuntu-core-16-amd64.img.xz: OK
sha256sum: ubuntu-core-16-cm3.img.xz: No such file or directory
ubuntu-core-16-cm3.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-dragonboard-410c.img.xz: No such file or directory
ubuntu-core-16-dragonboard-410c.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-dragonboard.img.xz: No such file or directory
ubuntu-core-16-dragonboard.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-i386.img.xz: No such file or directory
ubuntu-core-16-i386.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-pi2.img.xz: No such file or directory
ubuntu-core-16-pi2.img.xz: FAILED open or read
sha256sum: ubuntu-core-16-pi3.img.xz: No such file or directory
ubuntu-core-16-pi3.img.xz: FAILED open or read
sha256sum: WARNING: 6 listed files could not be read



Update:
Sorry, I missed the 2>&1 part of your question. That portion directs any error messages to the same place as the standard output messages. This page explains that quirky idiom: https://www.brianstorti.com/understanding-shell-script-idiom-redirect/


2>&1



Thanks for contributing an answer to Ask Ubuntu!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)