Methods of payment Abuse

Root in Ubuntu

23.07.2021, 22:37

The Ubuntu distribution policy is such that any user actions and decisions requiring administrative privileges are performed only with the sudo command. No one recommends using root for a beginner, because a novice user is not well oriented in the system and may forget that he is logged in as root and delete an important file. In Ubuntu, it is impossible to restore files after deletion with a single command of the rm command, which means that there is nothing to do for a beginner in root. But sometimes there is a need to log in as root user.

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 can't just log in as root using the virtual consoles available by Ctrl+Alt+FN or using the su utility. Since there is no password, you will not be able to enter it correctly.

Execute:

$ su - root

The truth of the matter is circumvented. To log in as root user in the terminal, just add sudo before the su command:

$ sudo su - root

You can also use the -i option of the sudo command to open the console as root:

$ sudo -i

If you want to log in as this user in a virtual console or via SSH, you must first set a password for this user. Execute:

$ sudo passwd root

Enter the password twice. After that, the root user becomes almost a full-fledged user of the system. It will not be possible to log in to the GUI under it. This is a limitation of the Gnome shell itself, and it is very bad practice to run an entire shell as root.

But if you really want to, you can customize the PAM rules for GDM a bit. To do this, open the /etc/pam.d/gdm-password file and comment out the line there:

$  sudo vi /etc/pam.d/gdm-password 
# auth required pam_succeed_if.so user != root quiet_success

Now you can authenticate as root in the login manager. Just click on No in the list, and then enter the root login:

Next, you will see a shell running as superuser:

Keep in mind that this is dangerous, as any program can do absolutely anything to your computer. The first versions of Windows ran in this mode too. And we remember how vulnerable and weak they were to hacker attacks.