{"id":28977,"date":"2024-08-30T23:29:19","date_gmt":"2024-08-30T23:29:19","guid":{"rendered":"https:\/\/goodwriterz.com\/site\/?p=28977"},"modified":"2024-08-30T23:29:20","modified_gmt":"2024-08-30T23:29:20","slug":"how-to-use-the-history-command-on-linux","status":"publish","type":"post","link":"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/","title":{"rendered":"How to Use the history Command on Linux"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_68_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >\u062c\u062f\u0648\u0644 \u0627\u0644\u0645\u062d\u062a\u0648\u064a\u0627\u062a<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#What_is_Linux_Command_History_Used_For\" title=\"What is Linux Command History Used For?\">What is Linux Command History Used For?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#The_history_Command\" title=\"The history Command\">The history Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Repeating_Commands\" title=\"Repeating Commands\">Repeating Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Searching_for_Commands_by_String\" title=\"Searching for Commands by String\">Searching for Commands by String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Interactive_Search\" title=\"Interactive Search\">Interactive Search<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Modifying_the_Last_Command\" title=\"Modifying the Last Command\">Modifying the Last Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Deleting_Commands_from_the_History_List\" title=\"Deleting Commands from the History List\">Deleting Commands from the History List<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Manually_Updating_the_History_File\" title=\"Manually Updating the History File\">Manually Updating the History File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Clearing_the_History_List\" title=\"Clearing the History List\">Clearing the History List<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Security_and_the_History_File\" title=\"Security and the History File\">Security and the History File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#The_bashrc_File\" title=\"The .bashrc File\">The .bashrc File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/#Using_Timestamps\" title=\"Using Timestamps\">Using Timestamps<\/a><\/li><\/ul><\/nav><\/div>\n<div>\n<p> Linux&#8217;s shell saves a history of the commands you run, and you can search it to repeat commands you&#8217;ve run in the past. Once you understand the Linux history command and how to use it, it can significantly boost your productivity. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":0,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":0,\"nbrPlacementsScanned\":0,\"ruleCount\":200,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":240} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":1,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":1,\"nbrPlacementsScanned\":0,\"ruleCount\":200,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":200,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><br \/>\n<!-- No winning ad found for zone: below first paragraph! --><br \/>\n<!-- No winning ad found for zone: native in content! --><\/p>\n<h2 id=\"what-is-linux-command-history-used-for\"><span class=\"ez-toc-section\" id=\"What_is_Linux_Command_History_Used_For\"><\/span> What is Linux Command History Used For? <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> The Linux <code>history<\/code> command allows you to review and repeat your previous commands. This isn&#8217;t intended to just encourage laziness or save time\u2014there&#8217;s also an efficiency (and accuracy) factor at play. The lengthier and more complicated a command is, the harder it is to remember and type without making an error. There are two types of errors: one that prevents the command from working, and one that allows the command to work, but makes it do something unexpected. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":1,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":1,\"nbrPlacementsScanned\":1,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":481} --><\/p>\n<p> The <code>history<\/code> command eliminates those issues. Like most Linux commands, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/man7.org\/linux\/man-pages\/man1\/bash.1.html#HISTORY\">there&#8217;s more to it than you might think<\/a>. However, if you learn how to use the <code>history<\/code> command, it can improve your use of the Linux command line, every single day. It&#8217;s a good investment of your time. There are far better ways to use the <code>history<\/code> command than just hitting the Up arrow repeatedly. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":1,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":1,\"nbrPlacementsScanned\":1,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":858} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":1,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":1,\"nbrPlacementsScanned\":1,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":858} --><\/p>\n<h2 id=\"the-history-command\"><span class=\"ez-toc-section\" id=\"The_history_Command\"><\/span> The history Command <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> In its simplest form, you can use the <code>history<\/code> command by just typing its name: <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":1,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":1,\"nbrPlacementsScanned\":1,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":938} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":1,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<pre>history<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":9} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"history in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":249} --><\/p>\n<p> The list of previously used commands is then written to the terminal window. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":327} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"382\" loading=\"lazy\" alt=\"Output from history in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_307_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_307_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C382&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":567} --><\/p>\n<p> The commands are numbered, with the most recently used (those with the highest numbers) at the end of the list. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":680} --><\/p>\n<p> To see a certain number of commands, you can pass a number to <code>history<\/code> on the command line. For example, to see the last 10 commands you&#8217;ve used, type the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":850} --><\/p>\n<pre>history 10<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":862} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":862,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":38,\"nextBlockCount\":240,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1102} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":2,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":2,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":2,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"262\" loading=\"lazy\" alt=\"history 10 in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_528_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_528_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C262&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":202} --><\/p>\n<p> You can achieve the same result if you pipe<code>history<\/code> through the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/man7.org\/linux\/man-pages\/man1\/tail.1.html\"><code>tail<\/code> command<\/a>. To do so, type the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":310} --><\/p>\n<pre>history | tail -n 10<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":332} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"262\" loading=\"lazy\" alt=\"history | tail -n 10 in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_354_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_354_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C262&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":572} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":572} --><\/p>\n<h2 id=\"repeating-commands\"><span class=\"ez-toc-section\" id=\"Repeating_Commands\"><\/span> Repeating Commands <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> If you want to reuse a command from the history list, type an exclamation point (!), and the number of the command with no spaces in-between. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":715} --><\/p>\n<p> For example, to repeat command number 37, you would type this command: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":787} --><\/p>\n<pre>!37<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":792} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":792,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":108,\"nextBlockCount\":240,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1032} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":3,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":3,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":3,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"132\" loading=\"lazy\" alt=\"!37 in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_778_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060546_778_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C132&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":132} --><\/p>\n<p> To repeat the last command, type two exclamation points, again, without spaces: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":213} --><\/p>\n<pre>!!<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":217} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"132\" loading=\"lazy\" alt=\"!! in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_822_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_822_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C132&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":457} --><\/p>\n<p> This can be useful when you issue a command and forget to use <code>sudo<\/code> . Type <code>sudo<\/code>, one space, the double exclamation points, and then hit Enter. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":600} --><\/p>\n<p> For the following example, we typed a command that requires <code>sudo<\/code>. Instead of retyping the whole line, we can save a bunch of keystrokes and just type <code>sudo !!<\/code>, as shown below: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":776} --><\/p>\n<pre>mv .\/my_script.sh \/usr\/local\/bin\/<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":811} --><\/p>\n<pre>sudo !!<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":820} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":820,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":80,\"nextBlockCount\":240,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1060} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":4,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":4,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":4,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"147\" loading=\"lazy\" alt=\"mv .\/my_script.sh \/usr\/local\/bin\/\u00a0 in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_664_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_664_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C147&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":160} --><\/p>\n<p> So, you can type the corresponding number from the list to repeat a command or use the double exclamation points to repeat the last command you used. However, what if you want to repeat the fifth or eighth command? <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":376} --><\/p>\n<p> You can use one exclamation point, a hyphen (-), and the number of any previous command (again, without spaces) to repeat it. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":503} --><\/p>\n<p> To repeat the 13th previous command, you would type the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":571} --><\/p>\n<pre>!-13<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":577} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"132\" loading=\"lazy\" alt=\"!-13 ina terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_418_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_418_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C132&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":817} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":817} --><\/p>\n<h2 id=\"searching-for-commands-by-string\"><span class=\"ez-toc-section\" id=\"Searching_for_Commands_by_String\"><\/span> Searching for Commands by String <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> To repeat the last command that starts with a particular string, you can type an exclamation point, and then the string with no spaces, and then hit Enter. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":5,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":5,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":974} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":5,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> For example, to repeat the last command that started with <code>sudo<\/code>, you would type this command: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":94} --><\/p>\n<pre>!sudo<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":101} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"358\" loading=\"lazy\" alt=\"!sudo in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_385_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060547_385_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C358&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":341} --><\/p>\n<p> There&#8217;s an element of danger in this, though. If the last command that started with <code>sudo<\/code> isn&#8217;t the one you think it is, you&#8217;ll launch the wrong command. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":507} --><\/p>\n<p> To provide a safety net, though, you can use the <code>:p<\/code> (print) modifier, as shown below: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":594} --><\/p>\n<pre>!sudo:p<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":603} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"97\" loading=\"lazy\" alt=\"!sudo:p in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_412_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_412_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C97&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":843} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":843,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":57,\"nextBlockCount\":230,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1073} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":6,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":6,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":6,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<p> This instructs <code>history<\/code> to print the command to the terminal window, rather than executing it. This allows you to see the command before you use it. If it is the command you want, press the Up arrow, and then hit Enter to use it. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":173} --><\/p>\n<p> If you want to find a command that contains a particular string, you can use an exclamation point and question mark. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":291} --><\/p>\n<p> For example, to find and execute the first matching command that contains the word &#8220;aliases,&#8221; you would type this command: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":425} --><\/p>\n<pre>!?aliases<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":436} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"647\" height=\"262\" loading=\"lazy\" alt=\"!?aliases in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_705_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_705_How-to-Use-the-history-Command-on-Linux.png?resize=647%2C262&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":676} --><\/p>\n<p> This will find any command that contains the string &#8220;aliases,&#8221; regardless of where it appears in the string. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":796} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":796} --><\/p>\n<h2 id=\"interactive-search\"><span class=\"ez-toc-section\" id=\"Interactive_Search\"><\/span> Interactive Search <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> An interactive search allows you to hop through a list of matching commands and repeat the one you want. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":7,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":7,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":902} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":7,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> Just press Ctrl+r to start the search. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":40} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"Ctrl+R search started in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_997_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_997_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":280} --><\/p>\n<p> As you type the search clue, the first matching command will appear. The letters you type appear between the backtick (`) and the apostrophe (&#8216;). The matching commands update as you type each letter. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":485} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"Ctrl+R search with sudo entered as the search clue\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_483_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_483_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":725} --><\/p>\n<p> Each time you press Ctrl+r, you&#8217;re searching backward for the next matching command, which appears in the terminal window. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":853} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":853,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":47,\"nextBlockCount\":240,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1093} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":8,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":8,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":8,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"Ctrl+r search with a matching command in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_529_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060548_529_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":193} --><\/p>\n<p> When you press Enter, the displayed command will execute. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":252} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"647\" height=\"242\" loading=\"lazy\" alt=\"gedit launched by a Ctrl+r search command\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_26_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_26_How-to-Use-the-history-Command-on-Linux.png?resize=647%2C242&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":492} --><\/p>\n<p> To edit a command before you execute it, press either the Left or Right arrow key. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":576} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"Ctrl+r search in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_388_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_388_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":816} --><\/p>\n<p> The command appears on the command line, and you can edit it. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":879} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":879,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":21,\"nextBlockCount\":240,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1119} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":9,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":9,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":9,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"Command shown on the command line allowing editing\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_17_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_17_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":219} --><\/p>\n<p> You can use other Linux tools to search the history list. For example, to pipe the output from <code>history<\/code> into <code>grep<\/code> and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/man7.org\/linux\/man-pages\/man1\/grep.1.html\">search for commands that contain the string<\/a> &#8220;aliases&#8221; you could use this command: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":429} --><\/p>\n<pre>history | grep aliases<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":453} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"167\" loading=\"lazy\" alt=\"history | grep aliases in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_803_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060549_803_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C167&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":693} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":693} --><\/p>\n<h2 id=\"modifying-the-last-command\"><span class=\"ez-toc-section\" id=\"Modifying_the_Last_Command\"><\/span> Modifying the Last Command <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> If you need to fix a typo, and then repeat the command, you can use the caret (^) to modify it. This a great trick to have up your sleeve for whenever you misspell a command or want to rerun one with a different command-line option or parameter. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":10,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":10,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":940} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":10,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> To use it, type (without spaces) a caret, the text you want to replace, another caret, the text you want to replace it with, another caret, and then press Enter. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":163} --><\/p>\n<p> For example, suppose you type the following command, accidentally typing &#8220;shhd&#8221; instead of &#8220;sshd&#8221;: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":283} --><\/p>\n<pre>sudo systemctl start shhd<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":310} --><\/p>\n<p> You could correct this easily by typing the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":366} --><\/p>\n<pre>^shhd^sshd^<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":379} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"132\" loading=\"lazy\" alt=\"sudo systemctl start shhd in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060550_129_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060550_129_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C132&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":619} --><\/p>\n<p> The command is executed with &#8220;shhd&#8221; corrected to &#8220;sshd.&#8221; <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":697} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":697} --><\/p>\n<h2 id=\"deleting-commands-from-the-history-list\"><span class=\"ez-toc-section\" id=\"Deleting_Commands_from_the_History_List\"><\/span> Deleting Commands from the History List <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> You can also delete commands from the history list with the <code>-d<\/code> (delete) option. There&#8217;s no reason to keep your misspelled command in the history list. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":853} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":853,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":47,\"nextBlockCount\":140,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":993} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":11,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":11,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":11,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<p> You can use <code>grep<\/code> to find it, pass its number to <code>history<\/code> with the <code>-d<\/code> option to delete it, and then search again to make sure it&#8217;s gone: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":93} --><\/p>\n<pre>history | grep shhd<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":114} --><\/p>\n<pre>history -d 83<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":129} --><\/p>\n<pre>history | grep shhd<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":150} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"227\" loading=\"lazy\" alt=\"history | grep shhd in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060550_732_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060550_732_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C227&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":390} --><\/p>\n<p> You can also pass a range of commands to the <code>-d<\/code> option. To delete all list entries from 22 to 32 (inclusive), type this command: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":520} --><\/p>\n<pre>history -d 22 32<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":538} --><\/p>\n<p> To delete only the last five commands, you can type a negative number, like so: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":619} --><\/p>\n<pre>history -d -5<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":634} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":634} --><\/p>\n<h2 id=\"manually-updating-the-history-file\"><span class=\"ez-toc-section\" id=\"Manually_Updating_the_History_File\"><\/span> Manually Updating the History File <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> When you log in or open a terminal session, the history list is read in from the history file. In Bash, the default history file is <code>.bash_history<\/code>. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":782} --><\/p>\n<p> Any changes you make in your current terminal window session are only written to the history file when you close the terminal window or log out. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":12,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":12,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":928} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":12,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> Suppose you want to open another terminal window to access the full history list, including commands you typed in the first terminal window. The <code>-a<\/code> (all) option allows you to do this in the first terminal window before you open the second. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":241} --><\/p>\n<p> To use it, type the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":273} --><\/p>\n<pre>history -a<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":285} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"77\" loading=\"lazy\" alt=\"history -a in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_251_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_251_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C77&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":525} --><\/p>\n<p> The commands are written silently to the history file. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":581} --><\/p>\n<p> If you want to write all changes to the history list to the history file (if you deleted some old commands, for example), you can use the <code>-w<\/code> (write) option, like so: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":748} --><\/p>\n<pre>history -w<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":760} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"77\" loading=\"lazy\" alt=\"history -w in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_169_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_169_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C77&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":13,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":13,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":1000} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":13,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":0} --><\/p>\n<h2 id=\"clearing-the-history-list\"><span class=\"ez-toc-section\" id=\"Clearing_the_History_List\"><\/span> Clearing the History List <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> To clear all commands from the history list, you can use the <code>-c<\/code> (clear) option, as follows: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":93} --><\/p>\n<pre>history -c<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":105} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"122\" loading=\"lazy\" alt=\"history -c in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_391_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_391_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C122&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":345} --><\/p>\n<p> If you additionally want to force these changes to the history file, use the <code>-w<\/code> option, like so: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":443} --><\/p>\n<pre>history -w<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":455} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":455} --><\/p>\n<h2 id=\"security-and-the-history-file\"><span class=\"ez-toc-section\" id=\"Security_and_the_History_File\"><\/span> Security and the History File <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> If you use any applications that require you to type sensitive information (like passwords) on the command line, remember this will also be saved in the history file. If you don&#8217;t want certain information saved, you can use the following command structure to delete it from the history list immediately: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":764} --><\/p>\n<pre>special-app my-secret-password;history -d $(history 1)<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":820} --><\/p>\n<pre>history 5<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":831} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":831,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":69,\"nextBlockCount\":240,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1071} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":14,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":14,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":15,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":15,\"nbrPlacementsScanned\":14,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"227\" loading=\"lazy\" alt=\"special-app my-secret-password;history -d $(history 1) in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_150_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_150_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C227&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":15,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":15,\"nbrPlacementsScanned\":15,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":171} --><\/p>\n<p> This structure includes two commands separated with a semicolon (;). Let&#8217;s break this down: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":15,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":15,\"nbrPlacementsScanned\":15,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":268} --><\/p>\n<ul>\n<li><strong>special-app<\/strong>: The name of the program we&#8217;re using. <\/li>\n<li><strong>my-secret-password<\/strong>: The secret password we need to provide for the application on the command line. This is the end of command one. <\/li>\n<li><strong>history -d<\/strong>: In command two, we invoke the <code>-d<\/code> (delete) option of <code>history<\/code>. What we&#8217;re going to delete comes is in the next portion of the command. <\/li>\n<li><strong>$(history 1)<\/strong>: This uses a command substitution. The portion of the command contained in the <code>$()<\/code> is executed in a subshell. The result of that execution posts as text in the original command. The <code>history 1<\/code> command returns the previous command. So, you can think of the second command as history -d &#8220;last command here.&#8221; <\/li>\n<\/ul>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":15,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":15,\"nbrPlacementsScanned\":15,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":932} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":15,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> You can use the <code>history 5<\/code> command to make sure the command containing the password was removed from the history list. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":119} --><\/p>\n<p> There&#8217;s an even simpler way to do this, though. Because Bash ignores lines that begin with a space by default, just include a space at the start of the line, as follows: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":294} --><\/p>\n<pre> special-app another-password<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":325} --><\/p>\n<pre>history 5<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":336} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"212\" loading=\"lazy\" alt=\"special-app another-password in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_230_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060551_230_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C212&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":576} --><\/p>\n<p> The command with the password isn&#8217;t added to the history list. The reason this trick works is contained within the <code>.bashrc<\/code> file. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":710} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":710} --><\/p>\n<h2 id=\"the-bashrc-file\"><span class=\"ez-toc-section\" id=\"The_bashrc_File\"><\/span> The .bashrc File <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> The <code>.bashrc<\/code> file executes each time you log in or open a terminal window. It also contains some values that control the behavior of the <code>history<\/code> command. Let&#8217;s edit this file with <code>gedit<\/code>. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":16,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":16,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":901} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":16,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> Type the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":21} --><\/p>\n<pre>gedit .bashrc<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":36} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"57\" loading=\"lazy\" alt=\"gedit .bashrc in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_745_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_745_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C57&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":276} --><\/p>\n<p> Near the top of the file, you see two entries: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":324} --><\/p>\n<ul>\n<li><code><strong>HISTSIZE<\/strong><\/code><strong>:<\/strong> The maximum number of entries the history list can contain. <\/li>\n<li><strong><code>HISTFILESIZE<\/code> :<\/strong> The limit for the number of lines a history file can contain. <\/li>\n<\/ul>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":472} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"272\" loading=\"lazy\" alt=\".bashrc in the gedit editor\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_208_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_208_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C272&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":712} --><\/p>\n<p> These two values interact in the following ways: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":762} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":762,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":138,\"nextBlockCount\":521,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1283} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":17,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":17,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":18,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":18,\"nbrPlacementsScanned\":17,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<ul>\n<li> When you log in or start a terminal window session, the history list is populated from the <code>.bash_history<\/code> file. <\/li>\n<li> When you close a terminal window, the maximum number of commands set in <code>HISTSIZE<\/code> are saved to the <code>.bash_history<\/code> file. <\/li>\n<li> If the <code>histappend<\/code> shell option is enabled, the commands are appended to <code>.bash_history<\/code>. If <code>histappend<\/code> isn&#8217;t set, <code>.bash_history<\/code> is overwritten. <\/li>\n<li> After saving the commands from the history list to <code>.bash_history<\/code> , the history file is truncated to contain no more than <code>HISTFILESIZE<\/code> lines. <\/li>\n<\/ul>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":18,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":18,\"nbrPlacementsScanned\":18,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":383} --><\/p>\n<p> Also near the top of the file, you see an entry for the <code>HISTCONTROL<\/code> value. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":18,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":18,\"nbrPlacementsScanned\":18,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":459} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"252\" loading=\"lazy\" alt=\"HISTCONTROL entry n the .bashrc file in gedit\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_943_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_943_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C252&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":18,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":18,\"nbrPlacementsScanned\":18,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":699} --><\/p>\n<p> You can set this value to do any of the following: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":18,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":18,\"nbrPlacementsScanned\":18,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":751} --><\/p>\n<ul>\n<li><code><strong>ignorespaces<\/strong>:<\/code>Lines that begin with a space aren&#8217;t added to the history list. <\/li>\n<li><code><strong>ignoredups<\/strong>:<\/code>Duplicate commands aren&#8217;t added to the history file. <\/li>\n<li><code><strong>ignoreboth<\/strong>:<\/code>Enables both of the above. <\/li>\n<\/ul>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":18,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":18,\"nbrPlacementsScanned\":18,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":939} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":18,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> You can also list specific commands you don&#8217;t want added to your history list. Separate these with a colon (:) and put them in quotation marks (&#8220;&#8230;&#8221;). <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":167} --><\/p>\n<p> You would follow this structure to add a line to your <code>.bashrc<\/code> file, and substitute the commands you want to be ignored: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":288} --><\/p>\n<pre>export HISTIGNORE=\"ls:history\"<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":330} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"255\" loading=\"lazy\" alt=\"export HISTIGNORE=&quot;ls:history&quot; in gedit\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_944_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060552_944_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C255&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":570} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":570} --><\/p>\n<h2 id=\"using-timestamps\"><span class=\"ez-toc-section\" id=\"Using_Timestamps\"><\/span> Using Timestamps <span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p> If you want to add timestamps to the history list, you can use the <code>HISTIMEFORMAT<\/code> setting. To do so, you just add a line like the following to your <code>.bashrc<\/code> file: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":732} --><\/p>\n<pre>export HISTTIMEFORMAT=\"%c \"<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":771} --><\/p>\n<p> Note that there&#8217;s a space before the closing quotation marks. This prevents the timestamp from butting up to the commands in the command list. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":19,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":19,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":919} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":20,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":20,\"nbrPlacementsScanned\":19,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"255\" loading=\"lazy\" alt=\"export HISTTIMEFORMAT=&quot;%c &quot; in gedit\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_486_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_486_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C255&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":20,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":20,\"nbrPlacementsScanned\":20,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":240} --><\/p>\n<p> Now, when you run the history command, you see date- and timestamps. Note that any commands that were in the history list before you added the timestamps will be timestamped with the date and time of the first command that receives a timestamp. In this example shown below, this was command 118. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":20,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":20,\"nbrPlacementsScanned\":20,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":537} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"382\" loading=\"lazy\" alt=\"history listing with timestamps in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_453_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_453_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C382&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":20,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":20,\"nbrPlacementsScanned\":20,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":777} --><\/p>\n<p> That&#8217;s a very long-winded timestamp. However, you can use tokens other than <code>%c<\/code> to refine it. The other tokens you can use are: <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":20,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":20,\"nbrPlacementsScanned\":20,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":909} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":20,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<ul>\n<li><strong><code>%d<\/code>:<\/strong> Day <\/li>\n<li><strong><code>%m<\/code>:<\/strong> Month <\/li>\n<li><strong><code>%y<\/code>:<\/strong> Year <\/li>\n<li><strong><code>%H<\/code>:<\/strong> Hour <\/li>\n<li><strong><code>%M<\/code>:<\/strong> Minutes <\/li>\n<li><strong><code>%S<\/code>:<\/strong> Seconds <\/li>\n<li><strong><code>%F<\/code>:<\/strong> Full date (year-month-date format) <\/li>\n<li><strong><code>%T<\/code>:<\/strong> Time (hour:minutes:seconds format) <\/li>\n<li><code><strong>%c<\/strong><\/code><strong>:<\/strong> Complete date and time stamp (day-date-month-year, and hour:minutes:seconds formats) <\/li>\n<\/ul>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":228} --><\/p>\n<p> Let&#8217;s experiment and use a few different tokens: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":282} --><\/p>\n<pre>export HISTTIMEFORMAT=\"%d n%m %T \"<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":328} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"252\" loading=\"lazy\" alt=\"export HISTTIMEFORMAT=&quot;%d n%m %T &quot; in gedit\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_981_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_981_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C252&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":568} --><\/p>\n<p> The output uses the day, month, and time. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":611} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"382\" loading=\"lazy\" alt=\"history list with timestamps in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_441_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060553_441_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C382&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":851} --><\/p>\n<p> If we remove the day and month, though, it will just show the time. <\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":21,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":21,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":920} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":21,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":false,\"actualCount\":0} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":false,\"currentRuleCount\":900,\"actualCount\":0,\"hasActualCountMetThreshold\":null,\"countRemainingForInjection\":null,\"nextBlockCount\":null,\"hasCountRemainingForInjectionMetThreshold\":null} --><\/p>\n<p> Any changes you make to <code>HISTIMEFORMAT<\/code> apply themselves to the entire history list. This is possible because the time for each command is stored as the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Unix_time\">number of seconds from the Unix epoch<\/a>. The <code>HISTTIMEFORMAT <\/code>directive simply specifies the format used to render that number of seconds into a human-readable style, such as: <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":324} --><\/p>\n<pre>export HISTTIMEFORMAT=\"%T \"<\/pre>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":363} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"252\" loading=\"lazy\" alt=\"The &quot;export HISTTIMEFORMAT=&quot;%T&quot; command in gedit. \" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060554_922_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060554_922_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C252&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":603} --><\/p>\n<p> Our output is now more manageable. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":639} --><\/p>\n<div class=\"body-img landscape \">\n<div class=\"responsive-img image-expandable img-article-item\">\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" width=\"646\" height=\"262\" loading=\"lazy\" alt=\"history list with timestamps in a terminal window\" data-img-url=\"https:\/\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060554_0_How-to-Use-the-history-Command-on-Linux.png\" src=\"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/1725060554_0_How-to-Use-the-history-Command-on-Linux.png?resize=646%2C262&#038;ssl=1\" style=\"height:auto;max-width:100%\" title=\"\">  <\/figure>\n<\/p><\/div>\n<\/p><\/div>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":879} --><br \/>\n<!-- Repeatable debug data: {\"isEarlyInjection\":true,\"currentRuleCount\":900,\"actualCount\":879,\"hasActualCountMetThreshold\":true,\"countRemainingForInjection\":21,\"nextBlockCount\":161,\"hasCountRemainingForInjectionMetThreshold\":true,\"nextCount\":1040} --><\/p>\n<p><!-- Repeatable debug data: {\"injection\":\"before\",\"adPosition\":22,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":22,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":900} --><!-- Zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"after\",\"adPosition\":23,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":23,\"nbrPlacementsScanned\":22,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"isEarlyInjection\":true,\"actualCount\":0} --><\/p>\n<p> You can also use the <code>history<\/code> command to audit. Sometimes, reviewing commands you&#8217;ve used in the past can help you identify what might have caused an issue. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":23,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":23,\"nbrPlacementsScanned\":23,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":140} --><\/p>\n<p> Just as you can in life, on Linux, you can use the <code>history<\/code> command to relive the good times and learn from the bad. <\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":23,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":23,\"nbrPlacementsScanned\":23,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":257} --><\/p>\n<p><!-- No repeatable ad for zone: character count repeatable. --><!-- Repeatable debug data: {\"injection\":\"none\",\"adPosition\":23,\"startingPoint\":0,\"skipEvery\":null,\"nbrPlacementFilledEachSkip\":23,\"nbrPlacementsScanned\":23,\"ruleCount\":900,\"degradationStartingPoint\":1,\"stopAds\":null,\"actualCount\":577} --><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linux&#8217;s shell saves a history of the commands you run, and you can search it to repeat commands you&#8217;ve run in the past. Once you understand the Linux history command and how to use it, it can significantly boost your productivity. What is Linux Command History Used For? The Linux history command allows you to &#8230; <a title=\"How to Use the history Command on Linux\" class=\"read-more\" href=\"https:\/\/goodwriterz.com\/site\/how-to-use-the-history-command-on-linux\/\" aria-label=\"Read more about How to Use the history Command on Linux\">\u0625\u0642\u0631\u0623 \u0627\u0644\u0645\u0632\u064a\u062f<\/a><\/p>\n","protected":false},"author":1,"featured_media":28978,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[42,43],"class_list":["post-28977","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-desktop","tag-linux","tag-linux-macos-terminal"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/goodwriterz.com\/site\/wp-content\/uploads\/2024\/08\/How-to-Use-the-history-Command-on-Linux.jpg?fit=2100%2C1400&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/posts\/28977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/comments?post=28977"}],"version-history":[{"count":0,"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/posts\/28977\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/media\/28978"}],"wp:attachment":[{"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/media?parent=28977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/categories?post=28977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/goodwriterz.com\/site\/wp-json\/wp\/v2\/tags?post=28977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}