Ubuntu 环境变量配置 profile和bashrc 全局和本用户

相关文件

其中以/结尾的行表示文件夹。

/etc/profile
/etc/profile.d/
/etc/bash.bashrc
/etc/bash_completion
/etc/bash_completion.d/
~/.profile
~/.bashrc
~/.bash_history
~/.bash_logout 普通用户有,root没有。

区别

profile,配置文件。
bashrc,打开shell程序之前才会读取执行的配置文件。

/etc/目录下的配置文件为全局配置。
~/目录下的配置文件为本用户的私人配置。一般为以.开头的隐藏文件。

设置全局环境变量

如果不想太麻烦,想一次性设置针对所有用户的环境变量,要修改的文件:/etc/profile
修改过后,若时间允许,重启机器使最新配置对所有用户生效。
或:执行source /etc/profile以更新配置,本用户本Shell窗口立即生效。
(source用于Execute commands from a file in the current shell.)

发布了270 篇原创文章 · 获赞 156 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/wuyujin1997/article/details/104118553