PATH环境变量在linux中 [英] PATH environment variable in linux

查看:130
本文介绍了PATH环境变量在linux中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道linux操作系统如PATH,HOME给出的标准环境变量是如何自动设置的。从哪些文件读取。应该有一些文件,当特定用户登录时,这些变量将被设置。

解决方案

我想要一些更多的细节

包含 PATH 的环境变量可以是




  • 系统范围 - 环境变量的值持续到系统启动

  • 会话宽度 - 持续到会话持续(直到用户注销)



/ etc / profile 适用于Bourne& Bourne兼容贝壳。

对于最新的Ubuntu发行版,建议使用 / etc / profile c $ c> / etc / environment 用于系统范围的设置(并且不建议使用 / etc / profile /etc/bash.bashrc Ubuntu帮助链接

在Ubuntu机器上, / etc / profile 是一个shell脚本,它以 /etc/profile.d &系统范围的 bashrc 文件在 /etc/bash.bashrc / etc / environment 是一个文本文件,由一行中的可变分配组成,它们被设置在系统范围的环境中。



对于每个用户,包括 PATH (对于shell)的环境变量的值也可以通过〜/ .profile 〜/ .bash_profile 〜。/ bash_login & 〜/ .bashrc =>用户的主目录)



有关Ubuntu系统环境变量的更多详细信息,请参阅以下链接: https:// help .ubuntu.com / community / EnvironmentVariables

希望这有帮助!


I want to know how the standard environment variables given by the linux OS like PATH, HOME are set automatically. Which file(s) are these read from. There should be some file from which these variables are set when a particular user logs in.

解决方案

I would like a little more details to what @cnicutar has already mentioned.
Environment variables including PATH can be

  • System wide - The values of the environment variables last till the system is up
  • Session wide - Lasts till a session lasts (till user logs out)

/etc/profile is meant for system setting for for Bourne & Bourne compatible shells. The behavior of /etc/profile may vary across distributions.
For latest Ubuntu distributions it is recommended to use /etc/environment for system-wide settings (and it is not recommended to use /etc/profile or /etc/bash.bashrc as noted in Ubuntu help link)
On Ubuntu machine, /etc/profile is a shell scrip which sources the scripts in /etc/profile.d & system-wide bashrc file in /etc/bash.bashrc whereas /etc/environment is a text file consisting of variable assignments per line which are set into the system-wide environment.

For each user the value of environment variables including PATH (for the shell) can also be manipulated through ~/.profile , ~/.bash_profile , ~./bash_login & ~/.bashrc (~ => User's home directory)

You can refer to the following link for more details on environment variable on Ubuntu System: https://help.ubuntu.com/community/EnvironmentVariables
Hope this helps!

这篇关于PATH环境变量在linux中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