{"id":3485,"date":"2018-04-30T18:12:33","date_gmt":"2018-04-30T14:12:33","guid":{"rendered":"https:\/\/www.howtoforge.com\/clear-bash-history\/"},"modified":"2018-04-30T18:12:33","modified_gmt":"2018-04-30T14:12:33","slug":"how-to-clear-bash-history-on-linux","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-clear-bash-history-on-linux\/","title":{"rendered":"How to Clear Bash History on Linux"},"content":{"rendered":"<p>Sometimes you might want to hide the history of commands you typed in the shell on Linux. This is e.g. useful when you are building a server image to roll out multiple virtual machines. The command shown below will work on all Linux Distributions (CentOS, Debian, Ubuntu, etc).<\/p>\n<h2 id=\"clear-bash-history\">Clear Bash History<\/h2>\n<p>To clear the Bash History on Linux, use this combination of 3 commands:<\/p>\n<p class=\"command\">cat \/dev\/null &gt; ~\/.bash_history &amp;&amp; history -c &amp;&amp; exit<\/p>\n<p>What do these commands do?<\/p>\n<ul>\n<li>The &#8216;cat&#8217; command empties the .bash_history file of the currently logged in user.<\/li>\n<li>The &#8216;history -c&#8217; command cleans the history of the current user session.<\/li>\n<li>The &#8216;exit&#8217; command quits the current session.<\/li>\n<\/ul>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Fclear-bash-history%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-clear-bash-history-on-linux.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Fclear-bash-history%2F&amp;text=How+to+Clear+Bash+History+on+Linux&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-clear-bash-history-on-linux-1.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-clear-bash-history-on-linux-2.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Fclear-bash-history%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-clear-bash-history-on-linux-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you might want to hide the history of commands you typed in the shell on Linux. This is e.g. useful when you are building a server image to roll out multiple virtual machines. The command shown below will work on all Linux Distributions (CentOS, Debian, Ubuntu, etc). Clear Bash History To clear the Bash &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-3485","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=3485"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3485\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=3485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=3485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=3485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}