给PATH变量添加路径Adding directories to your $PATH

  PATH是一个告诉shell在哪些路径中搜索可执行文件来响应用户的命令的环境变量。

  PATH is an environmental variable that informs the shell within which directories to search for executable files in response to commands issued by a user.

  为此,编辑用户家目录下的.bashrc文件在里面附上下面这行命令(接在现有路径后面):

  To do this, edit the .bashrc file in the home directory and append the following line (chaining the existing path additions) :

export PATH=/path/to/dir:$PATH

  可以在终端运行下面命令打开.bashrc:

  You can open .bashrc in terminal by running:

$ nano ~/.bashrc# ~/ being the implicit path for# your home folder#~/ 就是指你的家目录

  比如,这样添加/usr/sbin的路径:

  For example, to add the directory /usr/sbin, the following would be used:

PATH="/usr/sbin:$PATH"

  执行source命令或者注销重登陆(或者重启终端)来使更改生效。

  Source your .bashrc or logout/login (or restart the terminal) for the changes to take effect.

  执行source时,以文件作为参数。source .bashrc,直接输入:

  Sourcing executes the file that it was given as a parameter. To source your .bashrc, simply type

$ source ~/.bashrc

  这样也可以:

  This is the same as running:

. ~/.bashrc