{"id":256945,"date":"2022-11-30T09:34:02","date_gmt":"2022-11-30T01:34:02","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=256945"},"modified":"2022-11-07T08:34:12","modified_gmt":"2022-11-07T00:34:12","slug":"linux-share-skill","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-share-skill.html","title":{"rendered":"\u5206\u4eab\u4e00\u6761history\u547d\u4ee4\u5c0f\u6280\u5de7"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u73b0\u5728\u719f\u7ec3\u4f7f\u7528Linux\u5df2\u7ecf\u6210\u4e3aIT\u4eba\u5458\u7684\u5fc5\u5907\u6280\u80fd\u4e86\uff0c\u5b66\u4f1a\u4e00\u4e9b\u4f7f\u7528\u5c0f\u6280\u5de7\uff0c\u80fd\u5e2e\u52a9\u60a8\u66f4\u597d\u7684\u4f7f\u7528Linux\u7cfb\u7edf\uff0c\u4eca\u5929\u5c31\u6765\u4ecb\u7ecd\u4e00\u756a\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u5728\u4f7f\u7528linux\u7ec8\u7aef\u6267\u884cbash\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u600e\u4e48\u6ca1\u6709\u65f6\u95f4\u6807\u8bc6\u5462\uff0c\u8fd9\u4ee5\u540e\u8fd8\u600e\u4e48\u67e5\u662f\u54ea\u5929\u6267\u884c\u4e86\u90a3\u6761\u547d\u4ee4\u5462\u3002\u8fd9\u4e2ahistory\u7684\u4f5c\u7528\u5c31\u662f\u5c06bash\u6267\u884c\u8fc7\u7684\u6240\u6709\u547d\u4ee4\u5b58\u50a8\u5230.bash_history\u6587\u4ef6\u4e2d\uff0c\u5e2e\u52a9\u590d\u67e5\u7528\u6237\u547d\u4ee4\u3002\u9ed8\u8ba4\u60c5\u51b5\u4f7f\u7528history\u786e\u5b9e\u662f\u4e0d\u4f1a\u8f93\u51fa\u547d\u4ee4\u6267\u884c\u7684\u65f6\u95f4\u548c\u65e5\u671f\uff0c\u5c3d\u7ba1\u8fd9\u4e2a\u547d\u4ee4\u8bb0\u5f55\u5f97\u5230\u65f6\u95f4\u3002\u8fd0\u884chistory\u547d\u4ee4\u7684\u65f6\u5019\uff0c\u4f1a\u68c0\u67e5\u4e00\u4e2aHISTIMEFORMAT\u7684\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u4e2a\u53d8\u91cf\u5236\u5b9a\u4e86\u600e\u4e48\u53bb\u683c\u5f0f\u5316\u8f93\u51fa\u8fd9\u4e2a\u547d\u4ee4\u4e2d\u5b58\u50a8\u7684\u65f6\u95f4\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u4e3anull\uff0c\u90a3\u5c31\u662f\u9ed8\u8ba4\u4e0d\u663e\u793a\u3002\u73b0\u5728\u4f7f\u7528strftime\u683c\u5f0f\u5316\u65f6\u95f4\uff0c\u6709\u4e09\u79cd\u65b9\u5f0f\uff1a<\/p>\n

\uff081\uff09\u4e34\u65f6\u8bbe\u7f6eHISTIMEFORMAT\u53d8\u91cf\uff0c\u5728\u4e0b\u6b21\u673a\u5668\u91cd\u542f\u524d\u751f\u6548<\/p>\n

# export HISTIMEFROMAT=\u2018%F %T\u2019<\/pre>\n

\uff082\uff09\u5c06\u53d8\u91cf\u6dfb\u52a0\u5230.bashrc\u6216\u8005.bash_profile\u6587\u4ef6\u4e2d\uff0c\u6c38\u4e45\u751f\u6548<\/p>\n

# echo echo'HISTTIMEFORMAT=\"%F %T \"'>>~\/.bashrc \u6216\u8005~\/.bash_profile\u5e76\u5237\u65b0\u751f\u6548 source ~\/.bashrc\u6587\u4ef6\u6216\u8005.\/bash_profile<\/pre>\n

\uff083\uff09\u5c06HISTIMEFORMAT\u53d8\u91cf\u6dfb\u52a0\u5230\/etc\/profile\u6587\u4ef6\u4e2d\uff0c\u6c38\u4e45\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548<\/p>\n

echo'HISTTIMEFORMAT=\"%F %T \"'>>~\/.bashrc\u7136\u540e\u751f\u6548source \/etc\/profile<\/pre>\n

\u6ce8\u610f\uff1a\u914d\u7f6e\u5b8c\uff0c\u5c31\u53d1\u73b0\u600e\u4e48\u65f6\u95f4\u90fd\u4e00\u6837\uff0c\u8fd9\u662f\u56e0\u4e3a\u663e\u793a\u7684\u662f\u4f60\u5934\u4e00\u6b21\u8bbe\u7f6e\u5b8c\u53c2\u6570\u7684\u65f6\u95f4\uff0c\u8fd9\u4e2a\u53d8\u91cf\u53ea\u5bf9\u8bbe\u7f6e\u540e\u7684\u65f6\u95f4\u6709\u6548\uff0c\u4ee5\u524d\u7684\u5c31\u7b97\u4e00\u6837\u7684\u65f6\u95f4\u4e86\uff01<\/p>\n

\u6211\u4eec\u5927\u5bb6\u5728\u73a9Linux\u65f6\u7ecf\u5e38\u4f1a\u7528\u5230history\u8fd9\u4e2a\u547d\u4ee4\uff0c\u8fd9\u4e2a\u547d\u4ee4\u9ed8\u8ba4\u53ef\u4ee5\u4fdd\u5b58\u7684\u547d\u4ee4\u6570\u662f1000,1000\u5bf9\u4e8e\u6211\u4eecLinux\u73a9\u5bb6\u6765\u8bf4\u5b9e\u5728\u662f\u592a\u5c11\u4e86\uff0c\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u8c03\u6574history\u7684\u4fdd\u5b58\u6761\u6570\u5462\uff1f<\/p>\n

\uff081\uff09\u67e5\u627eprofile\u6587\u4ef6<\/p>\n

history\u547d\u4ee4\u6700\u5927\u8bb0\u5f55\u6570\u7684\u8bbe\u7f6e\u8fd8\u5728profile\u6587\u4ef6\u4e2d\u3002\u4f7f\u7528\u547d\u4ee4cd \/etc\u8fdb\u5165etc\u6587\u4ef6<\/p>\n

\uff082\uff09vi profile<\/p>\n

\u5728profile\u6587\u4ef6\u4e2d\u627e\u5230\u914d\u7f6e\u9879HISTSIZE\uff0c\u9ed8\u8ba4\u503c\u4e3a1000\uff0c\u6309\u4e0bi\u8fdb\u884c\u7f16\u8f91\uff0c\u7f16\u8f91\u4e3a10000\u751a\u81f3\u66f4\u591a\uff0c\u6309\u4e0b:wq,\u4fdd\u5b58\u9000\u51fa\uff0chistory\u7684\u6761\u6570\u8bbe\u7f6e\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u4f7f\u7528linux\u7ec8\u7aef\u6267\u884cbash\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u600e\u4e48\u6ca1\u6709\u65f6\u95f4\u6807\u8bc6\u5462\uff0c\u8fd9\u4ee5\u540e\u8fd8\u600e\u4e48\u67e5\u662f\u54ea\u5929\u6267\u884c\u4e86\u90a3\u6761\u547d\u4ee4\u5462\u3002\u8fd9\u4e2ahi […]<\/p>\n","protected":false},"author":310,"featured_media":256949,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-256945","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\/256945","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\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=256945"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256945\/revisions"}],"predecessor-version":[{"id":257073,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256945\/revisions\/257073"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/256949"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=256945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=256945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=256945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}