首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >‘`su -`’和‘`su -login`’有什么区别?

‘`su -`’和‘`su -login`’有什么区别?
EN

Unix & Linux用户
提问于 2016-10-24 16:26:04
回答 2查看 6.6K关注 0票数 18

来自su's主页:

代码语言:javascript
复制
For  backward  compatibility, su defaults to not change the current directory
and to only set the environment variables HOME and SHELL (plus USER and LOGNAME
if the target user is not root).  It is recommended to always use the 
--login option (instead of  its  shortcut -) to avoid side effects caused
by mixing environments.

...

-, -l, --login
    Start the shell as a login shell with an environment similar to a real login:

        o      clears all the environment variables except TERM

        o      initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH

        o      changes to the target user's home directory

        o      sets argv[0] of the shell to '-' in order to make the shell a login shell

很难判断---login之间是否有什么区别(或者应该只有-l)。也就是说,手册页上写着“而不是它的快捷方式-",但是所有这些选项都是分组在一起的,如果存在的话,我看不出有什么区别的解释。

UPD我检查了问题,这应该是解决我的问题。问题基本上是关于susu -之间的区别。我在问su -su --login之间的区别。所以不,它根本解决不了这个问题。

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2016-10-24 16:42:36

Debian的手册条目似乎更有启发性:

代码语言:javascript
复制
   -, -l, --login
       Provide an environment similar to what the user would expect had the user logged
       in directly.

       When - is used, it must be specified before any username. For portability it is
       recommended to use it as last option, before any username. The other forms (-l
       and --login) do not have this restriction.
票数 12
EN

Unix & Linux用户

发布于 2016-10-24 16:37:30

没有什么不同,就像跑步一样;

代码语言:javascript
复制
echo bob | grep -v bob
echo bob | grep --invert-match bob

只是速记..。

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/318572

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档