系统环境变量

发布时间 2023-12-25 15:45:06作者: 与太阳肩并肩

系统环境变量:

  系统环境变量:定义在 /etc/profile  中,此中的环境变量对所有用户有效

root身份执行:

  gedit  /etc/profile  一般不直接修改 /etc/profile

    而是在  /etc/profile.d/创建一个自定义的脚本

 

1.先切换到root用户,并以可编辑状态进入到 /etc/profile 文件路径中

 可编辑状态进入到文件中:

系统环境变量演示:

  1.用touch在profile.d下创建一个脚本

    touch  /etc/profile.d/myprofile.sh

  2.定义环境变量,添加脚本内容

    export  TOMCAT=/opt/tomcat

 

  3.注销并重新登录

    重新登陆后,环境变量生效