search
HomeComputer TutorialsComputer KnowledgeLog in to Ubuntu as superuser

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!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
How to Fix Attachment Not Showing in Outlook 365?How to Fix Attachment Not Showing in Outlook 365?Apr 19, 2025 am 12:50 AM

Do you have trouble downloading or sending attachments in Outlook 365? Sometimes, Outlook doesn’t show them for some unknown reason, so you are unable to see them. In this post on php.cn Website, we collect some use tips for attachments not showing.

How to Fix V Rising Connection Timed out? Here Are 5 Solutions! - MiniToolHow to Fix V Rising Connection Timed out? Here Are 5 Solutions! - MiniToolApr 19, 2025 am 12:49 AM

When V Rising players try to join a server that is close to or already full, they may encounter the “V Rising connection timed out” issue. If you are one of them, you can refer to this post from php.cn to get solutions. Now, keep on your reading.

How to Turn on/off Real-Time Protection in Windows Security? - MiniToolHow to Turn on/off Real-Time Protection in Windows Security? - MiniToolApr 19, 2025 am 12:48 AM

Windows supplies real-time protection via Windows Security. But this feature may prevent you from doing something it thinks are dangerous. In this situation, you may want to temporarily turn on real-time protection. This php.cn post will show you how

Windows 11 24H2 or Windows 12? Does This Matter?Windows 11 24H2 or Windows 12? Does This Matter?Apr 19, 2025 am 12:47 AM

Microsoft has started working on next year’s Windows updates very early. Recent rumors state that the next update in 2024 might be Windows 11 24H2 rather than Windows 12. Everything is uncertain now. php.cn will now take you to see some related infor

Fix: Unable to Perform Requested Operation – Error 0x80030001 - MiniToolFix: Unable to Perform Requested Operation – Error 0x80030001 - MiniToolApr 19, 2025 am 12:46 AM

The error 0x80030001 often happens when you are attempting to copy files. The error code will be accompanied by a message that tells “unable to perform requested operation”. If you are struggling with this error, you can read this article on php.cn W

How to Download and Install Windows 11 KB5034765How to Download and Install Windows 11 KB5034765Apr 19, 2025 am 12:45 AM

On February 13, 2024, Microsoft released KB5034765 (OS builds 22621.3155 and 22631.3155) for Windows 11 22H2 and Windows 11 23H2. This security update brings you many new improvements and bug fixes. You can learn how to download and install Windows 1

Power Management Tab Missing from Device Manager - Top GuidePower Management Tab Missing from Device Manager - Top GuideApr 19, 2025 am 12:44 AM

Device Manager is widely used when you need to fix some computer issues. You can check the problematic devices and decide to uninstall or update device drivers. Besides, you can also set Power Management settings in Device Manager. However, you may f

2 Ways to Reset Windows Backup to Default in Windows 11/102 Ways to Reset Windows Backup to Default in Windows 11/10Apr 19, 2025 am 12:43 AM

When Backup and Restore (Windows Backup) fails to work, you can choose to reset it to default. How to restore Windows Backup to default in Windows 11/10? php.cn will guide you to easily do this thing in 2 ways and let’s go to see them.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool