如何永久的更改PATH路径

如何永久的更改PATH路径使用如下语句将路径加入 PATH 后 仅在当前终端有效

大家好,欢迎来到IT知识分享网。

转载https://stackoverflow.com/questions//how-to-permanently-set-path-on-linux-unix/#

There are multiple ways to do it. The actual solution depends on the purpose.

The variable values are usually stored in either a list of assignments or a shell script that is run at the start of the system or user session. In case of the shell script you must use a specific shell syntax.

System wide

  • /etc/environment List of unique assignments. Perfect for adding system-wide directories like /usr/local/something/bin to PATH variable or defining JAVA_HOME.
  • /etc/xprofile Shell script executed while starting X Window System session. This is run for every user that logs into X Window System. It is a good choice for PATH entries that are valid for every user like /usr/local/something/bin. The file is included by other script so use POSIX shell syntax not the syntax of your user shell.
  • /etc/profile and /etc/profile.d/* Shell script. This is a good choice for shell-only systems. Those files are read only by shells.
  • /etc/.rc. Shell script. This is a poor choice because it is single shell specific.

User session

  • ~/.pam_environment. List of unique assignments. Loaded by PAM at the start of every user session irrelevant if it is an X Window System session or shell. You cannot reference other variable including HOME or PATH so it has limited use.
  • ~/.xprofile Shell script. This is executed when the user logs into X Window System system. The variables defined here are visible to every X application. Perfect choice for extending PATH with values such as ~/bin or ~/go/bin or defining user specific GOPATH or NPM_HOME. The file is included by other script so use POSIX shell syntax not the syntax of your user shell. Your graphical text editor or IDE started by shortcut will see those values.
  • ~/.profile Shell script. It will be visible only for programs started from terminal or terminal emulator. It is a good choice for shell-only systems.
  • ~/.rc. Shell script. This is a poor choice because it is single shell specific.

Distribution specific documentation

Ubuntu

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/158986.html

(0)
上一篇 2024-11-27 14:00
下一篇 2024-11-27 14:15

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信