linux - 将源添加到 bash

标签 linux bash debian

在我的 Debian 服务器中,所有用户都运行 sh,但 root 运行 bash; 当我开始一个 ssh 连接时,我使用没有 root 权限的个人帐户登录; 我已经安装了 rvm 并且我想以 root 身份使用它,因为从我的个人用户那里使用它,它无法安装所有东西,因为用户没有权限在需要的地方写入;所以每次我需要输入

source /usr/local/rvm/bin/rvm

在能够使用 rvm 之前;为了避免每次都输入 source 命令,在 sh 中我知道我可以将命令放在/etc/profile 文件中; bash 有类似的东西吗?

我尝试将“echo aaa”添加到/etc/profile,看看会发生什么; 当我以个人用户身份登录时,我得到“aaa”输出;但是当我键入 su 并以 root 身份登录时,没有任何反应......我认为当我使用“su”命令并以 root 身份登录时,/etc/profile 未被读取

通过 rvm 安装 ruby​​ 版本后,同样的情况发生了:我设置了默认的 ruby​​ 版本(作为 root),然后 ruby​​ 命令对我的个人用户可用(但是如果我再次执行“su”并尝试键入“ruby -v”作为root,我得到“找不到命令”

另一件事:使用我的个人用户登录后,可以使用 rvm 命令;输入“su”后,不再有;如果我将 source 命令添加到/etc/profile,一旦用个人用户完成登录,我可以看到 rvm 的屏幕输出(某种文档);以 root 身份使用 source 命令后也会发生同样的情况

最佳答案

bash -- 作为 sh 的扩展 -- 也读取 /etc/profile

bash 特定替代方案包括用于登录 shell 的 ~/.bash_profile 和用于非登录 shell 的 ~/.bashrc

关于linux - 将源添加到 bash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22418046/

相关文章:

python - 为 Ubuntu 发布

debian - Redmine 2.1.2(从2.0.4迁移): Migration OK but crashes after login

linux - 在构建 webkitgtk 时出错

bash - 我可以 tail -f 日志并只打印与某些文本匹配的某些行吗?

regex - 查找/我的音乐-type f | grep --regex ,仅通过管道传输 mp3 文件的正则表达式?

linux - bash 内置命令 "select"无法通过 shell 脚本中的管道工作

bash - aws cli - 在 bash 脚本中下载 rds postgres 日志

debian - Vagrant 和 Ansible 的 "skipping: no hosts matched"问题

linux - 如何让我的 init.d 脚本改变用户

c - 具有 4 Gb RAM 和 10 Gb 交换分区的 32 位内核中的无限循环 malloc