Roy*_*ley 16 user-profile environment-variables
我通过添加以下内容更改了我的 ~/.profile 文件:
PATH="/user/share/android-sdk-linux/tools:$PATH"
Run Code Online (Sandbox Code Playgroud)
然后我注销并再次登录,但路径没有添加到 $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
Run Code Online (Sandbox Code Playgroud)
请指教
编辑
我什至尝试过:
PATH=$PATH:/usr/share/android-sdk-linux/tools
EXPORT PATH
Run Code Online (Sandbox Code Playgroud)
这里也没有运气。
编辑 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"
Run Code Online (Sandbox Code Playgroud)
添加到 ~/.bachrc 或 /etc/environment:
PATH="/usr/share/android-sdk-linux/tools:$PATH"
Run Code Online (Sandbox Code Playgroud)
工作,但为什么不〜/ .profile?
Rad*_*anu 16
=
在 bash 中为变量赋值之前或之后不要使用空格。正确的方法是:
PATH="/user/share/android-sdk-linux/tools:$PATH"
Run Code Online (Sandbox Code Playgroud)
要使更改生效,请.profile
使用以下命令重新启动计算机或获取文件:
source ~/.profile
Run Code Online (Sandbox Code Playgroud)
如果要更改所有用户的路径,请在/etc/profile
文件中添加该行。再次需要重新启动。
如果我理解正确的话,您想永久更改 PATH envar 的值。
在 Ubuntu 中,PATH envar 是在/etc/environment
文件内定义的。因此,您需要修改该文件内的 PATH envar 声明,而不是 .profile 内!
仅当您想更改每个用户的 PATH 值时才使用此选项!