<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A18制造 &#187; bashrc</title>
	<atom:link href="http://a18zhizao.com/ytag/bashrc/feed" rel="self" type="application/rss+xml" />
	<link>http://a18zhizao.com</link>
	<description>梦想的种子飞入了大地，所需要的只有时间。</description>
	<lastBuildDate>Tue, 24 Jan 2012 11:50:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>linux启动是自动加载的几个文件说明bashrc等</title>
		<link>http://a18zhizao.com/y2010/1242_linux-boot-is-automatically-loaded-a-few-documented-bashrc-etc.html</link>
		<comments>http://a18zhizao.com/y2010/1242_linux-boot-is-automatically-loaded-a-few-documented-bashrc-etc.html#comments</comments>
		<pubDate>Thu, 25 Feb 2010 02:26:40 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bashrc]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[加载]]></category>

		<guid isPermaLink="false">http://www.a18zhizao.cn/?p=1242</guid>
		<description><![CDATA[（1）/etc/profile 全局（公有）配置，不管是哪个用户，登录时都会读取该文件。 （2）/ect/bashrc Ubuntu没有此文件，与之对应的是/ect/bash.bashrc 它也是全局（公有）的 bash执行时，不管是何种方式，都会读取此文件。 （3）~/.profile 若bash是以login方式执行时，读取~/.bash_profile，若它不存在，则读取~/.bash_login，若前两者不存在，读取~/.profile。 另外，图形模式登录时，此文件将被读取，即使存在~/.bash_profile和~/.bash_login。 （4）~/.bash_login 若bash是以login方式执行时，读取~/.bash_profile，若它不存在，则读取~/.bash_login，若前两者不存在，读取~/.profile。 （5）~/.bash_profile Unbutu默认没有此文件，可新建。 只有bash是以login形式执行时，才会读取此文件。通常该配置文件还会配置成去读取~/.bashrc。 （6）~/.bashrc 当bash是以non-login形式执行时，读取此文件。若是以login形式执行，则不会读取此文件。 （7）~/.bash_logout 注销时，且是longin形式，此文件才会读取。也就是说，在文本模式注销时，此文件会被读取，图形模式注销时，此文件不会被读取。 下面是在本机的几个例子： 1. 图形模式登录时，顺序读取：/etc/profile和~/.profile 2. 图形模式登录后，打开终端时，顺序读取：/etc/bash.bashrc和~/.bashrc 3. 文本模式登录时，顺序读取：/etc/bash.bashrc，/etc/profile和~/.bash_profile 4. 从其它用户su到该用户，则分两种情况： （1）如果带-l参数（或-参数，–login参数），如：su -l username，则bash是lonin的，它将顺序读取以下配置文件：/etc/bash.bashrc，/etc/profile和~/.bash_profile。 （2）如果没有带-l参数，则bash是non-login的，它将顺序读取：/etc/bash.bashrc和~/.bashrc 5. 注销时，或退出su登录的用户，如果是longin方式，那么bash会读取：~/.bash_logout 6. 执行自定义的shell文件时，若使用“bash -l a.sh”的方式，则bash会读取行：/etc/profile和~/.bash_profile，若使用其它方式，如：bash a.sh， ./a.sh，sh a.sh（这个不属于bash shell），则不会读取上面的任何文件。 7. 上面的例子凡是读取到~/.bash_profile的，若该文件不存在，则读取~/.bash_login，若前两者不存在，读取~/.profile。 其中PATH这个变量特殊说明一下: 如果是超级用户登录,在没有执行/etc/profile之前,PATH已经设定了下面的路径: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 如果是普通用户,PATH在/etc/profile执行之前设定了以下的路径: /usr/local/bin:/bin:/usr/bin 这里要注意的是:在用户切换并加载变量,例如su -,这时，如果用户自己切换自己,比如root用户再用su - root切换的话,加载的PATH和上面的不一样. 准确的说，会因为在/etc/profile脚本中的配置产生变化，因为它做了如下的配置: if [ [...]]]></description>
			<content:encoded><![CDATA[<p>（1）/etc/profile<br />
全局（公有）配置，不管是哪个用户，登录时都会读取该文件。</p>
<p>（2）/ect/bashrc<br />
Ubuntu没有此文件，与之对应的是/ect/bash.bashrc<br />
它也是全局（公有）的<br />
bash执行时，不管是何种方式，都会读取此文件。</p>
<p>（3）~/.profile<br />
若bash是以login方式执行时，读取~/.bash_profile，若它不存在，则读取~/.bash_login，若前两者不存在，读取~/.profile。<br />
另外，图形模式登录时，此文件将被读取，即使存在~/.bash_profile和~/.bash_login。<br />
<span id="more-1242"></span><br />
（4）~/.bash_login<br />
若bash是以login方式执行时，读取~/.bash_profile，若它不存在，则读取~/.bash_login，若前两者不存在，读取~/.profile。</p>
<p>（5）~/.bash_profile<br />
Unbutu默认没有此文件，可新建。<br />
只有bash是以login形式执行时，才会读取此文件。通常该配置文件还会配置成去读取~/.bashrc。</p>
<p>（6）~/.bashrc<br />
当bash是以non-login形式执行时，读取此文件。若是以login形式执行，则不会读取此文件。</p>
<p>（7）~/.bash_logout<br />
注销时，且是longin形式，此文件才会读取。也就是说，在文本模式注销时，此文件会被读取，图形模式注销时，此文件不会被读取。</p>
<p>下面是在本机的几个例子：<br />
1. 图形模式登录时，顺序读取：/etc/profile和~/.profile<br />
2. 图形模式登录后，打开终端时，顺序读取：/etc/bash.bashrc和~/.bashrc<br />
3. 文本模式登录时，顺序读取：/etc/bash.bashrc，/etc/profile和~/.bash_profile<br />
4. 从其它用户su到该用户，则分两种情况：<br />
（1）如果带-l参数（或-参数，–login参数），如：su -l username，则bash是lonin的，它将顺序读取以下配置文件：/etc/bash.bashrc，/etc/profile和~/.bash_profile。<br />
（2）如果没有带-l参数，则bash是non-login的，它将顺序读取：/etc/bash.bashrc和~/.bashrc<br />
5. 注销时，或退出su登录的用户，如果是longin方式，那么bash会读取：~/.bash_logout<br />
6. 执行自定义的shell文件时，若使用“bash -l a.sh”的方式，则bash会读取行：/etc/profile和~/.bash_profile，若使用其它方式，如：bash a.sh， ./a.sh，sh a.sh（这个不属于bash shell），则不会读取上面的任何文件。<br />
7. 上面的例子凡是读取到~/.bash_profile的，若该文件不存在，则读取~/.bash_login，若前两者不存在，读取~/.profile。</p>
<p>其中PATH这个变量特殊说明一下:<br />
如果是超级用户登录,在没有执行/etc/profile之前,PATH已经设定了下面的路径:<br />
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br />
如果是普通用户,PATH在/etc/profile执行之前设定了以下的路径:<br />
/usr/local/bin:/bin:/usr/bin<br />
这里要注意的是:在用户切换并加载变量,例如su -,这时，如果用户自己切换自己,比如root用户再用su - root切换的话,加载的PATH和上面的不一样.<br />
准确的说，会因为在/etc/profile脚本中的配置产生变化，因为它做了如下的配置:</p>
<p>if [ "`id -u`" -eq 0 ]; then<br />
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"<br />
else<br />
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"<br />
fi</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1242_linux-boot-is-automatically-loaded-a-few-documented-bashrc-etc.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

