Changing Shell Manually - FreeBSD 7.2

Hi All,

Some pleasantries, as this is my first post here - Nice to meet you all, I have been following this community for so long now, and find it wonderful... And thanks to the nice pplz around :)

ISSUE

I am running FreeBSD 7.2 i386 in ESXi.

I tried to change the default shell of user (say user1), I logged in as root and edited the /etc/passwd file and set the /bin/sh to /usr/local/bin/bash. The user (user1) logged on and complained it didn't change and was still using /bin/sh, but when he manually executed bash it worked fine. So I asked her to use chsh and that worked fine.

How is it that it didn't work when I (as root) modified the passwd file!!! Its strange, I have worked on some Unix / Linux machines and it hadn't failed me earlier. Very Strange - any guesses!!!

Thanks,
A I
 
You will need to edit the password file with 'vipw' or use the 'pw' command.
The passwords are kept in a database you can make with 'pwd_mkdb'
The real password file [with encrypted passwords in it] is '/etc/master.passwd' - Only readable by root.
 
As already mentioned, the database has to be rebuilt.

Or you can use chpass(1) or any of its hard-linked brothers. They can be ran interactively by editing the file or in a single command with the -s option.
 
Never, ever, edit /etc/passwd directly. When conditions are right you will end up with an empty file! Use one of the many tools to manipulate it, vipw, pw, chsh, etc.
 
Even if you did edit /etc/passwd directly and created a empty file, there is hope assuming even if /etc/master.passwd is gone as all you need to do is use the master.passwd.bak from /var/backups by copying it to /etc/master.passwd. Assuming, you didn't have the backups either, you can still regenerate the /etc/master.passwd from /etc/spwd.db. /etc/passwd and pwd.db in reality could be hosed as master.passwd and spwd.db are the files you are concerned about since once you have master.passwd, all you have to do is vipw and then save and you'll have spwd.db, passwd, pwd.db.
 
Back
Top