服务器技术

 首页 > 服务器技术 > Linux > linux 用户切换su 命令横杠的作用 - Linux操作系统:

linux 用户切换su 命令横杠的作用 - Linux操作系统:

分享到:
【字体:
导读:
          挺凑巧的,最近老有同事问起这些问题,所以总结一下。1. 首先用help理解su,sudo su,sudo2. 其次理解login shell and interactive shell.When Bash starts executes the commands in a var......

 

挺凑巧的,最近老有同事问起这些问题,所以总结一下。

 

1. 首先用help理解su,sudo su,sudo

2. 其次理解"login shell" and "interactive shell".

 

"When Bash starts executes the commands in a variety of different scripts.

(1) When started as an interactive login shell: Bash reads and executes the /etc/profile (if it exists). After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile in that order, and reads and executes the first one (that exists and is readable).  When a login shell exits: Bash reads and executes ~/.bash_logout (if it exists).

(2) When started as an interactive shell (but not a login shell): Bash reads and executes ~/.bashrc (if it exists)."

显然login shell和interactive shell在环境的设置上是存在差别的,详细可以参考:http://groups.google.com/group/linux.debian.user/browse_thread/thread/2b71ecfc45789958/7bff24e3bae74b36?lnk=raot

3.  然后su命令的横杠就非常容易理解了,参数横杠-, 是为了让切换获取的shell是一个login shell

 -, -l, --login               make the shell a login shell

 

摘自 linhx的专栏

      上一篇:linux与windows字符编码格式的自动调整 - Linux操作系 下一篇:sed高级命令之n、N - Linux操作系统:Ubuntu_Centos
    分享到:
    中国最完整的sysctl.conf优化方案 - Lin...
      网上关于sysctl.conf的优化方案有各种版本,大多都是抄来抄去的,让新人看了很迷茫。 为解决此问题,经过两天的整理,查了N多资料,将大家常用的总结如下, 很多默认的不需要修改的暂未涉及,今后将逐步把所有的项目都有个翻译、讲解、修改建议   ################### 所有rfc相关的选项都是默...
    linux与windows字符编码格式的自动调整 -...
      这几天频繁在windows和ubuntu下调试代码,字符编码格式不同老是造成很大的困扰,windows下的默认字符编码格式是GBK(gb2312)而在ubuntu下的是utf-8。前天光来回的保存编码格式就费了很大的劲,今天google了下找到了个临时还算是不错的方法。 ubuntu下自带一个字符编码格式调整命令:iconv   ICONV(1)...
    •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
    • 在这里……