From d01da978ea408ee1667ba7171b54a7580cb96f09 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 14 Apr 2015 10:21:52 +0800 Subject: [PATCH] translated --- ...ange PATH environment variable on Linux.md | 75 ------------------- ...ange PATH environment variable on Linux.md | 73 ++++++++++++++++++ 2 files changed, 73 insertions(+), 75 deletions(-) delete mode 100644 sources/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md create mode 100644 translated/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md diff --git a/sources/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md b/sources/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md deleted file mode 100644 index ccbe380f84..0000000000 --- a/sources/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md +++ /dev/null @@ -1,75 +0,0 @@ -Translating----geekpi - -Linux FAQs with Answers--How to change PATH environment variable on Linux -================================================================================ -> **Question**: When I try to run an executable, it complains "command not found." The executable is actually located in /usr/local/bin. How can I add /usr/local/bin to my PATH variable, so that I can run the command without specify the path? - -In Linux, PATH environment variable stores a set of directories to search for an executable command when the command is typed by a user. The value of PATH variable is formatted as a series of colon-separated absolute paths. Each user has a user-specific PATH environment variable (initialized with system-wide default PATH variable). - -To check the current PATH environment variable of a user, run the following command as the user: - - $ echo $PATH - ----------- - - /usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin - -Alternatively, run: - - $ env | grep PATH - ----------- - - PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin - -If the command that you type is not found in any of these directories, the shell will throw an error message: "command not found" - -If you want to add an additional directory (e.g., /usr/local/bin) to your PATH variable, you can follow these instructions. - -### Change PATH Environment Variable for a Particular User Only ### - -If you want to temporarily add a new directory (e.g., /usr/local/bin) to a user's default search path in the current login session, you can simply type the following. - - $ PATH=$PATH:/usr/local/bin - -Now check if PATH has been updated: - - $ echo $PATH - ----------- - - /usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin:/usr/local/bin - -The updated PATH will then remain effective in the current login session. The change, however, will be lost in any new terminal session. - -If you want to change PATH variable permanently, open ~/.bashrc (or ~/.bash_profile) with a text editor, and append the following line. - - export PATH=$PATH:/usr/local/bin - -Then activate the change permanently by running: - - $ source ~/.bashrc (or source ~/.bash_profile) - -### Change PATH Environment Variable System-wide ### - -If you want to permanently add /usr/local/bin to system-wide default PATH variable, edit /etc/profile as follows. - - $ sudo vi /etc/profile - ----------- - - export PATH=$PATH:/usr/local/bin - -Once you re-login, the updated PATH variable will take effect. - --------------------------------------------------------------------------------- - -via: http://ask.xmodulo.com/change-path-environment-variable-linux.html - -作者:[Dan Nanni][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 - -[a]:http://ask.xmodulo.com/author/nanni diff --git a/translated/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md b/translated/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md new file mode 100644 index 0000000000..5cc7a17bd2 --- /dev/null +++ b/translated/tech/20150413 Linux FAQs with Answers--How to change PATH environment variable on Linux.md @@ -0,0 +1,73 @@ +Linux有问必答--如何在Linux中修改环境变量PATH +================================================================================ +> **提问**: 当我试着运行一个程序时,它提示“command not found”。 但这个程序就在/usr/local/bin下。我该如何添加/usr/local/bin到我的PATH变量下,这样我就可以不用指定路径来运行这个命令了。 + +在Linux中,PATH环境变量保存了一系列的目录用于用户在输入的时候搜索命令。PATH变量的值由一系列的由分号分隔的绝对路径组成。每个用户都有特定的PATH环境变量(由系统级的PATH变量初始化)。 + +要检查用户的环境变量,用户模式下运行下面的命令: + + $ echo $PATH + +---------- + + /usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin + +或者运行: + + $ env | grep PATH + +---------- + + PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin + +如果你的命令不存在于上面任何一个目录内,shell就会抛出一个错误信息:“command not found”。 + +如果你想要添加一个另外的目录(比如:/usr/local/bin)到你的PATH变量中,你可以用下面这些命令。 + +### 为特定用户修改PATH环境变量 ### + +如果你只想在当前的登录会话中临时地添加一个新的目录(比如:/usr/local/bin)给用户的默认搜索路径,你只需要输入下面的命令。 + + $ PATH=$PATH:/usr/local/bin + +检查PATH是否已经更新: + + $ echo $PATH + +---------- + + /usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin:/usr/local/bin + +更新的PATH会在当前的PATH一直有效。然而,更改将在新的会话中失效。 + +如果你想要永久更改PATH变量,用编辑器打开~/.bashrc (或者 ~/.bash_profile),接着在最后添加下面这行。 + + export PATH=$PATH:/usr/local/bin + +接着运行下面这行永久激活更改: + + $ source ~/.bashrc (or source ~/.bash_profile) + +### 改变系统级的环境变量 ### + +如果你想要永久添加/usr/local/bin到系统级的PATH变量中,像下面这样编辑/etc/profile。 + + $ sudo vi /etc/profile + +---------- + + export PATH=$PATH:/usr/local/bin + +你重新登录后,更新的环境变量就会生效了。 + +-------------------------------------------------------------------------------- + +via: http://ask.xmodulo.com/change-path-environment-variable-linux.html + +作者:[Dan Nanni][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 + +[a]:http://ask.xmodulo.com/author/nanni