8

Is this a trap? I made these steps in FreeBSD 10:

1) ssh as root prohibited

2) logged as user

3) su as root

4) as root chsh changed name of user "user" to "luser"

5) exit from root

And from this moment I can't su root cause the luser is not in the wheel group and I can't change group in /etc/group because I have no privileges for doing that.

What can I do to login as root ?

migrated from serverfault.com Mar 7 '14 at 1:34

This question came from our site for system and network administrators.

22

You can do any one of these four things:

  • Log in as a user that is in the wheel group and fix it from there
  • Log in as root from the console/ILO
  • Boot off of a CD, mount /etc and fix /etc/group
  • Restore /etc/passwd and /etc/shadow from the most recent backup
3

There is no need for live cd or usb stick. You could boot into single user mode, mount the filesystems mount -a and set/change the root password passwd

Single user mode is a mode for just one user, root. You can boot into single user mode without typing in the root password.

In BSD booting into single user mode is usually an option in the boot menu.

In linux booting into single user mode could be achieved by setting single as a kernel option. (e.g. in grub, select the boot line, press e to edit, change the init parameter, press c to continue booting.)

In LILO using the LILO boot prompt (press [Ctrl]-[x] if you're in a graphical interface) and type linux single

If this doesn't work for an old kernel, you can also specify --init=/bin/bash then you get a root bash shell.

2

You can boot from a live cd or usb drive, mount your system partition, modify the nessecary files, boot your system again.

Your Answer

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