Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up sudo on my FreeBSD server. As I now never want to log in as root anymore, I was wondering whether I should do sudo pw lock root.

My questions are:

  • Is this possible, without forever disabling my machine?
  • Is it a smart idea, or is there a good reason to not do this?
  • Will I still be able to do sudo su to get a root shell?
share|improve this question
This is actually the default configuration for Ubuntu: root account is locked, and sudo prompts for your own password. Running sudo to run su as root to run a shell as root is also redundant; just use sudo -s. – psusi Nov 29 '11 at 14:56
up vote 5 down vote accepted

I actually did this on my FreeBSD box - so yes, it is possible, but of course you should take care to verify that sudo works properly before you do so ;-)

sudo su will not work anymore, but you can still do sudo bash to get a root shell.

share|improve this answer
or sudo -s will also get you a shell – psusi Nov 29 '11 at 14:55

It's possible, yes.

But it's not a very good idea. Locking out the account is equivalent to setting an absolutely unguessable password. You might as well set a practically unguessable password, i.e. one with sufficient entropy (128 bits, which comes out to 20 random printable ASCII characters, is massive overkill), and keep that password in a safe.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.