0
[root@Acheron ~]# systemctl status shadow
● shadow.service - Verify integrity of password and group files
   Loaded: loaded (/usr/lib/systemd/system/shadow.service; static; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2019-05-14 13:59:34 EDT; 1s ago
  Process: 25502 ExecStart=/bin/sh -c /usr/bin/pwck -r || r=1; /usr/bin/grpck -r && exit $r (code=exited, status=1/FAILURE)
 Main PID: 25502 (code=exited, status=1/FAILURE)

May 14 13:59:34 Acheron systemd[1]: Started Verify integrity of password and group files.
May 14 13:59:34 Acheron sh[25502]: user 'netdata': directory '/home/netdata' does not exist
May 14 13:59:34 Acheron sh[25502]: pwck: no changes
May 14 13:59:34 Acheron systemd[1]: shadow.service: Main process exited, code=exited, status=1/FAILURE
May 14 13:59:34 Acheron systemd[1]: shadow.service: Failed with result 'exit-code'.

This user should not have a home directory. I'd like to update its entry in /etc/passwd to remove the home directory. I could edit this file directly, but that seems unsafe. Is there a better way?

John M.
  • 111
  • 1
  • 5
  • It seems the question should rather be called: "which home directory I must specify for the user who doesn't login into system interactively". The "remove" in the title must have meant "remove information about the location of home directory from the system account database". The "own" answer below only mentions change in the user settings and no removals of data. – Nikita Kipriyanov Apr 07 '21 at 06:14
  • @Nikita Kipriyanov thanks I've updated the title. – John M. Apr 15 '21 at 12:58

3 Answers3

1

Looking at other entries in /etc/passwd it seems that users "without a home directory" actually just have their home directory set to /.

I used usermod -d / netdata to update the user's home directory to match.

John M.
  • 111
  • 1
  • 5
0

It depends on your intent. Do you want the user to log in with an interactive shell, or do you want the user account to be unusable via normal means of logging in? I don't have the reputation to comment to your question directly, ergo I'm asking clarifying questions via an 'answer'.

0

Your intent seems to be to ensure the user account exists, but is unusable for the purpose of logging into the system.

Assuming I am correct, there are three steps I would take.

  • Modify the user record and specify a shared home directory
  • Modify the user record and specify a 'nologin' shell
  • Remove the user's previous home directory.

First delete the user's home directory (it is important to do this before you change the user's home). rm -rf ~username

The first two can be achieved using the usermod command: usermod -d /new/shared/directory -s /sbin/nologin

Note, when creating new accounts using useradd you can specify these options (and many more).

Usermod examples, for the most part useradd works the same