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
Top Printers and Scanners and Copiers - MiniToolTop Printers and Scanners and Copiers - MiniToolMay 12, 2025 am 12:52 AM

If you want to buy a top printer & scanner, this post lists some best printers and scanners and copiers including some top HP printers and scanners. php.cn Software not only provides useful computer software but also provides various computer tut

How to Run Windows 11 Network Adapter Troubleshooter - MiniToolHow to Run Windows 11 Network Adapter Troubleshooter - MiniToolMay 12, 2025 am 12:51 AM

You can use the built-in Network Adapter troubleshooter in Windows 11 to find and fix problems with wireless and other network adapters. This post teaches you how to find and run Windows 11 network adapter troubleshooter with detailed instructions. S

[Solved] Battlefield 2042 Black Screen Issues (7 Solutions) - MiniTool[Solved] Battlefield 2042 Black Screen Issues (7 Solutions) - MiniToolMay 12, 2025 am 12:50 AM

Battlefield 2042 black screen then crash is an annoying problem when gaming. How to fix it? This guide on php.cn Website aims at tackling this issue. Look it through carefully and we sincerely hope that our solutions will work fine for you.

How to Fix the Dev Error 11557? Here Are 10 Methods! - MiniToolHow to Fix the Dev Error 11557? Here Are 10 Methods! - MiniToolMay 12, 2025 am 12:49 AM

Have you ever encountered Dev Error 11557 in Call of Duty: Modern Warfare 2 or Warzone 2? If you are, you come to the right place. In this post, php.cn provides some potential solutions to help you fix this error.

How to Cancel Apple Music Subscription on Android/iOS Devices? - MiniToolHow to Cancel Apple Music Subscription on Android/iOS Devices? - MiniToolMay 12, 2025 am 12:48 AM

If you want to cancel your Apple Music subscription, there are several ways to do so. This post from php.cn tells you how to cancel your subscription using your iPhone, iPad, Android device, Mac, or the Apple TV.

Compare All Microsoft 365 Plans and Choose a Preferred Plan - MiniToolCompare All Microsoft 365 Plans and Choose a Preferred Plan - MiniToolMay 12, 2025 am 12:47 AM

Microsoft 365 offers several subscription plans for you to choose from. This post introduces and compares all Microsoft 365 plans. You can choose a preferred Microsoft 365 plan based on your own needs. To recover deleted or lost files like Office fil

VLC Black Screen? A Guide to Fixing 'VLC Not Playing Videos” - MiniToolVLC Black Screen? A Guide to Fixing 'VLC Not Playing Videos” - MiniToolMay 12, 2025 am 12:46 AM

The VLC media player is a free and open-source, portable, cross-platform media player software and streaming media server, which is available for desktop operating systems and mobile platforms. But some people find the “VLC not playing videos” issue

Microsoft To Do Download for Windows 10/11, Mac, Android, iOS - MiniToolMicrosoft To Do Download for Windows 10/11, Mac, Android, iOS - MiniToolMay 12, 2025 am 12:45 AM

To manage your daily tasks, you can use the free task management app - Microsoft To Do. This post teaches you how to download Microsoft To Do on Windows 10/11, Mac, iPhone/iPad, or Android. If you are looking for more computer tips and solutions, you

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 Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version