我刚刚使用厨师在 Ubuntu (aws) 上安装了 apache2。
Ubuntu 服务器上的 Apache2:10.1.1.1
客户端:10.1.1.200
我还验证了 tcp 22 (sshd) 和 tcp 80 (apache2) 都在监听
root@Ubuntu:/var/www# netstat -anp | egrep '22|80'
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1469/sshd
tcp6 0 0 :::80 :::* LISTEN 16950/apache2
tcp6 0 0 :::22 :::* LISTEN 1469/sshd
root@Ubuntu:/var/www#
Run Code Online (Sandbox Code Playgroud)
流程看起来也不错
root@Ubuntu:/var/www# ps -ef | egrep 'apache2|sshd'
root 1469 1 0 Sep29 ? 00:00:00 /usr/sbin/sshd -D
root 16950 1 0 Sep29 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 16953 16950 0 Sep29 ? 00:00:02 /usr/sbin/apache2 …Run Code Online (Sandbox Code Playgroud) ifconfig位于/sbin/ifconfig。ifconfig我在 root 用户中发出命令没有问题。
当我创建一个新用户时,问题就开始了。
root@Ubuntu:~# useradd -m user
root@Ubuntu:~#
root@Ubuntu:~# passwd user
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@Ubuntu:~#
root@Ubuntu:~# su user
user@Ubuntu:/root$ id
uid=1003(user) gid=1003(user) groups=1003(user)
user@Ubuntu:/root$
Run Code Online (Sandbox Code Playgroud)
ifconfig在新用户中找不到。
user@Ubuntu:~$ ifconfig
-su: ifconfig: command not found
user@Ubuntu:~$
Run Code Online (Sandbox Code Playgroud)
临时解决方法是从完整路径执行它/sbin/ifconfig
user@Ubuntu:~$ whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
user@Ubuntu:~$
user@Ubuntu:~$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr AA:AA:AA:AA:AA:AA
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
user@Ubuntu:~$
Run Code Online (Sandbox Code Playgroud)
ifconfig未找到,因为/sbin在新用户环境中不再配置。
user@Ubuntu:~$ echo $PATH
/home/user/bin:/home/user/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
user@Ubuntu:~$
user@Ubuntu:~$ …Run Code Online (Sandbox Code Playgroud)