How to change the root password in Linux

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.

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.

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.

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.

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.

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

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

$ sudo bash
OR
$ 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.

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.

Add Comment