How to Login to Ubuntu as Root User?

At times where Linux provides a secure and healthy environment for users, it makes other things even more complicated and intricate. Despite being such a user-friendly operating system, it is not that easy to login to Ubuntu as a root user.

Root user has all the administrator privileges so whenever you need to edit system files or configuration from within Gnome, you will feel the need to login to Ubuntu as a root user. But the question is here is "How to login to Ubuntu as a root user?"

Just follow the steps below:

  1. Open the terminal and type:
    sudo passwd root
  2. When you see the prompt that says "Enter new UNIX password", enter the password you want for the root user and confirm it.
  3. Type:
    sudo gedit /etc/X11/gdm/gdm.conf
  4. Locate the line that says "AllowRoot=false". Change it to "AllowRoot=true".
  5. Save the file
  6. Exit gedit, logout and then reboot.

I used the same method when I wanted to login as root user to edit configuration files of my graphics card and everything worked great. However the only issue in this case is that by logging to Ubuntu as root you are making your operating system more vulnerable.

For Ubuntu users it is recommended to use the account which they created on time of install and use the "sudo" command while in terminal to execute commands as root user.

  • Bad bad bad idea, really.

    Never run X with root's power, there isn't a reason to do that. If you need to configure something as root-root use sudo properly: 'sudo -i'
  • Mike
    I aggree that you should not login to X as root. But Ubuntu style to use sudo is very bad bad bad idea too. If you always login using user who has sudo rights it's even more dangerous than to login as a root.
  • Michael
    You say to edit the gdm.conf file to allow root log in. Well you can edit the "Log In Window" settings under the System > Administration menu you to do this easier. Under the "Security" tab enable "Allow local system administrator log in".
  • boss
    I agree with Michael's idea
    It worked.
  • Matthew
    Actually thanx a lot Michael...my linux system stuck and I couldn't install nothing...now its cool :D
  • jason
    I tried this but sudo gedit /etc/X11/gdm/gdm.conf just opens a blank page with no text ???
  • r jesse
    hi Jason
    i tried sudo gedit /etc/X11/gdm/gdm.conf and it didnt work for me either! BUT: there is a better way to just do that! guess what: go to prompt and type:

    $locate gdm.conf

    where you will get something like:

    /etc/gdm/gdm.conf
    /etc/gdm/gdm.conf-custom
    /etc/gdm/gdm.conf~
    ...etc

    to me the above was my output.

    this gives you a whole lots of locations where files with name *like* gdm.conf can be found. THIS IS THE FILE WE NEED TO EDIT.

    you can tell from the listing that the first option is the one we r after (or it depends on your output but look for EXACTLY "gdm.conf" file), so you can go for you gedit command now: remove the /X11/ and type it like:

    sudo gedit /etc/gdm/gdm.conf

    ..there we r...

    r jesse
    Dar.
  • Sus
    Michael
    April 20, 2008 at 6:51 pm

    You say to edit the gdm.conf file to allow root log in. Well you can edit the “Log In Window” settings under the System > Administration menu you to do this easier. Under the “Security” tab enable “Allow local system administrator log in”.
  • whysoserious1
    there is no security tab in administration menu please help me i want to copy one file in "bin" folder but error is occur when coping u r not owner how i can copy that file in bin folder
  • Itchyfinger
    I wish people would get the facts straight before they go bleeting one way or the other on how something impacts Ubuntu system security, because it's important for all users, new and old, to know the straight dope. Not only do they need it explained in non-superstitious terms what they can and can't do while logged in as user or root, but they need better justification for the restrictions in play. It takes this sort of review process to perfect a system, and the perfect system is NOT the most secure one - fact is that the most secure system is also the most useless.

    While I know only a little myself, being a fairly new user, I went and tried tried the first fix before forming my opinion! The result is that I no longer get some asinine hassle when I want to browse partitions which are BY DEFAULT less security-sensitive than my system partition, and since you don't need root priveleges to write to your system partitions in Ubuntu (not so with other distros), Then I want to know what were you Ubuntu Engineers thinking in making an issue of browsing secondary partitions?

    Anyway, despite being able to browse your own files while logged in as root, you still can't change your system files without the sudo command - I tried that, and it won't let me. Very strange, but that's how it works.
  • Itchyfinger
    In summary (see above), total write-access does not exist any more (or any less) between a logged-in user and logged-in root user without the use or the sudo command, and then the only thing which non-root-user-status can make particularly difficult is access to partitions not containing his system (unless of course the system is on a separate partition from his home directory).
  • this is cool man
  • ihateubuntu
    sudo: gedit: command not found
  • tmath
    Take out the colons, ihateubuntu. Just type in sudo gedit, no extra punctuation.
  • Donald
    it says command not found....now what
  • Nick
    thank you!
  • binay
    i just got ubuntu as my os i wanna remuve it plz help me out
  • sathiskumar
    iam trying this cmd.bt not open the root user.its saying gtk-warring cannot open display.how can i open root account????????
  • Debian-root
    The power of root is almighty and easily can render a system useless. That is one way of learning. However there are instances where root login is needed, not only to do admin tasks, but to create files/folder with the owner root. A mate is frustrated as he can not make apps work on the iPhone using Ubuntu, but I can using Debian. There is nothing wrong with his files, but iPhone only except files with root ownership. If you can not login as root you do not get root ownership of files, at least not very easy.
  • JohnSmith
    Why did they even make it this difficult?
    Say what you want about windows but at least they dont treat you like a child.
    It's my computer. Let me do what I want without this sudo bs.
    That is all.
  • quad
    desktop:~$ sudo gedit /etc/X11/gdm/gdm.conf

    (gedit:2958): Gtk-WARNING **: Unable to locate theme engine in module_path: "ubuntulooks",
blog comments powered by Disqus