首页 >

linux的环境变量在哪里

运维|linux运维linux的环境变量在哪里
linux
运维-linux运维
毕业论文项目源码,vscode在线编译,ubuntu nfs速度优化,java下载tomcat,sqlite3迅雷,火焰字插件,前端框架发展现状,python爬虫下载表格,php中的数据库,58同城 seo,团购网站文件包,展览展示类网页,lmxcms模板,html5 专题页面,无忧政府网站管理系统,外卖网站程序lzw
linux的环境变量在哪里
rs编码 源码,vscode设置行宽线,ubuntu手机ui,多台tomcat代码同步,爬虫matlab,php静态变量初始化,梁平区seo优化咨询,论坛网站 静态jsp页面素材,视频类主题网站模板lzw
1、系统位置,/etc目录下的bashrc、profile、environment三个文件
3d购物商城源码,ubuntu 发现不了网卡,tomcat响应时间怎么看,python爬虫如何加密,php中substr是什么意思,seo 文案策划lzw
2、用户目录(root或普通用户)下的.bashrc、.bash_profile两个文件,注意这两个文件前面都有点,是隐藏文件。

先说这3个系统文件,列出文件内容(参考CentOS7)。 /**/为添加注释

# /etc/bashrc# System wide functions and aliases      /* 系统广泛功能(函数)和别名 */# Environment stuff goes in /etc/profile /* 环境东西(环境变量)在/etc/profile文件中 *//* 修改这个文件不是一个好主意,除非你知道自己在干什么。*//* 在/etc/profile.d/目录下创建一个自定义脚本会是修改环境变量的更好方法 *//* 但是会阻止在将来更新时合并的需要 */# It's NOT a good idea to change this file unless you know what you# are doing. It's much better to create a custom.sh shell script in# /etc/profile.d/ to make custom changes to your environment, as this# will prevent the need for merging(合并) in future updates.………………………………………………………………………………………………………………………………………………………………………………………………………………# /etc/profile# System wide environment and startup programs, for login setup# Functions and aliases go in /etc/bashrc# It's NOT a good idea to change this file unless you know what you# are doing. It's much better to create a custom.sh shell script in# /etc/profile.d/ to make custom changes to your environment, as this# will prevent the need for merging in future updates.………………………………………………………………………………………………………………………………………………………………………………………………………………

第三个文件environment文件打开是一个空文件,不表。

再说两个用户文件,贴上文件内容(参考CentOS7)/**/为添加注释

普通用户:

linux的环境变量在哪里

root用户

# .bashrc# User specific aliases and functions      /* 用户指定的别名和函数(功能)*/alias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then. /etc/bashrcfi# .bash_profile# Get the aliases and functions            /* 获取别名和函数(功能)*/if [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programs    /* 用户指定环境变量和启动程序(linux开机启动程序放在这里?还没有试过) */PATH=$PATH:$HOME/binexport PATH

这几个文件的注释已经说得很清楚了,bashrc文件是 用户指定别名和函数(功能), bash_profile文件是用来获取bashrc文件中的别名和函数(功能),用户还可以在此文件中指定环境变量和开机启动程序。在系统的bashrc、和bash_profile文件明确说明 在/etc/profile.d/目录下创建一个自定义脚本会是修改环境变量的更好方法。如图:

linux的环境变量在哪里

到这里文章就结束了,但是在实际配置环境变量中发现,如果变量仅配置在系统配置文件中,以普通用户登录系统终端中是有自己添加的环境变量,一旦su到root,终端中就没有了之前配环境变量。解决方法就是在每个用户的配置文件中都配置一次,这样太麻烦。在/etc/profile.d/目录下创建一个自定义脚本的方法无论你在一个终端中如何切换用户,环境变量依然存在。

《Linux视频教学》


  • 暂无相关文章
  • Posted in 未分类