Dont edit /etc/passwd

From FBSD_tips

Jump to: navigation, search

Don't edit /etc/passwd manually.

A fairly frequent problem for people who come to FreeBSD from other Unix variants is the tendency to edit /etc/passwd manually in order to change a user's shell, home directory or other parameters.

In FreeBSD, /etc/passwd is used only for historical reasons. It is not the file containing the effective user records - this file is the master passwd file, stored in /etc/master.passwd. This file contains the password hashes just like /etc/shadow does in classical shadow password systems, and all other user information is read from here. /etc/passwd is in fact generated from the master.passwd file.

This does of course mean editing /etc/passwd will not have the effect you have probably been expecting when you edited it. Now, don't edit the master.passwd manually either - FreeBSD has a set of tools that will help you execute the respective administrative tasks while preventing inconsistencies.

To change a user's login shell, you can use chsh(1), which is the same executable as chpass(1). The most important utility however is pw(1), which allows basically all administrative tasks involving user and group management to be performed without ever manually editing a file.

pw(1) sports a very illustrative and extensive manpage, which is very much recommended reading for anyone dealing with a FreeBSD system. Its sheer size may seem overwhelming at first, but you get used to it very quickly.

Oh, and please remember when you change your shell: Don't set root's shell to a non-default entry if you don't like walking to your data center.

For further reference, also see the passwd(5) manpage.


Pandzilla 18:07, 22 October 2007 (UTC)

Personal tools