su 与su -

今天在服务器上通过su hadoop切换用户,使用jps看不到启动的spark程序,找不到jps命令,原来是su不改变当前环境变量!
su - root is the same as su -

just like login as root, then the shell is login shell,
which mean it will expericene a login process,
usually .bash_profile and .bashrc will be sourced

su root is the same as su
like you open an interactive shell in root name,
then only .bashrc will be sourced.

su 后面不加用户是默认切到 root
su 是不改变当前变量
su - 是改变为切换到用户的变量
也就是说su只能获得root的执行权限,不能获得环境变量
而su -是切换到root并获得root的环境变量及执行权限
语法:
su[username]suIDIDSuswitchusersetuseridIDIDsuroot()rootsusupperuser()root使su使exit退使su su – username
一些配置文件是为你的对话线索而设立的。当你使用命令 su username时,你的对话特征和你原始的登录身份一样。如果你想要你的对话进程拥有转换后的用户 ID一致的特征,你要使用短斜杠: su – username。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值