no root login after changing shell
jerrymc at clunix.cl.msu.edu
Thu Aug 28 07:22:30 PDT 2003
> What about the toor user?
> I think it has no shell associated.
> Hope that helps. bye.
> i wanted to change the shell for user root to bash.
> in the freebsd online handbook i found this command:
Don't set a password on the real root account or log in to it.
For some little measure of safety, leave it starred '*' out.
Just make your own root account if it is your machine and you
will have the ability to have a root account. Use 'vipw' to
edit the passwd file - it also updates master.passwd when you
exit and write changes.
Copy the entry for toor and replace the username and the
information fields and the home directory and shell fields.
Then set a password for this account and create the home directory
and make sure the shell is in /etc/shells.
The gory details in an example:
Lets say your name is Clyde.
- Make yourself root -
either su, or go to single user and mount everything or whatever.
- use vipw to edit the passwd file. Make a copy of the toor entry
(Don't modify toor itself for reasons of cleanness and to avoid
possible problems (unlikely nowdays, but) during upgrades.
NOTE: Fields in the passwd file are separated with a colon (:).
- then edit the _copy_ to change the username field from toor to Rclyde
- Leave the uid and gid fields the same.
- Modify the field that says something like 'Bourne-again Superuser'
to say something like 'Clyde root account' (just for information)
- modify the home(login) directory field that says /root to be /root/Rclyde
- add /usr/local/bin/bash or whatever shell you want after the last (:)
NOTE: Do not add another colon (:) after the shell field
- write changes and exit the editor ':wq'
- set a password for Rclyde 'passwd Rclyde' - make sure you include the
username Rclyde because otherwise you will set the real root's password.
- Create the home directory for Rclyde 'mkdir /root/Rclyde'
- use some editor, probably vi to edit /etc/shells and make sure
that /usr/local/bin/bash is listed.
Now you should be able to log in as Rclyde with a root ability account
and have bash as your shell and not skrew up root's shell which should
stay /bin/sh for those times it is needed, as in when you are cleaning
up some mess that can only be done in single user with none of the other
filesystems mounted. You can also set up a nice convenient environment
with .login, .bashrc, .cshrc, etc depending on shell and what you like,
that suits you and doesn't make the real root requite stuff that might
not be available when you are cleaning up messes in single user.
NOTE: I don't use bash and haven't installed it, so if it installs
somewhere other than /usr/local/bin/bash, make sure you use
that instead of what I put in this example.
More information about the freebsd-questions