如何更改所有用户和shell的路径?

时间:2020-12-25 18:27:17

I'm on a Linux Mint system and I use bash and zsh as shells. I've just manually installed Texlive and I want it to be in my path.

我使用的是Linux Mint系统,我使用bash和zsh作为shell。我只是手动安装了Texlive,我希望它在我的路径中。

I thought adding the following lines to .profile would be fine, but zsh does not load .profile.

我想在.profile中添加以下几行是不错的,但是zsh不加载.profile。

if [ -d "/usr/local/texlive/2013/bin/i386-linux" ] ; then
    PATH="/usr/local/texlive/2013/bin/i386-linux:$PATH"
fi

if [ -d "/usr/local/texlive/2013/bin/x86_64-linux" ] ; then
    PATH="/usr/local/texlive/2013/bin/x86_64-linux:$PATH"
fi

if [ -d "/usr/local/texlive/2013/texmf/doc/man" ] ; then
    MANPATH="/usr/local/texlive/2013/texmf/doc/man:$MANPATH"
fi

if [ -d "/usr/local/texlive/2013/texmf/doc/info" ] ; then
    INFOPATH="/usr/local/texlive/2013/texmf/doc/info:$INFOPATH"
fi

Obviously, everything that mentions "add it to .zshrc / .bashrc" cannot be correct, as this will only affect me (only one user) and only those two shells.

显然,所有提到的“添加到.zshrc / .bashrc”都不能正确,因为这只会影响到我(只有一个用户)和只有那两个shell。

(I have administrative rights on my machine.)

(我对我的机器拥有管理权限。)

3 个解决方案

#1


2  

ZSH reads /etc/zsh/zprofile. So change that file.

ZSH读取/etc/zsh/zprofile.所以改变该文件。

#2


0  

You can change /etc/profile & /etc/bash_bashrc, those apply for all users.

您可以更改/etc/profile & /etc/bash_bashrc,它们适用于所有用户。

#3


0  

bash, ksh, dash, sh, and other shells related to sh all start by reading /etc/profile.

bash、ksh、dash、sh和与sh相关的其他shell都从读取/etc/ profile.com开始。


For zsh, I would recommend putting the change in /etc/zshenv. On the plus side, this file is guaranteed to be sourced, and sourced first, by any interactive zsh. On the minus side, it's guaranteed :), so don't put anything time-consuming here. Adding a few directories to PATH shouldn't be time-consuming, though.

对于zsh,我建议将更改放在/etc/zshenv中从好的方面来说,这个文件保证是由任何交互式zsh提供的,并且是首先由zsh提供的。缺点是,它保证是:),所以不要在这里浪费时间。不过,在PATH中添加几个目录应该不会太费时间。

Any of the other zsh startup files may or may not be read, depending on the settings in the user's private .zshenv file, which is the second file to be sourced.

任何其他zsh启动文件都可能被读取,也可能不被读取,这取决于用户的私有.zshenv文件中的设置,这是第二个要获取的文件。


For csh and its derivatives, /etc/csh.cshrc is probably the best bet.

对于csh和它的导数,/etc/ cshs。cshrc可能是最好的选择。

For any shells I may have missed, you'll have to consult their documentation.

对于我可能漏掉的任何shell,您都必须查阅它们的文档。


For any shell, be sure to check the documentation on your system to verify the location of the shells' files; they may be different depending on how the shell was compiled.

对于任何shell,请确保检查系统上的文档,以验证shell文件的位置;它们可能是不同的,这取决于shell是如何编译的。

#1


2  

ZSH reads /etc/zsh/zprofile. So change that file.

ZSH读取/etc/zsh/zprofile.所以改变该文件。

#2


0  

You can change /etc/profile & /etc/bash_bashrc, those apply for all users.

您可以更改/etc/profile & /etc/bash_bashrc,它们适用于所有用户。

#3


0  

bash, ksh, dash, sh, and other shells related to sh all start by reading /etc/profile.

bash、ksh、dash、sh和与sh相关的其他shell都从读取/etc/ profile.com开始。


For zsh, I would recommend putting the change in /etc/zshenv. On the plus side, this file is guaranteed to be sourced, and sourced first, by any interactive zsh. On the minus side, it's guaranteed :), so don't put anything time-consuming here. Adding a few directories to PATH shouldn't be time-consuming, though.

对于zsh,我建议将更改放在/etc/zshenv中从好的方面来说,这个文件保证是由任何交互式zsh提供的,并且是首先由zsh提供的。缺点是,它保证是:),所以不要在这里浪费时间。不过,在PATH中添加几个目录应该不会太费时间。

Any of the other zsh startup files may or may not be read, depending on the settings in the user's private .zshenv file, which is the second file to be sourced.

任何其他zsh启动文件都可能被读取,也可能不被读取,这取决于用户的私有.zshenv文件中的设置,这是第二个要获取的文件。


For csh and its derivatives, /etc/csh.cshrc is probably the best bet.

对于csh和它的导数,/etc/ cshs。cshrc可能是最好的选择。

For any shells I may have missed, you'll have to consult their documentation.

对于我可能漏掉的任何shell,您都必须查阅它们的文档。


For any shell, be sure to check the documentation on your system to verify the location of the shells' files; they may be different depending on how the shell was compiled.

对于任何shell,请确保检查系统上的文档,以验证shell文件的位置;它们可能是不同的,这取决于shell是如何编译的。