How can I get the root privileges?

erciyuan old 6 Reputation points
2022-07-03T15:03:25.947+00:00

Hi,
I created a Linux (centos 7.9.2009) VM, and I want to get the root privileges.
How can I do that? I tried to use sudo, su, root, but it's useless.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,014 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Prrudram-MSFT 28,201 Reputation points Moderator
    2022-07-28T19:30:59.307+00:00

    Hello @erciyuan old ,

    Root account is the username or account that by default has access to all commands and files on a Linux. It is, therefore, many times, you need to login as root in order to perform certain administrative actions.

    Standard method to SSH and connect to an azure VM:

    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.

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

    For connecting using cloudshell you can follow https://learn.microsoft.com/en-us/azure/cloud-shell/quickstart#ssh-into-your-linux-vm

    Hope this helps.

    --please don't forget to upvote and accept as answer if the reply is helpful--

    12 people found this answer helpful.
    0 comments No comments

  2. erciyuan old 6 Reputation points
    2022-07-04T06:28:58.483+00:00

    I entered the command in the cloud shell and did not use ssh to connect

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.