Mod*_*ndi 4 bash path environment-variables
我正在设置一个全新的 Ubuntu 16.04 Minimal 系统,但遇到了一个奇怪的问题。即使添加$HOME/bin到后$PATH,bash似乎也找不到其中的任何脚本,至少对于root.
我已经退出好几次了,甚至重新启动过一次机器。/etc/profile.d该路径由:中的一行脚本设置export PATH="$PATH:$HOME/bin"。
root@Pioneer ~ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/bin
root@Pioneer ~ # ls -la /root/bin
total 36
drwxr-xr-x 2 root root 4096 Feb 6 16:04 .
drwx------ 8 root root 4096 Feb 6 16:03 ..
-rwxr-xr-x 1 root root 174 Jan 5 2017 newuser
-rwxr-xr-x 1 root root 236 Nov 3 2015 own
-rwxr-xr-x 1 root root 87 May 6 2017 re-dns
-rwxr-xr-x 1 root root 57 May 10 2016 re-ftp
-rwxr-xr-x 1 root root 89 Oct 20 2015 re-mail
-rwxr-xr-x 1 root root 42 Oct 19 2015 re-smb
-rwxr-xr-x 1 root root 65 Oct 19 2015 re-web
root@Pioneer ~ # newuser
-bash: newuser: command not found
Run Code Online (Sandbox Code Playgroud)
/root/bin/newuser有效,就像 一样cd /root/bin && ./newuser。
名称中没有尾随空格:
# ls -lb /root/bin/newuser
-rwxr-xr-x 1 root root 174 Jan 5 2017 newuser
Run Code Online (Sandbox Code Playgroud)
Root 的家确实是/root:
# getent passwd root
getent: root:x:0:0:root:/root:/bin/bash
Run Code Online (Sandbox Code Playgroud)