问题:
用root账号登录时,使用 apt-get install git命令安装git时,报错如下
Command 'apt-get' is available in '/usr/bin/apt-get'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
apt-get: command not found
切换到普通管理员账号登录,使用sudo apt-get install git安装git安装成功
再切换到root,git --version查看git版本,仍然报错
root@alibaba:~# git --version
Command 'git' is available in '/usr/bin/git'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
git: command not found
查找得报错原因为apt-get不在/usr/bin下
解决方法:
使用root账号登录
输入以下代码:
root@alibaba:~# cd /bin/
root@alibaba:/bin# PATH="$PATH:/usr/bin"
root@alibaba:/bin# export PATH
root@alibaba:/bin# apt-get install vim
回车后显示如下图