Become root user on Linux servers in Azure

root is the user name or account that by default has access to all commands and files on a Linux or other Unix-like operating system. It is also referred to as the root account, root user and the superuser. The root account is the most privileged on the system and has absolute power over it (i.e., complete access to all files and commands). Among root’s powers are the ability to modify the system in any way desired and to grant and revoke access permissions (i.e., the ability to read, modify and execute specific files and directories) for other users, including any of those that are by default reserved for root.

It is therefore, many times, you need to login as root in order to perform certain administrative actions. However, while creating a linux VM in azure, you would need to enter a custom username/password and you are not allowed to root. This account is then added to /etc/sudoers to assign admin privileges.

Once VM is created, you cannot login to the VM as root, as you don’t know its password. However, there is quick workaround on this.

First, you need to login to Azure VM with the account that has admin privileges. Then you can simply use sudo -i to login as root user. It will only ask for password of current user.

Here’s a quick demo of the same:

login as: mogoyal
Using keyboard-interactive authentication.
Password:
Last login: Sat Aug 19 13:19:54 2017 from mohit200-81.domain.com
[mogoyal@controller-01 ~]$ sudo -i
[sudo] password for mogoyal:
[root@controller-01 ~]#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s