即使以 root 使用者身分也無法寫入 /home 目錄

即使以 root 使用者身分也無法寫入 /home 目錄

我試圖在 /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 中執行以下步驟:

  1. whoami(顯示您的使用者名稱)

  2. groups [使用者名稱](列印每個使用者名稱的群組成員資格)

  3. sg [群組成員身分](變更目前行程中其呼叫者的群組標識)

相關內容