Home > Computer Tutorials > Computer Knowledge > Log in to Ubuntu as superuser

Log in to Ubuntu as superuser

WBOY
Release: 2024-03-20 10:55:21
forward
1223 people have browsed it

Log in to Ubuntu as superuser

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su - command to log in as root.

The root user is a user with system administrative rights and unrestricted access. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes.

There is a clear difference between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do.

In this guide, I will explore the Ubuntu root user, how to log in as root, and how it differs from a normal user.

Note: For the instructions and commands mentioned in this guide, I am using Ubuntu 22.04.

Ubuntu root user

During Ubuntu installation, a root user without password is created. The root user is inactive to avoid any accidental damage to system files. Therefore, whenever you log into an Ubuntu system, you enter as a normal user, with specific rules. However, this does not mean that you will not have root access. Adding sudo before the command allows you to execute root-specific commands if you have administrative rights.

Root vs Sudo

The root user is the account with the highest authority in the system, and sudo is a command line tool that allows ordinary users to run commands that require root authority with special permissions. In Ubuntu system, if you try to perform an operation that requires privileged access without authorization, the system will display a permission denied error message. This means that your current user rights are insufficient to perform this operation.

However, when as a normal sudo user, inserting sudo before the command, it works perfectly fine.

However, if you are working as root on the system, you do not need to preface the command with sudo to perform system-related tasks.

To run sudo commands, a regular user must be granted administrative rights; see our guide on adding users to sudoers on Ubuntu for more details.

Enable root user on Ubuntu

As mentioned before, the root user is locked into Ubuntu and its flavors. However, you can enable it by setting a password for the root user.

Please note that you cannot perform these steps if you are not part of sudoers.

You can use the passwd command to enable the root user and use root as the username.

sudo passwd root

After executing the command, please set a strong password and remember the importance of the root user. Once a password is set, the root user is enabled and can be accessed.

Log in as super user

To log in to Ubuntu as the root user, open a terminal and use the su command with the dash-, -l or -login option.

Su—

You will be prompted for your password; enter it and you are now logged in to Ubuntu as superuser.

Please note that when you log in to Ubuntu as superuser, the bash shell's typical $ symbol will be changed to a # symbol.

Now, there is no need to put sudo when executing system-related commands or accessing system files.

To restore the identity of a normal user, use the exit or logout command.

Log in as root via Display Manager

The above method only works on the terminal, however, if you want to log in to Ubuntu as superuser using the display manager, you can do that too.

Warning: This method is not recommended because in the case of a malicious attack, you may lose control of the server. You may also cause damage to system files while installing software from unknown sources.

Please note that the following instructions are for Ubuntu 22.04 with GENOME desktop environment and will not work if you do not use GENOME.

The latest GENOME uses the GDM3 display manager by default, so we will use the nano text editor to access the GDM3 configuration file.

sudo nano/etc/gdm3/custom.conf

Type the following lines into the file.

AllowRoot = true

Now, press Ctrl x to exit the file and save changes.

The next step involves modifying the PAM or Pluggable Authentication Module directory, which contains the GDM password file.

Warning: Incorrect modifications may corrupt the pam.d configuration file, ultimately rendering your server inaccessible.

Open the gdm-passowrd file again using Nano editor.

Sudo Nano/etc/pam.d/gdm-password

Use the # sign to comment out the highlighted lines in the screenshot above.

Press ctrl x to exit and save the file.

Now, restart your Ubuntu system and select the unlisted option on the login screen.

Enter the username, superuser, and password created in the Log in as superuser section.

After logging in, open the terminal and you will see the # symbol by default.

Use sudo to log in as root

If you are part of the normal user and administrator groups, or have super user rights (Sudoer), you can use the sudo command to log in as a super user.

苏道-S

or

Sudōi

After executing the above command, the system will prompt you to enter your password. Enter your password (the user password is not the root password).

The username will be changed from your normal name to superuser; use the horami command to know the current username.

Wowwami

Before logging in as root, the username is Sam, but after logging in as root, the username will be changed to root.

There are always security risks associated with active root users. Therefore, I recommend using sudo command to access root user rights.

in conclusion

The root user is the top-level user with all permissions. However, on Ubuntu, the root user is not active by default. To activate the root user, you need to set a password using the passwd command. If a user is already sudoer, the user can use the sudo-i command to become the root user. This guide also mentions a way to enable root login from the GUI, which is not recommended. It is important to note that in many Linux distributions including Ubuntu, the root user is inactive due to security risks. It is recommended to use sudo instead of logging in as the active root user as it is a more secure option. To learn more about su and sudo, use the man su and man sudo commands in the terminal.

The above is the detailed content of Log in to Ubuntu as superuser. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template