<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post/4461/</link>
<title><![CDATA[[个人原创]su与sudo、su - root的区别在工作环境和附带的可执行文件.bashrc]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Tue, 12 Jul 2011 10:46:39 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/4461/</guid> 
<description>
<![CDATA[ 
	su 和 sudo 的区别：<br/>&nbsp;&nbsp;&nbsp;&nbsp;1.共同点：都是root用户的权限；<br/>&nbsp;&nbsp;&nbsp;&nbsp;2.不同点：su仅仅取得root权限，工作环境不变，还是在切换之前用户的工作环境；sudo是完全取得root的权限和root的工作环境。<br/><br/><br/>su - root 和 su root（su）有什么区别？<br/>su - root:表示人以root身份登录<br/>just like login as root, then the shell is login shell,<br/>which mean it will expericene a login process,<br/>usually .bash_profile and .bashrc will be sourced<br/>su&nbsp;&nbsp; root:表示与root建立一个链接，通过root执行命令<br/>like you open an interactive shell in root name,<br/><textarea name="code" class="html" rows="15" cols="100">
then only .bashrc will be sourced.
</textarea><br/>最直接的区别就是su目录还是原先用户的目录<br/>但是su或su - root后目录就变为root用户的主目录了。<br/><br/>实践：<br/>vi /root/.bashrc<br/><textarea name="code" class="html" rows="15" cols="100">
 ipL=`/sbin/ifconfig eth1&#124;grep &quot;inet addr:&quot;&#124;cut -d: -f 2&#124;cut -d&quot; &quot; -f1`
 export PS1=&quot;&#92;u@$ipL:&#92;w# &quot;
 
 alias cdh=&quot;cd /usr/local/tads/htdocs/&quot;
</textarea><br/>我是先root登录后：<br/>root@172.25.3*.7*:~# su jackxiang<br/>jackxiang@Tencent:/root&gt; <br/>发现上面的区别了吧？由root变为jackxiang后，控制台出现不同，再来看看：<br/>jackxiang@Tencent:/root&gt; cdh<br/>bash: cdh: command not found<br/>cdh这个不存在，也就是/root/.bashrc这个没有被执行，注意这点。<br/>我们再 su - root 一下：<br/><textarea name="code" class="html" rows="15" cols="100">
jackxiang@Tencent:/root&gt; su - root
Password: 
root@172.25.3*.7*:~# 
root@172.25.3*.7*:~# cdh
root@172.25.3*.7*:/usr/local/tads/htdocs#
</textarea><br/>看上面，控制台变了吧，主要原因是什么呢？是因为我们在su - root,或者su root 时，这一瞬间其root时去执行了脚本:<br/>/root/.bashrc。<br/>它告诉我们，想要修改PATH，PHP，APACHE，Mysql等的路径，都可以到这个脚本中添加即可。<br/><br/>有一个文档说明此事：<br/><a href="attachment.php?fid=204">点击这里下载文件</a>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/4461/#blogcomment63362</link>
<title><![CDATA[[评论] [个人原创]su与sudo、su - root的区别在工作环境和附带的可执行文件.bashrc]]></title> 
<author>tingaini178 &lt;tingaini178@126.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 30 Jul 2011 12:21:42 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/4461/#blogcomment63362</guid> 
<description>
<![CDATA[ 
	看帖回帖是一种美德.很开心来到这里!
]]>
</description>
</item>
</channel>
</rss>