How to change the root password in Ubuntu

As default Ubuntu has no password set for the root user. To gain root access you have to type in your own user password. This is the password you set for the first user while installing Ubuntu.

To manually set a password for the root user, type in the following in the shell:
sudo passwd

After that you are asked to type in the new root password twice. Finally, your root user has its own password.

Not entirely correct

By default the root user is setup with a random hash during the install of Ubuntu. Having no password for root is a serious security issue of which the Ubuntu security team would NEVER allow.

See for more detail.

Ubuntu is also setup initially with the first user having the right to become root through SUDO by being a member of the Admin group. Subsequent users that need root privileges simply need to be added to this group.

It is advisable to NEVER change the root password from it's default hash for many reasons. If you need persistent root access simply use sudo -i.

You're entirely incorrect.

"It is advisable to NEVER change the root password from it's default hash for many reasons. If you need persistent root access simply use sudo -i."

For those reading this, the above statement is a total load of crap. There's absolutely nothing wrong with changing the root password. The only danger is in forgetting the password, but you're not *that* stupid, right?

Unintentional Consequences

Even the article you point to concedes there are reasons and times when full access to root login is necessary. It even provides examples of when root login is needed and the command to relock the login after enabling.

Other means such as gksu access under nautilus or others like sudo -i have unintended limits and consequences. While applying myself diligently to workarounds might (or might not) eventually get the job done, "eventually" isn't good enough on a system I own, not Debian or Ubuntu. I am, after all, ultimately responsible for this machine and not them.

Simply use a secure password (16+ mixed characters and symbols in my case), do the job, and relock root when done.

When I first started using Ubuntu, it was still relatively easy to bypass sudo and enable root login. It has become increasingly difficult to do so with each new version. This is not a good thing in my opinion.

First comment is full of it

Ubuntu has no root password. The article is correct. The first commenter seems to think "no root password" is the same as "the root password is carriage return." "No root password" means it is 100% impossible to login as root using a password. Proof is in this blog post

Standing as corrected

I stand corrected and learned something new today. Apparently this setup is MORE secure than a hash as it cannot be brute force attacked.

I still stand by the policy of simply using sudo, but every admin has their own way of doing things.

Noob: did I screw myself?

I have some unix experience, but I am new to ubuntu and still in WinXP thought-mode. I recently installed ubuntu and noticed that when I did a sudo the system asked for my password, the user pw that I entered when I installed ubuntu.

That seemed fine, but since my brain is still in WinXP mode, I assumed that my user pw was also my admin pw, which *sort of* happens when you install XP. (Actually when you install XP the root pw is null and your initial account is automatically a member of the admin group.)

So in a ubuntu terminal I changed the root pw:

$ sudo passwd

So now I have a changed root pw, but when I do a:

$ su

I am prompted for a password, but when I do a:

$ sudo su

I gain access to root privileges without being prompted for a password. My concern here is that if someone pawns my machine (through my non-root user account) wouldn't they also be able to sudu su to root privileges without entering a password?

Sorry for the noob question. I do not have a sophisticated knowledge of sudo judo.

root for the common man..

God Please protect me from everybody who is trying to protect me from myself. I find it kind of offensive that I don't get root from the get go.

I build boxes for VoIP applications and network monitoring. I am not a great Sysadmin but its not rocket science. If I mess up I just reload the box. If I mess up a box thats being used or in production I better have an image of that box underneath my desk. Hard drives are cheap and weekly and daily backups are required. I only needed to make that mistake once and I remember the pain so vividly I do not think I will make that mistake again (but I will keep making images and do backups) in case one of my compatriots augers a box in.

I guess this is not the place to ask if I can allow root to log into the gui??

su passwd root
gksu gdmsetup

So if I don't enable root login how should I....

OK, I actually like the idea of not enabling root login. ...and not enabling login for the www-data user...

However, how do I use a tool like Panic's Coda to edit Apache Config files (owner and group root with default permissions 644), and web content (owner & group www-data with default permissions 754)?

Sudo works fine if I'm in a terminal. What's the equivalent for an application like Coda that makes an SFTP connection to move files?

Can be root in Ubuntu


How do I login as root user?
Open terminal and simply type the following command:

$ sudo bash
$ sudo -s

Supply your password and you will become a root user.

You may check by

