{"id":4835,"date":"2018-06-13T22:37:31","date_gmt":"2018-06-13T18:37:31","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-sha1sum-command\/"},"modified":"2018-06-13T22:37:31","modified_gmt":"2018-06-13T18:37:31","slug":"linux-sha1sum-command-tutorial-for-beginners-with-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-sha1sum-command-tutorial-for-beginners-with-examples\/","title":{"rendered":"Linux sha1sum Command Tutorial for Beginners (with Examples)"},"content":{"rendered":"<p>Linux command line offers several tools for checking and verifying a file&#8217;s integrity. One such tool is <strong>sha1sum<\/strong>, which we will be discussing here in this tutorial using some easy to understand examples. But before we do that, it&#8217;s worth mentioning that all examples here have been tested on an Ubuntu 16.04 LTS machine.<\/p>\n<h2 id=\"linux-shasum-command\">Linux sha1sum command<\/h2>\n<p>The sha1sum command is used to compute and check SHA1 message digest. Following is its syntax:<\/p>\n<p class=\"command\">sha1sum [OPTION]&#8230; [FILE]&#8230;<\/p>\n<p>And here&#8217;s how the man page describes this tool:<\/p>\n<pre> Print or check SHA1 (160-bit) checksums.<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 With no FILE, or when FILE is -, read standard input.<\/pre>\n<p>Following are some Q&amp;A-styled examples that should give you a better idea on how this tool works.<\/p>\n<h2 id=\"q-how-to-use-shasum-command\">Q1. How to use sha1sum command?<\/h2>\n<p>Basic usage is fairly simple &#8211; just run the command with a filename as input.<\/p>\n<p>For example:<\/p>\n<p class=\"command\">sha1sum test.txt<\/p>\n<p>Here&#8217;s the output the above command produced on my system:<\/p>\n<p><a class=\"fancybox\" id=\"img-sha1sum-basic-usage\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/sha1sum-basic-usage.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples.png\" alt=\"How to use sha1sum command\" width=\"453\" height=\"36\" title=\"\"><\/a><\/p>\n<p>One the left is the message digest computed by the tool. Here&#8217;s how the output can be comprehended:<\/p>\n<pre> The default\u00a0 mode\u00a0 is to\u00a0 print\u00a0 a\u00a0 line with checksum, a space, a <br\/>character indicating input mode ('*' for binary, ' ' for text or <br\/>where binary\u00a0 is\u00a0 insignificant), and name for each FILE.<\/pre>\n<h2 id=\"q-how-to-use-shasum-to-verify-a-files-integrity\">Q2. How to use sha1sum to verify a file&#8217;s integrity?<\/h2>\n<p>For this, first save the message digest produced by the command in a .sha1 file. For example, here&#8217;s how we did it in our case:<\/p>\n<p class=\"command\">sha1sum test.txt &gt; test.sha1<\/p>\n<p>Now, with both test.txt and test.sha1 in the same directory, use the -c command line option to verify the file&#8217;s integrity.<\/p>\n<p class=\"command\">sha1sum -c test.sha1<\/p>\n<p>Here&#8217;s the output produced:<\/p>\n<p><a class=\"fancybox\" id=\"img-sha1sum-c-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/sha1sum-c-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples-1.png\" alt=\"How to use sha1sum to verify a file&#039;s integrity\" width=\"344\" height=\"34\" title=\"\"><\/a><\/p>\n<p>In case the check fails, the tool produces following output:<\/p>\n<p><a class=\"fancybox\" id=\"img-sha1sum-c-fail\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/sha1sum-c-fail.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples-2.png\" alt=\"sha1sum command result\" width=\"460\" height=\"54\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-force-shasum-to-read-file-in-binary-mode\">Q3. How to force sha1sum to read file in binary mode?<\/h2>\n<p>By default, the sha1sum command reads a file in text mode. However, you can force the tool to read in binary mode as well, something which you can do using the -b option.<\/p>\n<p class=\"command\">sha1sum -b [filename]\n<h2 id=\"q-what-all-suboptions-are-available-while-verifying-checksums\">Q4. What all sub-options are available while verifying checksums?<\/h2>\n<p>There are multiple preferences that you can set while verifying checksums using sha1sum. Here&#8217;s the list:<\/p>\n<pre readability=\"14\"><strong> --ignore-missing<\/strong><br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 don't fail or report status for missing files<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>--quiet<\/strong><br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 don't print OK for each successfully verified file<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>--status<\/strong><br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 don't output anything, status code shows success<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>--strict<\/strong><br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit non-zero for improperly formatted checksum lines<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>-w, --warn<\/strong><br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 warn about improperly formatted checksum lines<\/p><\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>As you&#8217;d agree, the sha1sum utility doesn&#8217;t offer many features. Most of its command line options we have already discussed here. Once you&#8217;re done practicing these, head to the tool&#8217;s\u00a0<a href=\"https:\/\/linux.die.net\/man\/1\/sha1sum\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a> for more info.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Flinux-sha1sum-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-sha1sum-command%2F&amp;text=Linux+sha1sum+Command+Tutorial+for+Beginners+%28with+Examples%29&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples-4.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples-5.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-sha1sum-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-sha1sum-command-tutorial-for-beginners-with-examples-6.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linux command line offers several tools for checking and verifying a file&#8217;s integrity. One such tool is sha1sum, which we will be discussing here in this tutorial using some easy to understand examples. But before we do that, it&#8217;s worth mentioning that all examples here have been tested on an Ubuntu 16.04 LTS machine. Linux &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4835","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=4835"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4835\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=4835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=4835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=4835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}