Enable root User Account on Ubuntu

The root Account in Ubuntu is disabled by default because his password is not set. To use root priviledges, basically it’s better to use the sudo command with administrative accounts. But if you’d like to use root Account itself by some reason, it’s possible to use like follows.
[1]The user account added during installation is set an administrative account with Sudo, so it’s easy to get root account’s shell like follows.
ubuntu@dlp:~$ sudo -s
[sudo] password for ubuntu: # input self password root@dlp:/home/ubuntu# # just switched
[2]Or it’s possible to switch to root account with standard su command to set root account’s password.
ubuntu@dlp:~$ sudo passwd root
[sudo] password for ubuntu: # input self password New password: # set root password Retype new password: # confirm passwd: password updated successfully ubuntu@dlp:~$ su –
Password: # input root password root@dlp:~# # just switched
*The examples on this site shows by root user account. If you use Sudo, add [sudo] on the head of commands.It’s better to restrict users who can [su] to root if you enable root account like follows. For using by Sudo, it’s possible to limit to prohibit shells in sudoers config, refer to details about Sudo Settings.
[3]For [su] command restriction, set like follows.
root@dlp:~# vi /etc/pam.d/su# line 15: uncomment and add a group which is allow to run [su] command
auth required pam_wheel.so group=adm # add a user you allowed to run [su] to the group you set above
root@dlp:~# usermod -aG adm ubuntu

One thought on “Enable root User Account on Ubuntu

  1. I was having such a tough time configuring Postfix and Dovecot on my CentOS server, and this article helped me so much! The step-by-step guide was exactly what I needed to get everything up and running. I was stuck on a few configuration options, but your instructions were clear and easy to follow. Now, my mail server is up and running smoothly!

    By the way, I had a different issue trying to install Go on Debian for another project, and I found this [guide on how to install Go on Debian](https://docs.vultr.com/how-to-install-go-on-debian-18) that was a huge help.

    Thank you for sharing such a detailed and helpful article—this was exactly what I needed! I love how you covered everything so comprehensively. Keep up the great work!

Leave a Reply

Your email address will not be published. Required fields are marked *

RELATED POST

How to automatically restart Linux services with Systemd

Getting your Linux deployments working reliably is of paramount concern for production applications. One way to guarantee that a service…

How to Install SFTPGo on Ubuntu 22.04

Setup UFW Firewall For security reasons, it is recommended to install and configure the UFW firewall in your system. First,…

Executing Bash Scripts at Startup in Ubuntu Linux

Creating a Bash script in Ubuntu To create a Bash script in Ubuntu, you can use any text editor of…

How To Clear PHP’s Opcache

PHP can be configured to store precompiled bytecode in shared memory, called Opcache. It prevents the loading and parsing of PHP…