It is the policy of the Ubuntu distribution that all actions that require administrative privileges must be performed using the sudo command. It is dangerous for newbies to use the root user as the main user, because they are still poorly oriented in the system and may forget that they are logged in as root and delete something important.
And since it is almost impossible to recover files deleted using the rm command, it is better not to let newbies go there. But sometimes it becomes necessary to log in as root. In this short article, we’ll look at how to do this.
How to log in as root in Ubuntu
For the reasons described above for the root user, the password in Ubuntu is not set by default, so you cannot just log in on his behalf using the virtual consoles available on Ctrl+Alt+FN or using the su utility. Since there is no password, you cannot enter it correctly.
su - root
But it’s all very easy to get around. In order to log in as root in the terminal, just add sudo before the su command:
sudo su - root
You can also use the -i option to sudo to open the console as superuser:
sudo -i
However, if you want to log in on behalf of this user in the virtual console or via SSH, then you must first set a password for him. To do this, run:
sudo passwd root
Then enter the password twice. After that, the root user becomes almost a full-fledged user of the system. You will not be able to just enter the GUI under it, because this is limited by the Gnome shell itself, it is very bad practice to run a whole shell as root.
But if you really want to, you need to tweak the PAM rules for GDM a little. To do this, open the file /etc/pam.d/gdm-password and comment out the line there:
sudo vi /etc/pam.d/gdm-password
After that, you will be able to log in as root in the login manager. Just click on the item Not in the list, and then enter the login root:
You will see a shell launched as superuser
This is very insecure, because any program can do whatever it wants with your computer and no one will stop it. In fact, the first versions of Windows also worked in this mode, and therefore they were very vulnerable to viruses.
Comments