因此,我正在使用 chroot 进入 debian bootstrap,一切在 root 帐户下工作正常,直到我添加了一个新用户,才发现我无法更新或访问 xdisplay 或 localhost ip,这很奇怪,我不知道该怎么做,所以我寻求帮助,这是我正在使用的 chroot 脚本
~ $ cat chroot.sh
sudo mount -t proc /proc chroot-ubuntu/proc
sudo mount --rbind /sys chroot-ubuntu/sys
sudo mount --rbind /dev chroot-ubuntu/dev
sudo mount /system/ chroot-ubuntu/system/
unset LD_PRELOAD
env -i HOME=/root \
PATH="/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games:/opt/wine-5.3/bin/:/opt/wine-staging/bin/" \
TERM="xterm" \
BASH="/usr/bin/bash" \
SHELL="/usr/bin/bash" \
PREFIX="/usr" \
MDIR="/tmp" \
LD_LIBRARY_PATH="/lib:/usr/lib:/usr/lib/i386-linux-gnu/:/var/lib:/var/lib/dpkg/:/lib/i386-linux-gnu:/usr/local/lib:/opt/wine-stable/lib:/opt/wine-stable/lib/wine:/opt/wine-5.3/lib:/lib:/lib/wine:/lib/wine/fakedlls:/opt/wine-staging/lib" \
chroot chroot-ubuntu/ /bin/bash
我使用 sudo 执行 chroot.sh 所以我总是进入 root 帐户让我们添加一个新用户我得到这个奇怪的输出
root@localhost:~# adduser g
Adding user `g' ...
Adding new group `g' (1000) ...
Adding new user `g' (1000) with group `g' ...
Creating home directory `/home/g' ...
Copying files from `/etc/skel' ...
passwd: user 'g' does not exist
Permission denied
Try again? [y/N]
如果我尝试为新用户添加密码,我会得到
root@localhost:~# passwd g
passwd: user 'g' does not exist
所以我必须手动添加用户(我不记得怎么做了)
这是 root 和用户的 ifconfig 输出
root@localhost:~# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
注意,在用户上执行 ifcnfig 时,inet 127.0.0.1 不存在
spiral@localhost:~$ /sbin/ifconfig
warning: no inet socket available: No such file or directory`
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet6 ::1 prefixlen 128 scopeid 0x10<host>
相反,有warning: no inet socket available: No such file or directory
错误
答案1
这是输出
spiral@localhost:~$ strace ifconfig 2>&1 |grep ENOENT
proot warning: ptrace request 'PTRACE_???' not supported yet
faccessat(AT_FDCWD, "/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/ax25", R_OK) = -1 ENOENT (No such file or directory) faccessat(AT_FDCWD, "/proc/net/nr", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/rose", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/ipx", R_OK) = -1 ENOENT (No such file or directory) faccessat(AT_FDCWD, "/proc/net/appletalk", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/sys/net/econet", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/sys/net/ash", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/x25", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/ax25", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/nr", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/rose", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/ipx", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/appletalk", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/sys/net/econet", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/sys/net/ash", R_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/proc/net/x25", R_OK) = -1 ENOENT (No such file or directory)
spiral@localhost:~$