{"id":2306,"date":"2015-07-06T22:00:47","date_gmt":"2015-07-06T14:00:47","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2306"},"modified":"2015-07-06T22:00:47","modified_gmt":"2015-07-06T14:00:47","slug":"linux%e4%b8%ad-bashrc%e5%92%8c-bash_profile%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2306.html","title":{"rendered":"Linux\u4e2d.bashrc\u548c.bash_profile\u533a\u522b"},"content":{"rendered":"<h6>\u7f18\u7531\uff1a<\/h6>\n<p>\u65e9\u671f\u5b66\u4e60Linux\u7684\u65f6\u5019\u5c31\u5bf9\u8fd9\u4e2a\u95ee\u9898\u611f\u5174\u8da3\uff1a~\/.bashrc\u548c~\/.bash_profile\u4ee5\u53ca\/etc\/profile\u7b49\u6587\u4ef6\u7684\u4f5c\u7528\u5206\u522b\u662f\u4ec0\u4e48\uff0c\u542f\u52a8\u987a\u5e8f\u53c8\u662f\u600e\u4e48\u6837\u7684\u5462\uff1f\u5f53\u65f6\u4e5f\u67e5\u4e86\u5f88\u591a\u8d44\u6599\uff0c\u4f46\u9650\u4e8e\u5f53\u65f6\u7684\u77e5\u8bc6\u6c34\u5e73\u548c\u7ecf\u9a8c\uff0c\u5f88\u591a\u4e1c\u897f\u90fd\u4e0d\u592a\u61c2\uff0c\u53ea\u662f\u7565\u5fae\u8bb0\u5f97\u800c\u5df2\uff0c\u4eca\u5929\u4e2d\u5348\u6574\u7406\u4e86\u4e00\u4e0b\u81ea\u5df1\u5e38\u7528\u7684~\/.bashrc\u914d\u7f6e\uff0c\u53c8\u60f3\u8d77\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u89c9\u5f97\u6709\u5fc5\u8981\u628a\u8fd9\u4e2a\u95ee\u9898\u5f04\u6e05\u695a\uff0c\u4e8e\u662f\u6709\u4e86\u4e0b\u6587\u3002<\/p>\n<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<ul>\n<li>Linux .bashrc .bash_profile<\/li>\n<li>Linux .bashrc .bash_profile sequence<\/li>\n<li>Linux \u542f\u52a8 .bashrc bash_profile<\/li>\n<\/ul>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/tldp.org\/LDP\/Bash-Beginners-Guide\/html\/sect_01_02.html\" target=\"_blank\">http:\/\/tldp.org\/LDP\/Bash-Beginners-Guide\/html\/sect_01_02.html<\/a><\/li>\n<li><a href=\"http:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Bash-Startup-Files.html\" target=\"_blank\">http:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Bash-Startup-Files.html<\/a><\/li>\n<li><a href=\"http:\/\/www.thegeekstuff.com\/2008\/10\/execution-sequence-for-bash_profile-bashrc-bash_login-profile-and-bash_logout\/\" target=\"_blank\">Execution sequence for .bash_profile, .bashrc, .bash_login, .profile and .bash_logout<\/a><\/li>\n<\/ul>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<h6>\u4ea4\u4e92\u5f0f\u767b\u5f55shell<\/h6>\n<p>\u6587\u4ef6\u8bfb\u53d6\u987a\u5e8f\uff1a<\/p>\n<ol>\n<li>\/etc\/profile<\/li>\n<li>~\/.bash_profile,\u00a0~\/.bash_login\u00a0or\u00a0~\/.profile: first existing readable file is read<\/li>\n<li>~\/.bash_logout\u00a0upon logout<\/li>\n<\/ol>\n<p>\u9996\u5148\u8bfb\u53d6 \/etc\/profile\uff0c\u8fd9\u662f\u5bf9\u6240\u6709\u7528\u6237\u90fd\u6709\u6548\u7684\u914d\u7f6e\uff1b\u7136\u540e\u4f9d\u6b21\u5bfb\u627e\u4e0b\u9762\u4e09\u4e2a\u6587\u4ef6\uff08~\/.bash_profile\u3001~\/.bash_login\u3001~\/.profile\uff09\uff0c\u8fd9\u662f\u9488\u5bf9\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u914d\u7f6e\uff1b\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e09\u4e2a\u6587\u4ef6\u53ea\u8981\u6709\u4e00\u4e2a\u5b58\u5728\uff0c\u5c31\u4e0d\u518d\u8bfb\u53d6\u540e\u9762\u7684\u6587\u4ef6\u4e86\u3002\u6bd4\u5982\uff0c\u8981\u662f ~\/.bash_profile \u5b58\u5728\uff0c\u5c31\u4e0d\u4f1a\u518d\u8bfb\u53d6\u540e\u9762\u4e24\u4e2a\u6587\u4ef6\u4e86\u3002\u800c ~\/.bash_logout \u662f\u5728\u7528\u6237\u767b\u51fa\u7cfb\u7edf\u7684\u65f6\u5019\u7cfb\u7edf\u4f1a\u8bfb\u53d6\u7684\u6587\u4ef6\u3002<\/p>\n<h6>\u4ea4\u4e92\u5f0f\u975e\u767b\u5f55shell<\/h6>\n<p>A non-login shell means that you did not have to authenticate to the system. For instance, when you open a terminal using an icon, or a menu item, that is a non-login shell.<\/p>\n<p>Files read:<\/p>\n<ol>\n<li>~\/.bashrc<\/li>\n<\/ol>\n<p>\uff08~\/.bashrc \u8fd9\u4e2a\u6587\u4ef6\u901a\u5e38\u662f\u7531 ~\/.bash_profile \u5f15\u7528\u7684\uff09This file is usually referred to in\u00a0~\/.bash_profile:<\/p>\n<pre class=\"lang:default decode:true\">if [ -f ~\/.bashrc ]; then . ~\/.bashrc; fi<\/pre>\n<h6>\u975e\u4ea4\u4e92\u5f0f<\/h6>\n<p>All scripts use non-interactive shells. They are programmed to do certain tasks and cannot be instructed to do other jobs than those for which they are programmed.<\/p>\n<p>Files read:<\/p>\n<ol>\n<li>defined by\u00a0BASH_ENV<\/li>\n<\/ol>\n<p>PATH\u00a0is not used to search for this file, so if you want to use it, best refer to it by giving the full path and file name.<\/p>\n<p>\u5230\u8fd9\u513f\uff0c\u56f0\u6270\u6211\u591a\u65f6\u7684\u95ee\u9898\u5c31\u57fa\u672c\u89e3\u51b3\u4e86\uff0c\u5fc3\u91cc\u75db\u5feb\u4e86\u4e0d\u5c11\u3002\uff08\u5728\u78b0\u5230\u7c7b\u4f3c\u95ee\u9898\u7684\u65f6\u5019\uff0c\u5e94\u8be5\u9996\u5148\u60f3\u5230\u7684\u5c31\u662f\u67e5\u9605\u5b98\u65b9\u6587\u6863\uff0c\u6bd4\u5982\uff1aTLDP\u548cGNU\uff0c\u53ea\u8981\u8ba4\u771f\u67e5\u770b\uff0c\u80af\u5b9a\u80fd\u627e\u5230\u51c6\u786e\u7684\u7b54\u6848\u7684\uff09<\/p>\n<p>==<\/p>\n<h6>\u66f4\u591a\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.ruanyifeng.com\/blog\/2013\/08\/linux_boot_process.html\" target=\"_blank\">Linux \u7684\u542f\u52a8\u6d41\u7a0b<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/ithomer\/article\/details\/6322892\" target=\"_blank\">Linux \u4e4b \/etc\/profile\u3001~\/.bash_profile \u7b49\u51e0\u4e2a\u6587\u4ef6\u7684\u6267\u884c\u8fc7\u7a0b<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/robertaqi\/article\/details\/5449763\" target=\"_blank\">.bash_profile .bashrc profile \u6587\u4ef6\u7684\u4f5c\u7528\u7684\u6267\u884c\u987a\u5e8f<\/a><\/li>\n<li><a href=\"http:\/\/blog.snsgou.com\/post-647.html\" target=\"_blank\">(\u603b\u7ed3)\/etc\/rc.d\/rc.local \u4e0e \/etc\/profile .bash_profile .bashrc \u6587\u4ef6\u6267\u884c\u987a\u5e8f<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/chenchong08\/article\/details\/7833242\" target=\"_blank\">Linux\u4e2dprofile\u3001bashrc\u3001bash_profile\u4e4b\u95f4\u7684\u533a\u522b\u548c\u8054\u7cfb<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/www.linuxfromscratch.org\/blfs\/view\/svn\/postlfs\/profile.html\" target=\"_blank\">The Bash Shell Startup Files<\/a><\/li>\n<li><a href=\"http:\/\/stefaanlippens.net\/bashrc_and_others\" target=\"_blank\">Bash: about .bashrc, .bash_profile, .profile, \/etc\/profile, etc\/bash.bashrc and others<\/a><\/li>\n<li><a href=\"http:\/\/serverfault.com\/questions\/261802\/profile-vs-bash-profile-vs-bashrc\" target=\"_blank\">linux &#8211; .profile vs. .bash_profile vs. .bashrc<\/a><\/li>\n<li><a href=\"http:\/\/hacktux.com\/bash\/bashrc\/bash_profile\" target=\"_blank\">An Explanation of .bashrc and .bash_profile<\/a><\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/183870\/difference-between-bashrc-and-bash-profile\" target=\"_blank\">bash &#8211; Difference between .bashrc and .bash_profile<\/a><\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/789448\/choosing-between-bashrc-profile-bash-profile-etc\" target=\"_blank\">unix &#8211; Choosing between .bashrc, .profile, .bash_profile, etc<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/415403\/whats-the-difference-between-bashrc-bash-profile-and-environment\" target=\"_blank\">shell &#8211; What&#8217;s the difference between .bashrc, .bash_profile, and .environment?<\/a><\/li>\n<li><a href=\"http:\/\/linux.die.net\/man\/1\/bash\" target=\"_blank\">http:\/\/linux.die.net\/man\/1\/bash<\/a><\/li>\n<\/ul>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f18\u7531\uff1a \u65e9\u671f\u5b66\u4e60Linux\u7684\u65f6\u5019\u5c31\u5bf9\u8fd9\u4e2a\u95ee\u9898\u611f\u5174\u8da3\uff1a~\/.bashrc\u548c~\/.bash_profile\u4ee5\u53ca\/e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11],"tags":[538,118],"class_list":["post-2306","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","tag-bash_profile","tag-bashrc"],"views":4625,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2306"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2306\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}