﻿{"id":7889,"date":"2021-05-20T18:45:33","date_gmt":"2021-05-20T10:45:33","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=7889"},"modified":"2021-05-20T18:48:38","modified_gmt":"2021-05-20T10:48:38","slug":"linux-bieming","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/linux-bieming.html","title":{"rendered":"Linux \u4e2d\u7684\u522b\u540d\u662f\u4ec0\u4e48\uff0c\u5982\u4f55\u4f7f\u7528\u548c\u521b\u5efa\u6c38\u4e45\u522b\u540d\uff1f"},"content":{"rendered":"<p>\u8f93\u5165\u6587\u672c\u548c\u8bb0\u547d\u4ee4\u662fLinux\u547d\u4ee4\u884c\u7231\u597d\u8005\u7684\u7f3a\u70b9\u4e4b\u4e00\u3002\u5982\u679c\u4f60\u9700\u8981\u8f93\u5165\u5e76\u8bb0\u4f4f\u540c\u6837\u957f\u7684\u547d\u4ee4\uff0c\u8fd9\u53ef\u80fd\u4f1a\u964d\u4f4e\u7ec8\u7aef\u7684\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<p>\u5982\u679c\u60a8\u53ef\u4ee5\u7528\u81ea\u5df1\u7684\u77ed\u540d\u79f0\u66ff\u6362\u957f\u547d\u4ee4\uff0c\u6216\u8005\u5c06\u591a\u4e2a\u547d\u4ee4\u5206\u7ec4\uff0c\u90a3\u4f1a\u600e\u4e48\u6837\u5462?\u662f\u7684\uff0calias\u662f\u4e00\u79cd\u53ef\u4ee5\u5e2e\u52a9\u60a8\u6709\u6548\u4f7f\u7528\u547d\u4ee4\u884c\u7684\u65b9\u6cd5\u3002<\/p>\n<h1><strong>\u522b\u540d(alias)\u5728Linux\u4e2d\u662f\u4ec0\u4e48\u610f\u601d\u5462?<\/strong><\/h1>\n<p>\u522b\u540d\u662f\u6307\u53e6\u4e00\u4e2a\u547d\u4ee4\u6216\u4e00\u7ec4\u547d\u4ee4\u7684\u66ff\u4ee3\u540d\u79f0\u3002\u5b83\u6709\u52a9\u4e8e\u4e3a\u957f\u65f6\u95f4\u8f93\u5165\u6216\u9700\u8981\u8bb0\u5fc6\u7684\u547d\u4ee4\u521b\u5efa\u5feb\u6377\u65b9\u5f0f\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u5e0c\u671b\u5c06\u672c\u5730\u76ee\u5f55\u4e0e\u8fdc\u7a0b\u76ee\u5f55\u540c\u6b65\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u3002<\/p>\n<p>$ rsync -a &lt;path-to-local-directory&gt; username@host:&lt;destination_directory&gt;<\/p>\n<p>\u4f46\u662f\u5982\u679c\u60a8\u7ecf\u5e38\u6267\u884c\u76ee\u5f55\u540c\u6b65\uff0c\u90a3\u4e48\u8f93\u5165\u8fd9\u4e48\u957f\u7684\u547d\u4ee4\u53ef\u80fd\u4f1a\u8ba9\u60a8\u611f\u5230\u538c\u70e6(\u9664\u975e\u60a8\u4f7f\u7528\u7684\u662f\u5177\u6709\u81ea\u52a8\u63d0\u793a\u529f\u80fd\u7684shell)\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u4e3a\u4e86\u7b80\u5316\u5e38\u89c4\u540c\u6b65\u4efb\u52a1\uff0c\u60a8\u53ef\u4ee5\u4e3arsync\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u522b\u540d\u3002<\/p>\n<p>$ alias remote=&#8221;rsync -a &lt;dir-path&gt; user@host:&lt;dir-path&gt;&#8221;<\/p>\n<p>\u4e0b\u6b21\u5f53\u4f60\u60f3\u8981\u5c06\u672c\u5730\u5185\u5bb9\u4f20\u8f93\u548c\u540c\u6b65\u5230\u8fdc\u7a0b\u7cfb\u7edf\u65f6\uff0c\u4f60\u53ef\u4ee5\u5728\u4f60\u7684\u7ec8\u7aef\u4e2d\u8f93\u5165\u201cremote\u201d\u3002<\/p>\n<p>\u6839\u636e\u53ef\u7528\u6027\uff0c\u522b\u540d\u6709\u4e24\u79cd\u7c7b\u578b:\u4e34\u65f6\u522b\u540d\u548c\u6c38\u4e45\u522b\u540d\u3002\u4e34\u65f6\u522b\u540d\u4ec5\u5bf9\u5f53\u524d\u7ec8\u7aef\u4f1a\u8bdd\u53ef\u7528\u3002\u4e00\u65e6\u60a8\u5173\u95ed\u7ec8\u7aef\uff0c\u60a8\u5c31\u4e0d\u80fd\u518d\u4f7f\u7528\u81ea\u5b9a\u4e49\u522b\u540d\u3002<\/p>\n<p>\u76f8\u53cd\uff0c\u5982\u679c\u60a8\u5728Linux\u4e2d\u521b\u5efa\u4e00\u4e2a\u6c38\u4e45\u7684\u522b\u540d\uff0c\u60a8\u53ef\u4ee5\u7acb\u5373\u5728\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\u4e2d\u4f7f\u7528\u5b83\uff0c\u751a\u81f3\u5728\u91cd\u65b0\u5f15\u5bfc\u540e\u4f7f\u7528\u5b83\u3002<\/p>\n<h1><strong>Linux\u4e0b\u5982\u4f55\u521b\u5efa\u548c\u4f7f\u7528\u522b\u540d?<\/strong><\/h1>\n<p>\u4f7f\u7528 alias \u547d\u4ee4\u81ea\u5b9a\u4e49\u522b\u540d\u7684\u8bed\u6cd5\u683c\u5f0f\u4e3a\uff1a<br \/>\nalias new_name=&#8217;value&#8217;<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u559c\u6b22\u4f7f\u7528exa\u5b9e\u7528\u7a0b\u5e8f\u6765\u5217\u51fa\u6587\u4ef6\uff0c\u4f46\u4ecd\u7136\u5e0c\u671b\u4f7f\u7528ls\u547d\u4ee4\uff0c\u5219\u53ef\u4ee5\u5c06\u201c lsa\u201d\u4f5c\u4e3a\u201c ls\u201d\u522b\u540d\uff0c\u5e76\u4f7f\u7528ls\u547d\u4ee4\u6253\u5370exa\u8f93\u51fa\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ alias ls=&#8217;exa -lh&#8217;<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ ls<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7890\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/05\/ls-exa.png\" alt=\"\" width=\"1572\" height=\"958\" \/><\/p>\n<p>\u4e00\u5728\u4f60\u521b\u5efa\u4e86\u8bb8\u591a\u522b\u540d\u540e\uff0c\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u5730\u8fd0\u884calias\u547d\u4ee4\u6765\u68c0\u67e5\u6216\u5217\u51fa\u5b83:<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ alias<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7890\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/05\/ls-exa.png\" alt=\"\" width=\"1572\" height=\"958\" \/><\/p>\n<p>\u4ee5\u540e\uff0c\u5982\u679c\u8981\u5220\u9664\u6216\u53d6\u6d88\u8bbe\u7f6e\u4efb\u4f55\u522b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528unalias\u547d\u4ee4\uff0c\u5e76\u5c06\u522b\u540d\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ unalias ls<\/p>\n<p>\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528unalias\u547d\u4ee4\u7684-a\u9009\u9879\u5220\u9664\u6240\u6709\u522b\u540d\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ unalias -a<\/p>\n<h1><strong>\u5982\u4f55\u5728Linux\u4e2d\u521b\u5efa\u6c38\u4e45\u522b\u540d\uff1f<\/strong><\/h1>\n<p>\u5728\u5173\u95ed\u7ec8\u7aef\u5e76\u91cd\u65b0\u5f15\u5bfc\u5230\u7cfb\u7edf\u540e\uff0c\u60a8\u662f\u5426\u4ecd\u8981\u4f7f\u7528\u522b\u540d\uff1f\u5982\u679c\u662f\uff0c\u5219\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6c38\u4e45\u522b\u540d\u3002<\/p>\n<p>\u4e3a\u6b64\uff0c\u60a8\u9700\u8981\u901a\u8fc7\u5728\u7f16\u8f91\u5668\u4e2d\u6253\u5f00\u522b\u540d\u6216\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u60a8\u7684\u522b\u540d\u653e\u5728~\/.bashrc\u6587\u4ef6\u4e2d\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ echo &#8220;alias up=&#8217;sudo apt update &amp;&amp; sudo apt upgrade'&#8221; &gt;&gt; ~\/.bashrc<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ source ~\/.bashrc<\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u4e0d\u662fbash shell\uff0c\u5219\u53ef\u80fd\u9700\u8981\u5728\u76f8\u5e94\u7684shell\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u522b\u540d\uff0c\u4f8b\u5982ZSH\u7684~\/.zshrc\u548cFish shell\u7684~\/.config\/fish\/config.fish\u3002<\/p>\n<p><strong>\u5c06\u522b\u540d\u5b58\u50a8\u5728\u5355\u72ec\u7684\u6587\u4ef6\u4e2d<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u5927\u91cf\u7684\u522b\u540d\uff0c\u6700\u597d\u4e3a\u5b83\u51c6\u5907\u4e00\u4e2a\u5355\u72ec\u7684\u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u5728\u4e3b\u76ee\u5f55\u4e2d\u521b\u5efabash_aliases\u70b9\u6587\u4ef6\uff0c\u5e76\u5c06\u6240\u6709\u522b\u540d\u653e\u5728\u6b64\u5904\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ touch ~\/.bash_aliases<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7893 size-full\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/05\/alias-2.png\" alt=\"\" width=\"1572\" height=\"418\" \/><\/p>\n<p>#\u5728\u4e0a\u9762\u7684\u6587\u4ef6\u4e2d\u6dfb\u52a0\u522b\u540d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7892\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/05\/alias-1.png\" alt=\"\" width=\"1572\" height=\"562\" \/><\/p>\n<p>\u5c06\u522b\u540d\u6dfb\u52a0\u5230\u201c bash_aliases\u201d\u6587\u4ef6\u540e\uff0c\u8fd8\u9700\u8981\u5728\u301c\/.bashrc\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n<p>if [ -e ~\/.bash_aliases ]; then<br \/>\nsource ~\/.bash_aliases<br \/>\nfi<\/p>\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n<p>\u522b\u540d\u53ef\u4ee5\u5c06\u4e00\u4e9b\u590d\u6742\u7684\u547d\u4ee4\u7b80\u5316\u6210\u4e00\u4e2a\u6211\u4eec\u81ea\u5df1\u547d\u540d\u7684\u76f8\u5bf9\u7b80\u5355\u597d\u8bb0\u7684\u547d\u4ee4\uff0c\u80fd\u591f\u6781\u5176\u65b9\u4fbf\u6211\u4eec\u7684\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f93\u5165\u6587\u672c\u548c\u8bb0\u547d\u4ee4\u662fLinux\u547d\u4ee4\u884c\u7231\u597d\u8005\u7684\u7f3a\u70b9\u4e4b\u4e00\u3002\u5982\u679c\u4f60\u9700\u8981\u8f93\u5165\u5e76\u8bb0\u4f4f\u540c\u6837\u957f\u7684\u547d\u4ee4\uff0c\u8fd9\u53ef\u80fd\u4f1a\u964d\u4f4e\u7ec8 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[707,706],"class_list":["post-7889","post","type-post","status-publish","format-standard","hentry","category-linux","tag-alias","tag-linux"],"aioseo_notices":[],"views":990,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/7889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=7889"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/7889\/revisions"}],"predecessor-version":[{"id":7895,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/7889\/revisions\/7895"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=7889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=7889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=7889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}