{"id":4078,"date":"2018-05-24T11:48:21","date_gmt":"2018-05-24T07:48:21","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-sum-command\/"},"modified":"2018-05-24T11:48:21","modified_gmt":"2018-05-24T07:48:21","slug":"linux-sum-command-tutorial-for-beginners-with-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-sum-command-tutorial-for-beginners-with-examples\/","title":{"rendered":"Linux sum Command Tutorial for Beginners (with Examples)"},"content":{"rendered":"<p>As you start spending more and more time working on the Linux command line, you tend to learn utilities that aren&#8217;t very frequently used. Once such tool is <strong>sum<\/strong>, which only offers two features: display checksum and block count for input files. In this short tutorial, we will quickly discuss the basics of sum using some easy to understand examples.<\/p>\n<p>But before we do that, it&#8217;s worth mentioning that all examples in this tutorial have been tested on an Ubuntu 16.04 LTS machine.<\/p>\n<h2 id=\"linux-sum-command\">Linux sum command<\/h2>\n<p>As already mentioned above, the sum command gives you information about file checksum and the number of blocks a file is comprised of. Following is its syntax:<\/p>\n<p class=\"command\">sum [OPTION]&#8230; [FILE]&#8230;<\/p>\n<p>And here&#8217;s how the tool&#8217;s man page defines it:<\/p>\n<pre>Print checksum and block counts for each FILE.<\/pre>\n<p>Following are some Q&amp;A-styled examples that should give you a good idea on how the tool works.<\/p>\n<h2 id=\"q-how-to-use-sum-command\">Q1. How to use sum command?<\/h2>\n<p>Basic usage is fairly easy &#8211; just pass an input file to the command. For example:<\/p>\n<p class=\"command\">sum file1<\/p>\n<p>And here&#8217;s the output the command produced on my system:<\/p>\n<pre>54333\u00a0\u00a0\u00a0\u00a0 1<\/pre>\n<p>The first entry is the checksum and the second one is the block count for the file<\/p>\n<h2 id=\"q-how-to-make-sum-accept-input-from-stdin\">Q2. How to make sum accept input from STDIN?<\/h2>\n<p>For this, all you have to do is to run the sum command without any input.<\/p>\n<p class=\"command\">sum<\/p>\n<p>As you press enter, the command will wait for you to provide input.<\/p>\n<p><a class=\"fancybox\" id=\"img-sum-stdin-1\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/sum-stdin-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/linux-sum-command-tutorial-for-beginners-with-examples.png\" alt=\"How to make sum accept input from STDIN\" width=\"196\" height=\"68\" title=\"\"><\/a><\/p>\n<p>Once the input file name is provided, just press ctrl+d, and you&#8217;ll get the output.<\/p>\n<p><a class=\"fancybox\" id=\"img-sum-stdin-2\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/sum-stdin-2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/linux-sum-command-tutorial-for-beginners-with-examples-1.png\" alt=\"sum command processes input file\" width=\"189\" height=\"80\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-change-algorithm-sum-uses\">Q3. How to change algorithm sum uses?<\/h2>\n<p>The tool offers two options: -r and -s. The former enables BSD sum algorithm, while the latter tells sum to use System V algo. Also, with -r, sum uses 1k block, while with -s, it uses 512 bytes blocks.<\/p>\n<p>Here&#8217;s an example:<\/p>\n<p><a class=\"fancybox\" id=\"img-sum-s-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/sum-s-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/linux-sum-command-tutorial-for-beginners-with-examples-2.png\" alt=\"How to change algorithm sum uses\" width=\"266\" height=\"53\" title=\"\"><\/a><\/p>\n<p><em>To know more about sum, you can use the standard &#8211;help and &#8211;version options. The former displays the complete help info, while the latter outputs the tool&#8217;s version information.<\/em><\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>As you would have observed, the sum command is very easy to understand and use &#8211; the learning curve is very low. We&#8217;ve discussed almost all command line option the tool offers. To learn more about Sum, head to its <a href=\"https:\/\/linux.die.net\/man\/1\/sum\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>.<\/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-sum-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/linux-sum-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-sum-command%2F&amp;text=Linux+sum+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\/05\/linux-sum-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\/05\/linux-sum-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-sum-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/linux-sum-command-tutorial-for-beginners-with-examples-6.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As you start spending more and more time working on the Linux command line, you tend to learn utilities that aren&#8217;t very frequently used. Once such tool is sum, which only offers two features: display checksum and block count for input files. In this short tutorial, we will quickly discuss the basics of sum using &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-4078","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4078","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=4078"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4078\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=4078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=4078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=4078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}