LINUX: Set root password

31 01 2009

So, this isn’t tough stuff, but any gui-loving user will find themselves in shambles when put in front of a l?[ui]n[iu]x (pardon the regex) terminal.  That is to say that it’s OKAY if you’re good “at computers”, yet you can’t fumble your way around a unix-style terminal.

I recently set up my own headless (no GUI) Ubuntu Linux, 8.10 server edition on an old computer I have lying around.  I decided that making it run Apache and my personal SVN repositories (while doubling as a 160gb backup drive 🙂 ) was a good idea.  Problem is, after I got it all set up, I of course have no decent programs, and suddenly find myself wanting to browse the web on my new server box, to find the appropriate urls to feed to the ‘wget’ command.  And I’m tired of pushing my monitor’s “switch input source” button.

By default, Ubuntu tries to abstract the root account from you by letting you perform “root”-ish operations with your own account, using the sudo command.  But sometimes I just want to be root for an effing minute while I do stuff.  By default, Ubuntu comes with no password on the root account, meaning that it also won’t let you sign in with it directly.  Blank passwords are a no-no.

$ sudo passwd root

^^ that ‘$’ is the intrawebs’ way of saying “this is the start of a unix command-line thingy”.  And that’s the technical term, trust me.

This is actually the command to change ANY user’s password, but it just so happens that you’re changing the root password, so you of course need  the all-powerful pixie dust of the “sudo” command.  If you were root already, or some other empowered user, you would only have to type:

$ passwd USERnameGOEShere

And it would prompt you for the new password.  But again, if you don’t have good enough authentication, it’ll make you do “sudo” in front of it, or be root altogether.

As pointed out by Dave in the first comment below, the “sudo -s” command is a way to obtain sudo permissions for a more extended period of time.  If that’s all you want, then go for it.  But if you’re looking to actually give the root account a password, then you’ve gotten your instructions already.




2 responses

14 02 2009

Hey there,
I dunno if you’ve come across the command sudo -s, but that will let you stay running with the sudo permissions. I don’t remember where I learned that, but I too do a BUNCH of stuff needing root permissions and that command is a life saver.

Just figured I’d pass that along.

14 02 2009

Very true– And it’s nice to do it that way. In the end, as the soul owner of my own little headless linux server box, I wanted to just have the root account under my control if I need/want it.

Generally, best practice always states that your should keep yourself with as few permissions as possible, so as never to have too much power. In a networked/multi-user environment, that makes sense.

But ultimately, this command is for setting the password for anybody, not just the root account.

I’ll update the post, though, to reflect all this stuff, including your suggestion.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: