Graphical root logins are not supported. This is separate from root logins in general, which work fine when enabled, though we usually discourage them since sudo
gives you the same power and has some advantages (see below).
The specific mechanism that's stopping you from logging in graphically as root--assuming you're entering root's password correctly--is that your display manager is configured not to allow them. You could attempt to reconfigure it so it does (your display manager is probably GDM). But even if you do, graphical root logins are likely to work very poorly if at all, because this is not a use case that is supported or tested in Ubuntu.
Graphical root logins should also be avoided because they involve running a lot of stuff as root unnecessarily. Even if they worked perfectly, users would still be well-advised never to use them under any circumstances. (This is why no effort has been undertaken to make them work in Ubuntu.)
When you log in graphically, you should do so as a non-root user. When--if--you log in as root, you should, and can, do so non-graphically. Although you could use the same method you used to set a password for root to set one for another user, you don't have to. Since you've enabled root logins, you can set a password for a non-root user efficiently and without rebooting:
Switch to a text-based virtual console by pressing Ctrl+Alt+F2.
(In general, Ctrl+Alt+Fn switches to the virtual console ttyn
. When the virtual console you're switching from is text-based, you can omit Ctrl from this key combination, though you don't have to.)
Log in by entering root
as the username and the password you set for root as the password. This is a non-graphical login. Based on the information you've provided, there's no reason to expect this to fail.
Run passwd user
to set a password for some non-root user account user
. Replace user
with the actual username.
Or run adduser user
to create a new user user
. Enter the requested information. The real important bit is the password, though most people will want to put something in for the full name field too.
Switch back to the virtual console on which the GUI is running. This is usually tty7
, so press Ctrl+Alt+F7.
Log in as the user whose password you set.
Since you have the root account enabled, you can run su
in a terminal to get a root shell from which you can run commands as root. Use su -
if you want this to behave as an initial login shell. The shell you get from su
or su -
lasts as long as you like (i.e., until you run exit
in it or otherwise quit it), but it is best to use it only for administrative tasks that a non-root user couldn't directly perform. su -c 'some-command'
runs a single command as root rather than starting a shell. (When some-command
is just one word, i.e. when there are no command-line arguments, you can omit the quotes.) When you use su
, you enter root's password, as you would when logging in as root. You must enter it each time you run su
.
With that said, sudo
and pkexec
--rather than root logins and su
--are the generally recommended way to perform administrative actions on Ubuntu. I recommend you consider adding a non-root user to the sudo
group (an existing user or a new user), which makes that user an administrator. Then that user can run commands as root with sudo
(and pkexec
). One way to do this is to run usermod -a -G sudo user
in step 3 above. Or perhaps your existing non-root user account is already in the sudo
group; you can run groups user
to check.
To run a command as root with sudo
, you would usually use sudo some-command
. Even when some-command
consists of multiple words, it need not (and must not) be quoted. This is one of the ways that sudo
is easier than su -c
.
You also do not have to enter your password every time; instead, you need only enter it to use sudo
in a terminal where you have not used sudo
in the last several minutes. This way, it is efficient to run commands as root only when you need to, because you can interleave sudo
commands with other commands, without having to type your password many times as you would with su -c
instead of sudo
, and without ending up running all commands entered into that terminal as root, as you would if you used su
to get a root shell.
If you do want a root shell, you can get one with sudo -s
, which is much like what you get from su
, or sudo -i
, which is virtually identical to what you get with su -
.
When you use sudo
, you enter your password, not root's password. Therefore root need not have a password set; the root account can be "disabled," yet you can still run commands as root with sudo
.
If you decide to switch entirely to this recommended method--that is, if you administer your system in the way most Ubuntu users (and a sizable fraction of Debian users) do--then you can then re-disable root logins by running sudo passwd -dl root
. This will keep you from logging in as root or becoming root with su
, but you can still become root with sudo
, including with sudo -i
.
passwd
instead ofpassword
? – jake Nov 08 '19 at 11:08