11

I have made some changes to /etc/passwd file ,now I wanted to see if the effect of changes taken place or not .What command should I run for that.

For example after making change to /etc/ssh/ssh_config file ,I run /etc/init.d/sshd command.

16

To verify the passwd and corresponding shadow file, use pwck. To verify the group and corresponding gshadow fiile, use grpck'. See the manpages for the details of the actions they perform.

Hand-editting of /etc/passwd is best done (if at all) with vipw and vipw -s for the shadow file. For the /etc/group and /etc/gshadow use vigr and vigr -s, respectively. Using these tools provide not only a lock to prevent muultiple, concurrent user updates but also offer validity checking.

In general, modifications to the password and group files are best made using the standard user(add|mod|del) and group(add|mod|del) tools.

7

There is no such command to apply changes from /etc/passwd file.

If user which details you've changed is logged in, it should just relogin to apply the changes. If not, they will be immediately available after login.

This is because login reads details from passwd file during login and keeps it in memory until logout.

  • 2
    "…no such command…" on Linux. Many other *ixes do have such commands. The passed file is either compiled down to a binary form that's faster to process, or is kept only for compatibility and the data has to be translated into the OS's native password DB form. – Warren Young Nov 23 '13 at 10:59
2

I had success with the update-passwd command after I manually edited the /etc/passwd file on Debian-based systems (e.g. Ubuntu). I know this is NOT the intended use of this command, but it works for this purpose, too. See its man page for more deatails: http://manpages.ubuntu.com/manpages/precise/man8/update-passwd.8.html

On Red Hat / CentOS based systems I did not find an equivalent command, on those systems I had to do a system reboot to make the changes take effect.

As somebody already mentioned, it is best not to edit the /etc/passwd file manually. Instead I use useradd / userdel / usermod commands whenever possible. The only valid reason for editing the /etc/passwd and /etc/group files IMO is when I need to copy over a lot of accounts from another system. After adding e.g. a 100 accounts this way, I usually do a full system reboot. Also, when you manually edit /etc/passwd and/or /etc/groups files you must not forget to edit the appropriate shadow files as well.

1

I dont think there is such command as it's not necessary in the first place Also it's not advisable to edit that file directly, instead use the appropriate commands like useradd and passwd

If you are not convinced then just reboot after editing that file and all the changes will be effective

0

You should not modify /etc/passwd manually; use usermod instead

For example:

If you want to change the user home directory, use this command:

usermod --home /path/to/home/dir username
  • 1
    It's sometimes necessary to edit the file by hand, but then vipw should be used. – Kusalananda Mar 11 '17 at 13:30
  • Got it @Kusalananda – Sun Kuo Mar 11 '17 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.