linux ruby 环境变量,Linux 环境变量总结+rvm安装时一个tip

环境变量配置文件

在Ubuntu中有如下几个文件可以设置环境变量

/etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行。

/etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量。

/etc/bash.bashrc(有些系统为/etc/bashrc):为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.

~/.bash_profile

~/.bashrc

注:其中1、2、3是全局的,对所有用户生效;4和5是局部的,只作用于当前用户。

带bash的只对shell有效,即只能用于终端登录;不带bash的适合于任何程序。

设置永久环境变量

把环境变量添加要上面4种文件中。如:~/.bashrc

用source命令使得刚修改的环境变量生效。如:source .bashrc

我想强调的问题:/etc/profile的设置对su root无效。

这就是为什么rvm安装时不建议使用root而使用sudo的原因。

Multi-User Installs – Using the sudo command

The installation process is similar for both installation methods, however, when installing a multi-user configuration, do not run the installer directly as root. Always use the sudo command. This is due to variables that are different between root’s environment and a user’s that aren’t affected by an EUID change, as well as code checks in the install itself. In addition, when you use sudo, it will not load the /etc/profile.d/rvm.sh, and as such will not load RVM.

那如何将/etc/profile的设置在su root也能生效呢?

su - root

“-”不能省略,它是–login的编写。

这样就可以不用sudo,直接用root安装rvm了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值