linux etc profile.d,Linux :: /etc/profile.d中的共享别名未应用于root用户,为什么?

Must have to do with diff between su-ing over ssh vs when logged

directly into machine

我怀疑你执行没有破折号( – )的su命令,如果是这样,它将调用一个交互式非登录shell.与你结合只有在/root/.bashrc中关注:

# Test for an interactive shell. There is no need to set anything

# past this point for scp and rcp,and it's important to refrain from

# outputting anything in those cases.

if [[ $- != *i* ]] ; then

# Shell is non-interactive. Be done now!

return

fi

(不是源/ etc / bashrc)

而如果您直接登录或使用su –,它将调用登录shell,读取/ etc / profile并执行sharedAliases.sh.

要查看使用不同shell读取的文件,请通过以root身份执行以下命令将日志添加到所有这些文件:

echo "echo 'running /etc/bashrc'" >> /etc/bashrc

echo "echo 'running /etc/profile'" >> /etc/profile

echo "echo 'running /root/.bashrc'" >> ~/.bashrc

创建测试别名:

# echo "alias list='ls'" > /etc/profile.d/test.sh

现在,以普通用户身份登录并使用su,您将看到如下内容:

$su

Password:

running /root/.bashrc

bash-3.2# list

bash: list: command not found

和su – :

$su -

Password:

running /etc/profile

running /root/.bashrc

# list

total 226540

-rw-rw-r-- 1 root root 60148987 Apr 1 2011 3241948.flv

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值