-Mを設定しても常にホームディレクトリが表示されます。

-Mを設定しても常にホームディレクトリが表示されます。

私はdebian 10を使用しており、ホームディレクトリなしでユーザーを作成したいと思います。ユーザーは自分のグループが所有するディレクトリにのみアクセスできる必要があります。つまり、ユーザーは自分のグループディレクトリにのみアクセスできます。私のコマンド情報は次のとおりです。

useradd -g mygroup-G mygroup1,mygroup2 -s /bin/bash -M username

しかし、パテを介してシステムにログインしてlsコマンドを実行すると、ホームフォルダが表示され、そこにcd入ります。

-Mホームフォルダの作成を防ぐ必要がありますが、なぜこれが可能なのか理解できません。

ベストアンサー1

どのシステムを使用しているのか分かりません。 CentOS-7でこれをテストしましたが、予想通りうまくいきました。

[root@localhost ~]# useradd -M bruce
[root@localhost ~]# grep bruce /etc/passwd
bruce:x:1002:1004::/home/bruce:/bin/bash
[root@localhost ~]# su - bruce
su: warning: cannot change directory to /home/bruce: No such file or directory
-bash-4.2$ pwd
/root
-bash-4.2$ exit
logout
[root@localhost ~]# passwd bruce
Changing password for user bruce.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# ssh bruce@localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:O9p/h/nXgzhoxJragsnRHhqv/r0er1OCvIyML5X3/+4.
ECDSA key fingerprint is MD5:58:0e:65:19:0f:d9:78:8b:2d:a1:00:11:3a:c2:0b:c9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
bruce@localhost's password:
Last login: Fri Feb 19 22:00:56 2021
Could not chdir to home directory /home/bruce: No such file or directory
-bash-4.2$ pwd
/
-bash-4.2$

おすすめ記事