{"id":3285,"date":"2014-06-10T16:37:35","date_gmt":"2014-06-10T16:37:35","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2014\/06\/10\/history-command\/"},"modified":"2014-06-10T16:37:35","modified_gmt":"2014-06-10T16:37:35","slug":"history-command","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/","title":{"rendered":"The Linux history Command"},"content":{"rendered":"<p>The <em>history<\/em> command is used to display the list of previously typed commands. While the base command will list all previous commands used since the last clearing, it can also be tailored to display by the page or a certain number of commands.<\/p>\n<p><strong>Command: <\/strong>history<br \/> <strong>Synopsis: <\/strong>history [option]\n<p> <strong>Options: <\/strong> <\/p>\n<table class=\"article_table\">\n<tr>\n<th>Option<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>-c<\/td>\n<td>Clears the history log by deleting all entries.<\/td>\n<\/tr>\n<tr>\n<td>-d offset<\/td>\n<td>Deletes entry at the offset. For example: <em>history -d 8<\/em> will delete the entry at line 8 in the history log. All entries are then renumbered.<\/td>\n<\/tr>\n<\/table>\n<h2>Examples<\/h2>\n<p><strong>history<\/strong> &#8211; The base command lists all the commands that were previously entered.   <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">history<\/span>     1  (06\/10\/14) 13:43:41 clear     2  (06\/10\/14) 13:43:42 cd \/     3  (06\/10\/14) 13:43:47 ping google.com     4  (06\/10\/14) 13:43:56 tail -f \/var\/log\/messages     5  (06\/10\/14) 13:44:05 cd ..     6  (06\/10\/14) 13:44:11 cd \/home\/userna5     7  (06\/10\/14) 13:44:14 history     8  (06\/10\/14) 13:44:39 cd public_html     9  (06\/10\/14) 13:44:44 touch test.html    10  (06\/10\/14) 13:45:02 history   <\/pre>\n<\/p>\n<p><strong>history n<\/strong> &#8211; Using the base command plus n where n is the number of lines you want to display. Below is an example displaying the last 5 commands.   <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">history 5<\/span>     7  (06\/10\/14) 13:44:14 history     8  (06\/10\/14) 13:44:39 cd public_html     9  (06\/10\/14) 13:44:44 touch test.html    10  (06\/10\/14) 13:45:02 history    11  (06\/10\/14) 14:05:06 history 5   <\/pre>\n<\/p>\n<p><strong>history -d n<\/strong> &#8211; The delete offset command allows you to delete a specific command from the list. The number used in the command relates to the line number you want to delete. Below is an example where we delete the 9th line number. Notice that in the last history list that command is no longer present.   <\/p>\n<pre class=\"cli\"> #<span style=\"color:red\">history<\/span><br\/>     1  (06\/10\/14) 13:43:41 clear     2  (06\/10\/14) 13:43:42 cd \/     3  (06\/10\/14) 13:43:47 ping google.com     4  (06\/10\/14) 13:43:56 tail -f \/var\/log\/messages     5  (06\/10\/14) 13:44:05 cd ..     6  (06\/10\/14) 13:44:11 cd \/home\/userna5     7  (06\/10\/14) 13:44:14 history     8  (06\/10\/14) 13:44:39 cd public_html     9  (06\/10\/14) 13:44:44 touch test.html    10  (06\/10\/14) 13:45:02 history  # <span style=\"color:red\">history -d 9<\/span> # <span style=\"color:red\">history<\/span>     1  (06\/10\/14) 13:43:41 clear     2  (06\/10\/14) 13:43:42 cd \/     3  (06\/10\/14) 13:43:47 ping google.com     4  (06\/10\/14) 13:43:56 tail -f \/var\/log\/messages     5  (06\/10\/14) 13:44:05 cd ..     6  (06\/10\/14) 13:44:11 cd \/home\/userna5     7  (06\/10\/14) 13:44:14 history     8  (06\/10\/14) 13:44:39 cd public_html     9  (06\/10\/14) 13:45:02 history     10 (06\/10\/14) 14:16:38 history -d 9     11 (06\/10\/14) 14:17:07 history   <\/pre>\n<\/p>\n<p><strong>history -c<\/strong> &#8211; This command clears the history list.   <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">history -c<\/span> # <span style=\"color:red\">history<\/span>    1  (06\/10\/14) 14:21:04 history   <\/pre>\n<\/p>\n<p><strong>history | tail<\/strong> &#8211; This history command will list the last 10 commands used. Note that the character between <em>history<\/em> and <em>tail<\/em> is a pipe character, not a lowercase &#8216;L&#8217;.   <\/p>\n<pre class=\"cli\"><span style=\"color:red\">history | tail<\/span>    13  (06\/10\/14) 14:58:23 ls -l    14  (06\/10\/14) 14:58:27 clear    15  (06\/10\/14) 14:58:31 history    16  (06\/10\/14) 14:58:41 history | less    17  (06\/10\/14) 15:00:23 history | less    18  (06\/10\/14) 15:05:03 history | tail    19  (06\/10\/14) 15:12:51 clear    20  (06\/10\/14) 15:12:52 man pwd    21  (06\/10\/14) 15:13:03 man cd    22  (06\/10\/14) 15:16:36 history | tail   <\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The history command is used to display the list of previously typed commands. While the base command will list all previous commands used since the last clearing, it can also be tailored to display by the page or a certain number of commands. Command: history Synopsis: history [option] Options: Option Description -c Clears the history<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\"> Read More ><\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4308],"tags":[],"class_list":["post-3285","post","type-post","status-publish","format-standard","hentry","category-linux"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The Linux history Command | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn how to use the Linux history command.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Linux history Command | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Linux history command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-10T16:37:35+00:00\" \/>\n<meta name=\"author\" content=\"Scott Mitchell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Scott Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\"},\"author\":{\"name\":\"Scott Mitchell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\"},\"headline\":\"The Linux history Command\",\"datePublished\":\"2014-06-10T16:37:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\"},\"wordCount\":226,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\",\"name\":\"The Linux history Command | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2014-06-10T16:37:35+00:00\",\"description\":\"Learn how to use the Linux history command.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Linux history Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\",\"name\":\"Scott Mitchell\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Linux history Command | InMotion Hosting","description":"Learn how to use the Linux history command.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/","og_locale":"en_US","og_type":"article","og_title":"The Linux history Command | InMotion Hosting","og_description":"Learn how to use the Linux history command.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2014-06-10T16:37:35+00:00","author":"Scott Mitchell","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Scott Mitchell","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/"},"author":{"name":"Scott Mitchell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed"},"headline":"The Linux history Command","datePublished":"2014-06-10T16:37:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/"},"wordCount":226,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/","name":"The Linux history Command | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2014-06-10T16:37:35+00:00","description":"Learn how to use the Linux history command.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/history-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"The Linux history Command"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed","name":"Scott Mitchell","url":"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3285"}],"version-history":[{"count":0,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3285\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}