{"id":64785,"date":"2022-06-02T09:00:31","date_gmt":"2022-06-02T09:00:31","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=64785"},"modified":"2022-06-02T09:00:31","modified_gmt":"2022-06-02T09:00:31","slug":"the-only-linux-command-you-need-to-know","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=64785","title":{"rendered":"The only Linux command you need to know"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">The only Linux command you need to know<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/seth\" class=\"username\">Seth Kenlon<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Thu, 06\/02\/2022 &#8211; 03:00<\/span><\/p>\n<div data-drupal-selector=\"rate-node-70039\" class=\"rate-widget-thumbs-up\" title=\"Register or Login to like.\">\n<div class=\"rate-thumbs-up-btn-up vote-pending\">1 reader likes this<\/div>\n<div class=\"rate-score\">1 reader likes this<\/div>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>Information about Linux and open source abounds on the internet, but when you&#8217;re entrenched in your work there&#8217;s often a need for quick documentation. Since the early days of Unix, well before Linux even existed, there&#8217;s been the <code>man<\/code> (short for &#8220;manual&#8221;) and <code>info<\/code> commands, both of which display official project documentation about commands, configuration files, system calls, and more.<\/p>\n<p>There&#8217;s a debate over whether <code>man<\/code> and <code>info<\/code> pages are meant as helpful reminders for users who already know how to use a tool, or an intro for first time users. Either way, both <code>man<\/code> and <code>info<\/code> pages describe tools and how to use them, and rarely address specific tasks and how to accomplish them. It&#8217;s for that very reason that the <code>cheat<\/code> command was developed.<\/p>\n<p>For instance, suppose you can&#8217;t remember how to <a href=\"https:\/\/opensource.com\/article\/17\/7\/how-unzip-targz-file\">unarchive a tar file<\/a>. The <code>man<\/code> page provides you with all the options you require, but it leaves it up to you to translate this information into a functional command:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\"><span class=\"kw2\">tar<\/span> <span class=\"re5\">-A<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> ARCHIVE ARCHIVE<br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-c<\/span> <span class=\"br0\">[<\/span>-f ARCHIVE<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>FILE...<span class=\"br0\">]<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-d<\/span> <span class=\"br0\">[<\/span>-f ARCHIVE<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>FILE...<span class=\"br0\">]<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-t<\/span> <span class=\"br0\">[<\/span>-f ARCHIVE<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>MEMBER...<span class=\"br0\">]<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-r<\/span> <span class=\"br0\">[<\/span>-f ARCHIVE<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>FILE...<span class=\"br0\">]<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-u<\/span> <span class=\"br0\">[<\/span>-f ARCHIVE<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>FILE...<span class=\"br0\">]<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-x<\/span> <span class=\"br0\">[<\/span>-f ARCHIVE<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>OPTIONS<span class=\"br0\">]<\/span> <span class=\"br0\">[<\/span>MEMBER...<span class=\"br0\">]<\/span><\/div><\/div><\/pre>\n<p>That&#8217;s exactly what some users need, but it confounds other users. The cheat sheet for tar, by contrast, provides complete common commands:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ cheat <span class=\"kw2\">tar<\/span><br><br><span class=\"co0\"># To extract an uncompressed archive:<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xvf<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>foo.tar<br><br><span class=\"co0\"># To extract a .tar in specified Directory:<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xvf<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>foo.tar <span class=\"re5\">-C<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>destination<span class=\"sy0\">\/<\/span><br><br><span class=\"co0\"># To create an uncompressed archive:<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-cvf<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>foo.tar <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>foo<span class=\"sy0\">\/<\/span><br><br><span class=\"co0\"># To extract a .tgz or .tar.gz archive:<\/span><br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xzvf<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>foo.tgz<br><span class=\"kw2\">tar<\/span> <span class=\"re5\">-xzvf<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>foo.tar.gz<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span><\/div><\/div><\/pre>\n<p>It&#8217;s exactly what you need, when you need it.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">More Linux resources<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/linux-commands-cheat-sheet\/?intcmp=70160000000h1jYAAQ\">Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/advanced-linux-commands\/?intcmp=70160000000h1jYAAQ\">Advanced Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/rh024-red-hat-linux-technical-overview?intcmp=70160000000h1jYAAQ\">Free online course: RHEL technical overview<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-networking?intcmp=70160000000h1jYAAQ\">Linux networking cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-selinux?intcmp=70160000000h1jYAAQ\">SELinux cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/linux-common-commands-cheat-sheet?intcmp=70160000000h1jYAAQ\">Linux common commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/resources\/what-are-linux-containers?intcmp=70160000000h1jYAAQ\">What are Linux containers?<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux?intcmp=70160000000h1jYAAQ\">Our latest Linux articles<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>The Linux cheat command<\/h2>\n<p>The <code>cheat<\/code> command is a utility to search for and display a list of example tasks you might do with a Linux command. As with many Unix commands, there are different implementations of the same concept, including one <a href=\"https:\/\/github.com\/cheat\/cheat\">written in Go<\/a> and one, which I help maintain, <a href=\"https:\/\/gitlab.com\/slackermedia\/cheat\">written in just 100 lines of Bash<\/a>.<\/p>\n<p>To install the Go version, download <a href=\"https:\/\/github.com\/cheat\/cheat\/releases\">the latest release<\/a> and put it somewhere in <a href=\"https:\/\/opensource.com\/article\/17\/6\/set-path-linux\">your path<\/a>, such as <code>~\/.local\/bin\/<\/code> or <code>\/usr\/local\/bin<\/code>. To install the Bash version, download the latest release and run the <code>install-cheat.sh<\/code> script:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sh<\/span> .<span class=\"sy0\">\/<\/span>install-cheat.sh<\/code><\/span><\/pre>\n<p>Or to configure the installation, use <a href=\"https:\/\/opensource.com\/article\/19\/7\/introduction-gnu-autotools\">Autotools<\/a>:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">aclocal<\/span> ; <span class=\"kw2\">autoconf<\/span><br>\n$ <span class=\"kw2\">automake<\/span> <span class=\"re5\">--add-missing<\/span> ; autoreconf<br>\n$ .<span class=\"sy0\">\/<\/span>configure <span class=\"re5\">--prefix<\/span>=<span class=\"re1\">$HOME<\/span><span class=\"sy0\">\/<\/span>.local<br>\n$ <span class=\"kw2\">make<\/span><br>\n$ <span class=\"kw2\">make<\/span> <span class=\"kw2\">install<\/span><\/div><\/div><\/pre>\n<h2>Get cheat sheets for your Linux terminal<\/h2>\n<p>Cheat sheets are just plain text files containing common commands. The main collection of cheat sheets is available at <a href=\"https:\/\/github.com\/cheat\/cheatsheets\">Github.com\/cheat\/cheatsheets<\/a>. The Go version of cheat downloads cheatsheets for you when you first run the command. If you&#8217;re using the Bash version of cheat, the <code>--fetch<\/code> option downloads cheatsheets for you:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>cheat <span class=\"re5\">--fetch<\/span><\/code><\/span><\/pre>\n<p>As with <code>man<\/code> pages, you can have multiple collections of cheat sheets on your system. The Go version of cheat uses a <a href=\"https:\/\/opensource.com\/article\/21\/9\/yaml-cheat-sheet\">YAML<\/a> config file to define where each collection is located. The Bash version defines the path during the install, and by default downloads the <a href=\"https:\/\/github.com\/cheat\/cheatsheets\">Github.com\/cheat\/cheatsheets<\/a> collection as well as <a href=\"http:\/\/opensource.com\/\">Opensource.com<\/a>&#8216;s own <a href=\"https:\/\/gitlab.com\/opensource.com\/cheatsheets\">Gitlab.com\/opensource.com\/cheatsheets<\/a> collection.<\/p>\n<h2>List cheat sheets<\/h2>\n<p>To list the cheat sheets on your system, use the <code>--list<\/code> option:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ cheat <span class=\"re5\">--list<\/span><br>\n7z<br>\nab<br>\nacl<br><span class=\"kw3\">alias<\/span><br>\nansi<br>\nansible<br>\nansible-galaxy<br>\nansible-vault<br>\napk<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span><\/div><\/div><\/pre>\n<h2>View a Linux cheat sheet<\/h2>\n<p>Viewing a cheat sheet is as easy as viewing a <code>man<\/code> or <code>info<\/code> page. Just provide the name of the command you need help with:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ cheat <span class=\"kw3\">alias<\/span><br><br><span class=\"co0\"># To show a list of your current shell aliases:<\/span><br><span class=\"kw3\">alias<\/span><br><br><span class=\"co0\"># To alias `ls -l` to `ll`:<\/span><br><span class=\"kw3\">alias<\/span> <span class=\"re2\">ll<\/span>=<span class=\"st_h\">'ls -l'<\/span><\/div><\/div><\/pre>\n<p>By default, the <code>cheat<\/code> command uses your environment&#8217;s pager. Your pager is set with the <code>PAGER<\/code> <a href=\"https:\/\/opensource.com\/article\/19\/8\/what-are-environment-variables\">environment variable<\/a>. You can override that temporarily by redefining the <code>PAGER<\/code> variable before running the <code>cheat<\/code> command:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"re2\">PAGER<\/span>=most cheat <span class=\"kw2\">less<\/span><\/code><\/span><\/pre>\n<p>If you just want to <a href=\"https:\/\/opensource.com\/article\/19\/2\/getting-started-cat-command\">cat<\/a> the cheat sheet into your terminal without a pager, the Bash version has a <code>--cat<\/code> option for convenience:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>cheat <span class=\"re5\">--cat<\/span> <span class=\"kw2\">less<\/span><\/code><\/span><\/pre>\n<h2>It&#8217;s not actually cheating<\/h2>\n<p>The cheat system cuts to the chase. You don&#8217;t have to piece together clues about how to use a command. You just follow the examples. Of course, for complex commands, it&#8217;s not a shortcut for a thorough study of the actual documentation, but for quick reference, it&#8217;s as fast as it gets.<\/p>\n<p>You can even create your own cheat sheet just by placing a file in one of the cheat sheet collections. Good news! Because the projects are open source, you can contribute your personal cheat sheets to the GitHub collection. And more good news! When there&#8217;s a new Opensource.com <a href=\"https:\/\/opensource.com\/downloads\" target=\"_blank\" rel=\"noopener\">cheat sheet<\/a> release, we&#8217;ll include a plain text version from now on so you can add that to your collection.<\/p>\n<p>The command is called <code>cheat<\/code>, but as any Linux user will assure you, it&#8217;s not actually cheating. It&#8217;s working smarter, the open source way.<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>The Linux cheat command is a utility to search for and display a list of example tasks you might do with a command.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/command_line_prompt.png\" width=\"518\" height=\"292\" alt=\"Command line prompt\" title=\"Command line prompt\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>Opensource.com<\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux\" hreflang=\"en\">Linux<\/a><\/div>\n<\/p><\/div>\n<div class=\"hidden field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/cc-by-sa-4-2.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The only Linux command you need to know Seth Kenlon Thu, 06\/02\/2022 &#8211; 03:00 1 reader likes this 1 reader likes this Information about Linux and open source abounds on the internet, but when you&#8217;re entrenched in your work there&#8217;s often a need for quick documentation. Since the early days of Unix, well before Linux [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":64786,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-64785","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/64785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64785"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/64785\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/64786"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}