永久添加环境变量

时间:2022-02-16 23:13:26

I was trying to modify the ~/.profile file to add a line to the PATH variable. I added this line:

我正试着修改~/。将行添加到路径变量的概要文件。我说这条线:

PATH=$PATH:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/

at the end. I restarted the terminal, but it still did not identify commands in that directory. Does anyone know what I am doing wrong?

在最后。我重新启动了终端,但是它仍然没有识别那个目录中的命令。有人知道我做错了什么吗?

4 个解决方案

#1


15  

Try this in the ~/.pam_environment in your home folder, if it does not exist then create it

在~/上试试这个。在您的home文件夹中的pam_environment中,如果它不存在,那么创建它

PATH DEFAULT=${PATH}:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/

You will need to log in and out.

您将需要登录和退出。

#2


3  

Run bash -xl to see which startup files are loaded with your shell. .profile may actually not be read. Otherwise try adding export to your assignment:

运行bash -xl看看哪些启动文件被加载到shell中。.profile文件实际上可能不会被读取。否则,尝试向您的任务添加导出:

export PATH=$PATH:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/

Reference about bash's startup files: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

关于bash的启动文件的引用:https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

#3


2  

I'm running Mint 18.3 Cinnamon. The changes in ~/.profile got picked up only after I logged out/in from the account. The terminal restart was not enough in my case.

我在用薄荷18。3肉桂。~ /的变化。只有在我从账户注销/登录后,个人资料才会被获取。在我的情况下,终端重新启动是不够的。

#4


1  

if you edit .bashrc file:

如果你编辑。bashrc文件:

vim ~/.bashrc

you will see next line

您将看到下一行

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

So create a ~/.bash_aliases in your $HOME folder and add any command you want to be executed when you open the terminal

所以创建一个~ /。bash_aliases存在于$HOME文件夹中,并在打开终端时添加任何希望执行的命令

#1


15  

Try this in the ~/.pam_environment in your home folder, if it does not exist then create it

在~/上试试这个。在您的home文件夹中的pam_environment中,如果它不存在,那么创建它

PATH DEFAULT=${PATH}:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/

You will need to log in and out.

您将需要登录和退出。

#2


3  

Run bash -xl to see which startup files are loaded with your shell. .profile may actually not be read. Otherwise try adding export to your assignment:

运行bash -xl看看哪些启动文件被加载到shell中。.profile文件实际上可能不会被读取。否则,尝试向您的任务添加导出:

export PATH=$PATH:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/

Reference about bash's startup files: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

关于bash的启动文件的引用:https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

#3


2  

I'm running Mint 18.3 Cinnamon. The changes in ~/.profile got picked up only after I logged out/in from the account. The terminal restart was not enough in my case.

我在用薄荷18。3肉桂。~ /的变化。只有在我从账户注销/登录后,个人资料才会被获取。在我的情况下,终端重新启动是不够的。

#4


1  

if you edit .bashrc file:

如果你编辑。bashrc文件:

vim ~/.bashrc

you will see next line

您将看到下一行

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

So create a ~/.bash_aliases in your $HOME folder and add any command you want to be executed when you open the terminal

所以创建一个~ /。bash_aliases存在于$HOME文件夹中,并在打开终端时添加任何希望执行的命令