\u5982\u679c\u4f60\u60f3\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u505c\u6b62\u8bb0\u5f55\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\uff1a<\/p>\n
$ set +o history<\/pre>\n\u5f53\u4f60\u8f93\u5165 history \u65f6\uff0c\u4f60\u8f93\u5165\u7684\u547d\u4ee4\u4e0d\u4f1a\u663e\u793a\u51fa\u6765\uff0c\u5f53\u4f60\u9000\u51fa\u4f1a\u8bdd\u6216\u9000\u51fa\u7ec8\u7aef\u65f6\uff0c\u5b83\u4eec\u4e5f\u4e0d\u4f1a\u88ab\u6dfb\u52a0\u5230\u4f60\u7684 .bash_history \u6587\u4ef6\u4e2d\u3002<\/p>\n
\u8981\u53d6\u6d88\u8fd9\u4e2a\u8bbe\u7f6e\uff0c\u4f7f\u7528 set -o history\u3002<\/p>\n
\u8981\u4f7f\u5b83\u6c38\u4e45\u5316\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u6dfb\u52a0\u5230\u4f60\u7684 .bashrc \u6587\u4ef6\u4e2d\uff0c\u5c3d\u7ba1\u4e0d\u4f7f\u7528\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u901a\u5e38\u4e0d\u662f\u4e00\u4e2a\u597d\u4e3b\u610f\u3002<\/p>\n
$ echo 'set +o history' >> ~\/.bashrc<\/pre>\n\u8981\u6682\u65f6\u6e05\u9664\u5386\u53f2\u8bb0\u5f55\uff0c\u8fd9\u6837\u5728\u8f93\u5165 history \u65f6\u53ea\u663e\u793a\u4e4b\u540e\u8f93\u5165\u7684\u547d\u4ee4\uff0c\u53ef\u4ee5\u4f7f\u7528 history -c\uff08\u6e05\u9664\uff09\u547d\u4ee4\uff1a<\/p>\n
$ history | tail -3\r\n209 uname -v\r\n210 date\r\n211 man chage\r\n$ history -c\r\n$ history\r\n1 history<\/pre>\n\u6ce8\u610f\uff1a\u5728\u8f93\u5165 history -c \u540e\u8f93\u5165\u7684\u547d\u4ee4\u4e0d\u4f1a\u88ab\u6dfb\u52a0\u5230 .bash_history \u6587\u4ef6\u4e2d\u3002<\/p>\n
\u63a7\u5236\u5386\u53f2<\/strong><\/div>\n\u8bb8\u591a\u7cfb\u7edf\u4e0a\u7684 history \u547d\u4ee4\u7684\u8bbe\u7f6e\u4f1a\u9ed8\u8ba4\u5305\u62ec\u4e00\u4e2a\u540d\u4e3a $HISTCONTROL \u7684\u53d8\u91cf\uff0c\u4ee5\u786e\u4fdd\u5373\u4f7f\u4f60\u8fde\u7eed\u8fd0\u884c\u540c\u4e00\u547d\u4ee4\u4e03\u6b21\uff0c\u4e5f\u53ea\u4f1a\u88ab\u8bb0\u4f4f\u4e00\u6b21\u3002\u5b83\u8fd8\u53ef\u4ee5\u786e\u4fdd\u4f60\u5728\u9996\u5148\u8f93\u5165\u4e00\u4e2a\u6216\u591a\u4e2a\u7a7a\u683c\u540e\u8ddf\u7740\u7684\u547d\u4ee4\u5c06\u4ece\u4f60\u7684\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u4e2d\u5ffd\u7565\u3002<\/p>\n
$ grep HISTCONTROL .bashrc\r\nHISTCONTROL=ignoreboth<\/pre>\nignoreboth \u7684\u610f\u601d\u662f\u201c\u5ffd\u7565\u91cd\u590d\u7684\u547d\u4ee4\u548c\u4ee5\u7a7a\u683c\u5f00\u5934\u7684\u547d\u4ee4\u201d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u8f93\u5165\u8fd9\u4e9b\u547d\u4ee4\uff1a<\/p>\n
$ echo try this\r\n$ date\r\n$ date\r\n$ date\r\n$ pwd\r\n$ history<\/pre>\n\u4f60\u7684 history \u547d\u4ee4\u5e94\u8be5\u50cf\u8fd9\u6837\u62a5\u544a\uff1a<\/p>\n
$ history\r\n$ echo try this\r\n$ date\r\n$ history<\/pre>\n\u8bf7\u6ce8\u610f\uff0c\u8fde\u7eed\u7684 date \u547d\u4ee4\u88ab\u7f29\u51cf\u4e3a\u4e00\u6761\uff0c\u4ee5\u7a7a\u683c\u7f29\u8fdb\u7684\u547d\u4ee4\u88ab\u7701\u7565\u3002<\/p>\n
\u5ffd\u7565\u5386\u53f2<\/strong><\/div>\n\u8981\u5ffd\u7565\u67d0\u4e9b\u547d\u4ee4\uff0c\u4f7f\u5b83\u4eec\u5728\u4f60\u8f93\u5165 history \u65f6\u4e0d\u4f1a\u51fa\u73b0\uff0c\u4e5f\u4e0d\u4f1a\u88ab\u6dfb\u52a0\u5230\u4f60\u7684 .bash_history \u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 $HISTIGNORE \u8bbe\u7f6e\u3002\u4f8b\u5982\uff1a<\/p>\n
$ export HISTIGNORE=\u201dhistory:cd:exit:ls:pwd:man\u201d<\/pre>\n\u8fd9\u4e2a\u8bbe\u7f6e\u5c06\u5bfc\u81f4\u6240\u6709\u7684 history\u3001cd\u3001exit\u3001ls\u3001pwd \u548c man \u547d\u4ee4\u4ece\u4f60\u7684 history \u547d\u4ee4\u7684\u8f93\u51fa\u548c .bash_history \u6587\u4ef6\u4e2d\u88ab\u5ffd\u7565\u3002<\/p>\n
\u5982\u679c\u4f60\u60f3\u628a\u8fd9\u4e2a\u8bbe\u7f6e\u53d8\u6210\u6c38\u4e45\u6027\u7684\uff0c\u4f60\u5fc5\u987b\u628a\u5b83\u6dfb\u52a0\u5230\u4f60\u7684 .bashrc \u6587\u4ef6\u4e2d\u3002<\/p>\n
$ echo 'HISTIGNORE=\"history:cd:exit:ls:pwd:man\"' >> .bashrc<\/pre>\n\u8fd9\u4e2a\u8bbe\u7f6e\u53ea\u662f\u610f\u5473\u7740\u5f53\u4f60\u56de\u770b\u4ee5\u524d\u8fd0\u884c\u7684\u547d\u4ee4\u65f6\uff0c\u5217\u8868\u4e0d\u4f1a\u88ab\u4f60\u5728\u67e5\u770b\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u65f6\u4e0d\u60f3\u770b\u5230\u7684\u547d\u4ee4\u6240\u5e72\u6270\u3002<\/p>\n
\u8bb0\u4f4f\u3001\u5ffd\u7565\u548c\u5fd8\u8bb0\u8fc7\u53bb\u7684\u547d\u4ee4<\/strong><\/div>\n\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u5f88\u6709\u7528\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8bb0\u4f4f\u6700\u8fd1\u4f7f\u7528\u8fc7\u7684\u547d\u4ee4\uff0c\u5e76\u63d0\u9192\u4f60\u6700\u8fd1\u6240\u505a\u7684\u66f4\u6539\u3002\u5b83\u8fd8\u53ef\u4ee5\u8ba9\u4f60\u66f4\u5bb9\u6613\u5730\u91cd\u65b0\u8fd0\u884c\u547d\u4ee4\uff0c\u7279\u522b\u662f\u90a3\u4e9b\u6709\u4e00\u4e32\u53c2\u6570\u4f46\u4f60\u4e0d\u4e00\u5b9a\u60f3\u91cd\u65b0\u521b\u5efa\u7684\u547d\u4ee4\u3002\u5b9a\u5236\u4f60\u7684\u5386\u53f2\u8bbe\u7f6e\u53ef\u4ee5\u8ba9\u4f60\u5bf9\u547d\u4ee4\u5386\u53f2\u7684\u4f7f\u7528\u53d8\u5f97\u66f4\u5bb9\u6613\uff0c\u66f4\u6709\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Linux \u7cfb\u7edf\u4e2d\u7684 bash history \u547d\u4ee4\u6709\u52a9\u4e8e\u8bb0\u4f4f\u4f60\u4ee5\u524d\u8fd0\u884c\u8fc7\u7684\u547d\u4ee4\uff0c\u5e76\u91cd\u590d\u8fd9\u4e9b\u547d\u4ee4\uff0c\u800c\u4e0d\u5fc5\u91cd\u65b0\u8f93 […]<\/p>\n","protected":false},"author":1469,"featured_media":201630,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-201626","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201626","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=201626"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201626\/revisions"}],"predecessor-version":[{"id":202042,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201626\/revisions\/202042"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/201630"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=201626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=201626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=201626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}