Edit /etc/passwd correctly
In my recent guides, you might have noticed that I sometimes edit /etc/passwd
directly with vi
or nano
. This is not advised behavior. The main reason being the possibility of file corruption and other users making changes to their account while you are editing. The latter is not very likely to happen as I am the only user on the system. In any case, here's how to do it more properly.
Use vipw
vipw is a command line utility designed to make edits to the /etc/passwd
file and prevents corruption by setting appropriate locks. You will need elevated privileges to edit /etc/passwd
.
$ sudo vipw
It might ask you to pick an editor you want to use, usually nano
or vi
. Choose which one you prefer and the file will open, ready to be edited. I usually do this to edit shell for a service user, but do whatever you like.
No Comments