我尝试在 /home 中以根用户身份创建一个目录,但出现以下错误:
mkdir: cannot create directory `foo': Permission denied
我已经通过运行检查了权限ls -ld /home
:
drwxr-xr-x 2 root root 0 May 11 10:46 /home/
我还在其他帖子中看到这可能是与安装相关的问题,因此我运行“mount”,这是输出:
/dev/mapper/trusty--vg-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu type cgroup (rw,relatime,cpu)
cgroup on /sys/fs/cgroup/cpuacct type cgroup (rw,relatime,cpuacct)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,relatime,freezer)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,relatime,hugetlb)
/dev/xvda1 on /boot type ext2 (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
我也尝试使用创建一个用户sudo adduser testuser --home testuser
但失败并显示以下输出:
nimbadmin@trusty:/home$ sudo adduser testuser --home testuser
adduser: The home dir must be an absolute path.
nimadmin@trusty:/home$ sudo adduser testuser --home /home/testuser
Adding user `testuser' ...
Adding new group `testuser' (1001) ...
Adding new user `testuser' (1001) with group `testuser' ...
Creating home directory `/home/testuser' ...
Stopped: Couldn't create home directory `/home/testuser': Permission denied.
Removing directory `/home/testuser' ...
Removing user `testuser' ...
Removing group `testuser' ...
groupdel: group 'testuser' does not exist
adduser: `groupdel testuser' returned error code 6. Exiting.
有什么建议吗?如果能解释权限问题的原因,我将不胜感激。
答案1
您可以在Linux中执行以下步骤:
whoami(显示您的用户名)
组 [用户名](打印每个用户名的组成员身份)
sg [组成员身份](在当前进程中更改其调用者的组标识)