从su
的手册页:
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我检查了问题,该问题应该可以解决我的问题。问题基本上是关于su
和之间的区别su -
。我问的是su -
和之间的区别su --login
。所以不,它根本无法解决。
我不知道您对重复项的定义,但我不这样认为。您提出的问题基本上是关于
—
x-yuri
su
和之间的区别su -
。我问的是su -
和之间的区别su --login
。我在这里想念什么?
To avoid side effects caused by mixing environments use --login option or its equivalent -. The first form is recommended because - can be placed only just before username.