zoukankan      html  css  js  c++  java
  • 环境变量设置的几种方法

    一、CentOS

    在CentOS系统中添加环境变量的方法有几种,推荐第三种方法。这里以添加 TexLive 2017 的环境变量为例进行说明。

    1. 修改  ~/.bash_profile  文档,在文末添加以下代码:

    $ vi ~/.bash_profile
    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    
    # path for TexLive 2017
    export TEXMF=/usr/local/texlive/texmf-local export PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/texlive/2017/bin/x86_64-linux export MANPATH=$MANPATH:/usr/local/texlive/2017/texmf-dist/doc/man export INFOPATH=$INFOPATH:/usr/local/texlive/2017/texmf-dist/doc/info
    $ source ~/.bashrc  # 在终端运行相应的变量更新,即可得到更新后的环境变量

    2. 修改  ~/.bashrc  文档,在文末添加以下内容:

    $ vi ~/.bashrc 
    # .bashrc
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
        . /etc/bashrc
    fi
    
    # Uncomment the following line if you don't like systemctl's auto-paging feature:
    # export SYSTEMD_PAGER=
    
    # User specific aliases and functions

    # path for TexLive 2017
    export TEXMF=/usr/local/texlive/texmf-local export PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/texlive/2017/bin/x86_64-linux export MANPATH=$MANPATH:/usr/local/texlive/2017/texmf-dist/doc/man export INFOPATH=$INFOPATH:/usr/local/texlive/2017/texmf-dist/doc/info

    $ source ~/.bashrc  # 在终端运行相应的变量更新,即可得到更新后的环境变量

    3. 新建一个 shell 文件,命名为 ~/TexLive2017.sh ,它的内容如下,并将它拷贝到目录  /etc/profile.d/  下。

    在终端运行相应的变量更新,即可得到更新后的环境变量。

    $ vi ~/TexLive2017.sh
    #!/bin/bash
    # setting for TexLive 2017 environment variables, edit by She
    export TEXMF=/usr/local/texlive/texmf-local
    export PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/texlive/2017/bin/x86_64-linux
    export MANPATH=$MANPATH:/usr/local/texlive/2017/texmf-dist/doc/man
    export INFOPATH=$INFOPATH:/usr/local/texlive/2017/texmf-dist/doc/info
    
    $ source /etc/profile.d/texlive2017.sh 

    二、Mac

    参考这里:https://blog.csdn.net/u010596262/article/details/103155283

    之前配置环境变量一直都在 ~/.bash_profile 中, 最近更新系统后,重启终端后或者重启系统环境变量配置都不生效。

    每次都需要重新执行 : $source ~/.bash_profile。

    zsh加载的是 ~/.zshrc文件

    在~/下新建 .zshrc 文件,并在里面添加一行:source ~/.bash_profile

    保存~/.zshrc文件,重启后,一切正常。

     
  • 相关阅读:
    显示在页面中间的加载gif
    10个超赞的jQuery图片滑块动画
    【Mybatis】mybatis设置指定列为空值
    【Centos】使用confluent将Mysql数据同步到clickhouse
    SpringBoot Mock测试RequestBody参数并包含其他参数接口
    【Linux】linux使用screen部署spring cloud项目
    Docker中部署jenkins
    【Mysql】Docker连接容器中的mysql 8报错 Public Key Retrieval is not allowed
    【MySQL】Windows下mysql的主从配置笔记
    This Gradle plugin requires a newer IDE able to request IDE model level 3. For Android Studio this means version 3.0+
  • 原文地址:https://www.cnblogs.com/snake553/p/7211153.html
Copyright © 2011-2022 走看看