通过更新〜/ .profile而不工作来添加自定义路径

我通过添加以下内容来修改我的〜/ .profile文件:

PATH="/user/share/android-sdk-linux/tools:$PATH" 

然后我注销并再次登录,但路径未添加到$ PATH环境变量中。 我正在检查终端:

 echo $PATH /usr/share/android-sdk-linux/tools:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0_17/bin 

请指教

编辑

我甚至尝试过:

 PATH=$PATH:/usr/share/android-sdk-linux/tools EXPORT PATH 

这里也没有运气。

编辑2

〜/ .profile文件:

  # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi # set path to android # PATH = $PATH:/usr/share/android-sdk-linux/tools # EXPORT PATH PATH="/usr/share/android-sdk-linux/tools:$PATH" 

添加到〜/ .bachrc或/ etc / environment:

 PATH="/usr/share/android-sdk-linux/tools:$PATH" 

有效,但为什么不〜/ .profile?

如果我理解正确,您想永久更改PATH envar的值。
在Ubuntu中,PATH envar在/etc/environment文件中定义。 所以你需要修改该文件中的PATH envar声明,而不是.profile内部!
仅当您想要为每个用户更改PATH值时才使用此选项!

在bash中为变量赋值时,不要在=之前或之后使用空格。 正确的方法是:

 PATH="/user/share/android-sdk-linux/tools:$PATH" 

要使更改生效,请使用以下命令重新启动计算机或获取.profile文件:

 source ~/.profile 

如果要更改所有用户的路径,请在/etc/profile文件中添加该行。 再次需要重启。