$ whoami

It will tell you that you are "root"

Then you may log out and log in again by using "root" and your new password. Now, your prompt will always # which is root. In X window, it also mention me as root.

thank you to all

@ kayun
Thank you for this, exactly what I wanted. I suspect this new-found tidbit of knowledge will apply to the mac bash shell as well.

root login


Yours seems to be the only reply which works. I am not a Linux geek yet but it looks interesting. I am told that most Linux versions actually request a root user password on install but Ubuntu does not.

I have been put off Linux in the past by geeks who tell me that windows is rubbish. I think they used to have a point, especially with security issues and hangups but I think it is better now.

I think Unix / Linux strength is that it can be hardened for specific apps like checkpoint firewalls, and renamed of course. Also it is not so heavyweight as windows and can run on lesser hardware.

So I look forward to using Ub more, but with an open mind.


$sudo passwd root Now u see

$sudo passwd root

Now u see it asking for the new password for root. So reset it and Enjoy :)

$su root
Give the new password that you have entered

Yeps, this post is not entirely correct

I suggest to you all, dont change the "random" root password that've been set by default. Its the feature that offered by Ubuntu, security. You still can do "root mode" just by type "su" before your command. So there's no reason to change the root password.

re: dont change the "random" root password

Security? Whatever. The weak masses are always looking for security. I'll protect myself. Thanks for your advice.

Worked thanks!

Good post, really helped just installed Ubuntu server and wasn't sure about the root password issue. The sudo -i helped!


About blog

I have used it to set root password. For more Linux Tips and Tricks visit

Not working

After inputing command $ sudo -s in terminal ,asks for password then will not allow any further input from keyboard, any suggestions.
Ubuntu 10.04 just installed same and am unable to authenticate anything after reinstalled three times to make sure I was not missing the password I chose.

thanks, was helpful...

thanks, was helpful...

Forgot to...

Hello everyone. I had Kubuntu 10.10 installed on my laptop. When I tried to upgrade to 11.04, I forgot to write down my username and password. Result = the upgrade is finished and when I am asked to login I cannot because I cant remember the username and password. (My previous setting was not to have a login screen....)

Hello, what about a emergency

what about a emergency boot medium (CD)
Log in, mount your root volume, have a look in /etc/passwd what's your user and bail the passwpord out in /etc/passwd AND /etc/shadow?

Have to be root, of course ;)


What security?

sudo is misunderstood soooo often.

It means Switched User DO - not Super User DO.
I work at a large corporate as application administrator.
I have to test if the source systems (another user and group) have delivered their data to the target systems (yet another user and group).

The superuser has setup sudo rules to make it possible to me to see foreign files and directories (sudo -u other_user allowed command).

THAT'S what sudo is for.

If nobody knows the root password, that's odd.
BTW it doesnt add no security. If someone can get MY password and get into the machine. If he can simply do a ``sudo bash -l'' ... where the hick is the added security?


overtly techie

you overtly techie guys has made it so complex , i guess what the guy said is simple and i used it and have been able to access my root directory since i installed ubuntu

need the config network connection password

need the config network connection password-pls

my pc only be used by myself

my pc only be used by myself . so i don't need a new password

oops, no password

So I was setting all the user passwords to nothing, and did so, however, since I was the administrator for my netbook, I set my password also to nothing, and could not access updates or installs. Since there was no superuser password, I did not need the sudo or su command. All I had to do was load up the terminal and type in:


Once I did that, I was able to set the root/administrator password, and I can still log into the computer password free (as well as everyone else).

Hope this helps someone as I pretty much had to figure that one out though those who posted comments on this page.

Thanks for your help everyone.

so easy

sudo su
passwd enter .there you go now enter passwd x 2 .if you are using 12.10 its gkroot.

and why are yous acting like his or her,s mother about root the person wont,s help give it .if the thay crash there computer its one lesion .install again . it may inspire them to learn programing .you dont learn from from bitching .you lean from mistakes.

Just a side note

If anyone is confused with "no keyboard input" or what they are typing is not showing up, the reason for this is that when entering passwords, the terminal won't show any dots, asterisks, nothing.
Type in your password as if dots were showing up and then press enter.

Root password

On a related note, what is the difference between editing and adding a user to the sudoers file and just adding the user to the ADMIN group?