网站地图    收藏   

主页 > 系统 > linux系统 >

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

来源:自学PHP网    时间:2015-04-14 11:51 作者: 阅读:

[导读] 挺凑巧的,最近老有同事问起这些问题,所以总结一下。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的专栏

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论