3

简单的问题,有什么区别

su oraclesu - oracle

我不确定这-两个命令的意义是什么。

更新:

做了su oracle之后,尝试了which sqlplus,但没有识别出来,但是通过doing su - oracle,设置了sqlplus环境。

4

2 回答 2

4

根据手册页

 -l      Simulate a full login.  The environment is discarded except for HOME, SHELL, PATH, TERM, and USER.  HOME and SHELL are modified as above.
         USER is set to the target login.  PATH is set to ``/bin:/usr/bin''.  TERM is imported from your current environment.  The invoked shell is
         the target login's, and su will change directory to the target login's home directory.

 -       (no letter) The same as -l.

简而言之,如果您使用,则su - oracle切换到用户oracle并重置环境。没有-,环境不会重置。

例如,没有-

#(root) export HELLO=world
#(root) su postgres
$(postgres) echo $HELLO
world
$(postgres)

并与-

#(root) export HELLO=world
#(root) su - postgres
$(postgres) echo $HELLO

$(postgres)
于 2013-02-12T22:19:32.810 回答
0

su - oracle它启动一个登录 shell,因此使用 oracle 用户环境。W/O 连字符只是更改为用户 oracle 用户;这授予与 oracle 用户相同的权限,因此您可以访问 oracle 拥有的文件/目录。

于 2013-02-12T22:14:14.070 回答