{"id":68650,"date":"2022-11-15T09:02:13","date_gmt":"2022-11-15T09:02:13","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=68650"},"modified":"2022-11-15T09:02:13","modified_gmt":"2022-11-15T09:02:13","slug":"my-favorite-tricks-for-navigating-the-linux-terminal-faster","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=68650","title":{"rendered":"My favorite tricks for navigating the Linux terminal faster"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">My favorite tricks for navigating the Linux terminal faster<\/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\/anamika\" class=\"username\">Anamika<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Tue, 11\/15\/2022 &#8211; 03:00<\/span><\/p>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>One of the advantages of working in a terminal is that it&#8217;s faster than most other interfaces. Thanks to the <a href=\"https:\/\/tiswww.case.edu\/php\/chet\/readline\/rltop.html\" target=\"_blank\" rel=\"noopener\">GNU Readline<\/a>\u00a0library and the built-in syntax of shells like <a href=\"https:\/\/opensource.com\/downloads\/bash-cheat-sheet\" target=\"_blank\" rel=\"noopener\">Bash<\/a> and <a href=\"http:\/\/www.opensource.com\/article\/19\/9\/getting-started-zsh\" target=\"_blank\" rel=\"noopener\">Zsh<\/a>, there are several ways to make your interactions with the command line even faster. Here are five ways to make the most of your time in the terminal.<\/p>\n<h2>1. Navigate without the arrow keys<\/h2>\n<p>While executing commands on the command line, sometimes you miss a part at the beginning or forget to add certain tags or arguments toward the end. It&#8217;s common for users to use the <em>Left <\/em>and <em>Right arrow<\/em> keys on the keyboard to move through a command to make edits.<\/p>\n<p>There&#8217;s a better way to get around the command line. You can move the cursor to the beginning of the line with <strong>CTRL+A<\/strong>. Similarly, use <strong>CTRL+E<\/strong> to move the cursor to the end of the line. <strong>Alt+F<\/strong> moves one word forward, and <strong>Alt+B<\/strong> moves one word back.<\/p>\n<p><strong>Shortcuts:<\/strong><\/p>\n<ul>\n<li>Instead of\u00a0<em>Left arrow, left, left, left<\/em>, use\u00a0<strong>CTRL+A<\/strong> to go to the start of the line\u00a0or <strong>Alt+B<\/strong> to move back one word.<\/li>\n<li>Instead of\u00a0<em>Right arrow, right, right, right<\/em>, use\u00a0<strong>CTRL+E<\/strong> to move to the end of the line, or <strong>Alt+F<\/strong> to move forward a word.<\/li>\n<\/ul>\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>2. Don&#8217;t use the backspace or delete keys<\/h2>\n<p>It&#8217;s not uncommon to misspell commands. You might be used to using the <em>Backspace <\/em>key on the keyboard to delete characters in the backward direction and the <em>Delete <\/em>button to delete them in the forward direction. You can also do this task more efficiently and easily with some helpful keyboard shortcuts.<\/p>\n<p>Instead of deleting commands character by character, you can delete everything from the current cursor position to the beginning of the line or the end.<\/p>\n<p>Use <strong>CTRL+U<\/strong> to erase everything from the current cursor position to the beginning of the line. Similarly, <strong>CTRL+K<\/strong> erases everything from the current cursor position to the end of the line.<\/p>\n<p><strong>Shortcuts:<\/strong><\/p>\n<ul>\n<li>Instead of\u00a0<em>Backspace<\/em>, use\u00a0<strong>CTRL+U<\/strong>.<\/li>\n<li>Instead of\u00a0<em>Delete<\/em>, use\u00a0<strong>CTRL+K<\/strong>.<\/li>\n<\/ul>\n<p><drupal-entity data-embed-button=\"image_cta\" data-entity-embed-display=\"view_mode:cta.embed\" data-entity-type=\"cta\" data-entity-uuid=\"4cdb23e5-0af4-4121-8bc7-1f19bfb2ecc6\" data-langcode=\"en\" class=\"align-right\"><\/drupal-entity><\/p>\n<h2>3. Execute multiple commands in a single line<\/h2>\n<p>Sometimes it&#8217;s convenient to execute multiple commands in one go, letting a series of commands run while you step away from your computer or turn your attention to something else.<\/p>\n<p>For example, I love contributing to\u00a0open source, which means working with <a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-git\" target=\"_blank\" rel=\"noopener\">Git repositories<\/a>. I find myself running these three commands frequently:<\/p>\n<pre>\n<code class=\"language-shell\">$ git add\n$ git commit -m \"message\"\n$ git push origin main<\/code><\/pre>\n<p>Instead of running these commands in three different lines, I use a semi-colon (<code>;<\/code>) to concatenate them onto a single line and then execute them in sequence.<\/p>\n<p><strong>Shortcuts:<\/strong><\/p>\n<ul>\n<li>Instead of:\n<pre>\n<code class=\"language-shell\">$ git add .\n$ git commit -m \"message\"\n$ git push origin main<\/code><\/pre>\n<p>\tUse:<\/p>\n<pre>\n<code class=\"language-shell\">$ git add .;git commit -m \"message\";git push origin main<\/code><\/pre>\n<\/li>\n<\/ul>\n<ul>\n<li>Use the <code>;<\/code> symbol to concatenate and execute any number of commands in a single line. To stop the sequence of commands when one fails, use <code>&amp;&amp;<\/code> instead:\n<pre>\n<code class=\"language-shell\">$ git add . &amp;&amp; git commit -m \"message\" &amp;&amp; git push origin main<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>4. Alias frequently used commands<\/h2>\n<p>You probably run some commands often. Sometimes, these may be lengthy commands or a combination of different commands with the same arguments.<\/p>\n<p>To save myself from retyping these types of commands, I create an alias for the commands I use most frequently. For example, I often contribute to projects stored in a Git repository. Since I use the <code>git push origin main<\/code> command numerous times daily, I created an alias for it.<\/p>\n<p>To create an alias, open your <code>.bashrc<\/code> file in your favorite editor and add an alias:<\/p>\n<pre>\n<code class=\"language-plaintext\">alias gpom= \"git push origin main\"<\/code><\/pre>\n<p>Try creating an alias for anything you run regularly.<\/p>\n<p>Note: The <code>.bashrc<\/code> file is for users using the Bash shell. If your system runs a different shell, you probably need to adjust the configuration file you use and possibly the syntax of the alias command. You can check the name of the default shell in your system with the <code>echo $SHELL<\/code> command.<\/p>\n<p>After creating the alias, reload your configuration:<\/p>\n<pre>\n<code class=\"language-shell\">$ . ~\/.bashrc<\/code><\/pre>\n<p>And then try your new command:<\/p>\n<pre>\n<code class=\"language-shell\">$ gpom<\/code><\/pre>\n<p><strong>Shortcut:<\/strong><\/p>\n<p>Instead of typing the original command, such as:<\/p>\n<pre>\n<code class=\"language-shell\">$ git push origin main<\/code><\/pre>\n<p>Create an alias with the <code>alias<\/code> declaration in <code>.bashrc<\/code> or your shell&#8217;s configuration file.<\/p>\n<h2>5. Search and run a previous command without using the arrow keys<\/h2>\n<p>Most terminal users tend to reuse previously executed commands. You might have learned to use the <em>Up arrow<\/em> button on your keyboard to navigate your shell&#8217;s history. But when the command you want to reuse is several lines in the past, you must press the <em>Up arrow<\/em> repeatedly until you find the command you are looking for.<\/p>\n<p>Typically the situation goes like this:\u00a0<em>Up arrow, up, up, up. Oh, I found it!<\/em> <em>Enter<\/em>.<\/p>\n<p>There is an easier way:\u00a0You can search your history one step at a time using the <code>history<\/code> command.<\/p>\n<p>When you use the <code>history<\/code> command, the list of commands appears with a number beside each. These numbers are known as the <code>history-number<\/code> of the command. You can type <code>!{history-number}<\/code> on your terminal to run the command of the corresponding number.<\/p>\n<p><strong>Shortcuts:<\/strong><\/p>\n<ul>\n<li>Instead of\u00a0<em>Up arrow, up, up, up, Enter<\/em>,\u00a0type\u00a0<code>history<\/code>, and then look for the <code>history-number<\/code> of the command you want to run:\n<pre>\n<code class=\"language-shell\">$ !{history-number}<\/code><\/pre>\n<\/li>\n<\/ul>\n<ul>\n<li>You can also perform this task a different way: Instead of:\u00a0<em>Up arrow, up, up, up, Enter<\/em>, use\u00a0<strong>CTRL+R<\/strong> and type the first few letters of the command you want to repeat.<\/li>\n<\/ul>\n<h2>Command-line shortcuts<\/h2>\n<p>Shortcut keys provide an easier and quicker method of navigating and executing commands in the shell. Knowing the little tips and tricks can make your day less hectic and speed up your work on the command line.<\/p>\n<hr>\n<p><em>This article originally appeared on <a href=\"https:\/\/www.redhat.com\/sysadmin\/shortcuts-command-line-navigation?intcmp=7013a000002qLH8AAM\" target=\"_blank\" rel=\"noopener\">Red Hat Enable Sysadmin<\/a> and has been republished with the author&#8217;s permission.<\/em><\/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>Make your day less hectic and speed up your work on the Linux command line with these tips.<\/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\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/11\/terminal_command_linux_desktop_code.jpg\" width=\"520\" height=\"292\" alt=\"Terminal command prompt on orange background\" title=\"Terminal command prompt on orange background\"><\/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><a href=\"https:\/\/pixabay.com\/en\/users\/iradaturrahmat-3964359\/\" target=\"_blank\" rel=\"ugc noopener\">iradaturrahmat\u00a0<\/a>via <a href=\"https:\/\/pixabay.com\/en\/ubuntu-computer-program-interface-3145957\/\" target=\"_blank\" rel=\"ugc noopener\">Pixabay<\/a>, CC0<\/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<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/sysadmin\" hreflang=\"en\">Sysadmin<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/command-line\" hreflang=\"en\">Command line<\/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\/11\/cc-by-sa--21.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?destination=\/feed&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>My favorite tricks for navigating the Linux terminal faster Anamika Tue, 11\/15\/2022 &#8211; 03:00 One of the advantages of working in a terminal is that it&#8217;s faster than most other interfaces. Thanks to the GNU Readline\u00a0library and the built-in syntax of shells like Bash and Zsh, there are several ways to make your interactions with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":68651,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-68650","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\/68650","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=68650"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/68650\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/68651"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}