4 ways to gain root level access in Linux

Table of contents:

4 ways to gain root level access in Linux
4 ways to gain root level access in Linux
Anonim

The root level or superuser, gives you the right to access the most protected elements of a Linux or Unix operating system and to intervene by means of very powerful commands in order to control its behavior in the smallest details. This level of privilege is so powerful that you should only log in as root when necessary and with the awareness that you are putting your system at risk with potentially catastrophic consequences.

Steps

Method 1 of 4: Access the root level with a terminal

Become Root in Linux Step 1

Step 1. Open a terminal

If you haven't already, open it from your desktop interface by simultaneously pressing the shortcut keys Ctrl + Alt + T.

Become Root in Linux Step 2

Step 2. Type su - then press the Enter key

This will allow you to log in with the privileges of the system superuser. This command also allows you to log into the account of any other user of the computer, but if you do not type anything after su -, the system will automatically assume that this is a request. login at root level.

Become Root in Linux Step 3

Step 3. Enter the superuser password

When you have entered the command su - then Enter, you will be prompted for the superuser password.

If you receive the "su: Authentication failed" message, the root account may be locked, in which case you will need to unlock it

Become Root in Linux Step 4

Step 4. Check the display of your terminal prompt

If you were able to log in, the last character of the system command prompt will become # instead of $.

Become Root in Linux Step 5

Step 5. Perform the tasks that you need to perform

Once logged in as superuser using the su - command, you will be able to launch any utility that requires root level access privileges to run. The system will remember your superuser status until the end of the session, so that you will not have to log in again each time you need to issue a command.

Become Root in Linux Step 6

Step 6. Consider using sudo instead of su -.

The sudo command (for Super User DO) will allow you to temporarily gain superuser privileges to perform ad hoc tasks that require this level to run. It is also the safest way to execute commands requesting privileged access because the root environment is only temporary and the user does not need to know the password to access the root account., his being sufficient to temporarily become superuser, as long as he has system administration permissions.

  • Type sudo command and then press the Enter key. Try for example sudo ifconfig. When the system asks you for a password, enter only your own as the user and not the one to access the root account.
  • Using sudo is the preferred method for distributions like Ubuntu and derivatives and it has the advantage of working even if the root account is locked.
  • This command is limited to users who have been assigned system administration permissions by their membership in the group named sudo. These permissions can be added or removed by modifying the / etc / sudoers file.

Method 2 of 4: Unlock root account in Ubuntu and derived distributions

Become Root in Linux Step 7

Step 1. Unlock the root account in Ubuntu

Access to the root account is rarely needed if you can use the sudo command as mentioned above. For this reason, Ubuntu and several distributions derived from it block access to the root account, so that unauthorized users cannot access it.

Become Root in Linux Step 8

Step 2. Open a terminal

Simultaneously press the Ctrl + Alt + T keys in the desktop environment to start the terminal.

Become Root in Linux Step 9

Step 3. Invoke sudo passwd root then press Enter key

The system will ask you to enter your password. Enter your user password.

Become Root in Linux Step 10

Step 4. Create a new password

You will be prompted to enter a new password which you will need to enter a second time. The root account will be activated when it has been accepted by the system.

Become Root in Linux Step 11

Step 5. Lock the root account again

Enter the following command to remove the password from the root account and lock it:

sudo passwd -dl root

Method 3 of 4: Log in as root

Become Root in Linux Step 12

Step 1. Always prefer to use temporary root access

It is not recommended that you stay logged in at all times with superuser privileges while using your computer normally. During the time that you keep this level open, the system remains exposed to significant security risks as well as to the careless execution of certain commands which could render it inoperative. For these reasons, you will only need to log in as superuser while you perform your maintenance tasks such as setting up devices or managing user accounts.

  • Using the sudo or su commands instead of logging in to the root account will allow you to limit the risks to your system while you are working as superuser. Using these commands has the advantage of forcing you to think about what you are going to do so that you do not risk damaging the system.
  • Some distributions, like Ubuntu, lock access to the root account until you manually unlock it. This has the advantage of not only preventing a user from causing damage without realizing it, but also of securing the system against possible intrusion by hackers, because the root account is usually the target of choice for hackers. 'computer science. They are unlikely to be able to gain access if that account is locked.
Become Root in Linux Step 13

Step 2. Enter root as the username to log in

If the root account is unlocked and you know the password, you can log into it when the system prompts you. You just need to give the name root as user in the login window.

If you need to run a command requiring superuser rights, it is better to use the sudo command

Become Root in Linux Step 14

Step 3. Enter the password for the root account

After entering the root name as the user, enter the password assigned to the root account.

  • It is common that on freshly delivered machines this password has been initialized to "password", "system" or "admin". Make sure to modify it from the first connection.
  • If you do not know the password for the root account or have forgotten it, instructions on how to reset it are given later.
  • In Ubuntu, the root account is locked by default and cannot be used until you unlock it yourself.
Become Root in Linux Step 15

Step 4. Running some complex applications should be avoided

If you remain logged in to the root account, it is very possible that some programs can have a negative effect if they run with the highest level access permissions of the system. It is strongly recommended to use the sudo or su commands to launch this kind of program rather than doing it while remaining permanently logged in to the root account.

Method 4 of 4: Reset the password for a privileged access account

Become Root in Linux Step 16

Step 1. Reset the password for the root account

You will need to reset this passkey if you no longer remember it. You will need to use your user password (provided you have administrative permissions) to change the superuser password. Simply enter sudo passwd root, enter your user password and then create the root account password. If, to add insult to injury, you also forgot your user password, you will need to restart your system in "recovery" mode before you can change both of them.

Become Root in Linux Step 17

Step 2. Restart your system in recovery mode

As soon as the BIOS screen is finished, hold down the left Shift key to display the “GRUB” boot manager menu.

The time you have to react can be very short, be prepared to have to make several attempts before it is successful

Become Root in Linux Step 18

Step 3. Select the first entry (recovery mode) from the list

Your system will load in recovery mode.

Become Root in Linux Step 19

Step 4. Select the root option from the menu that appears

The terminal you were using to log in to the root account should appear on your screen.

Become Root in Linux Step 20

Step 5. Reassemble the drive with write permissions

When you start your system in recovery mode, you normally only have read mode permissions. Enter the following command to get write permissions:

mount -rw -o remount /

Become Root in Linux Step 21

Step 6. Create a new password

Do the same for any accounts that you could no longer access. Once you are logged into the root account and have changed the access permissions, you will be able to create passwords for any account hosted on the system.

  • Type passwd accountName and press the Enter key. To change the password for the root account, enter passwd root.
  • You will be prompted to enter the new password a second time to confirm it.
Become Root in Linux Step 22

Step 7. Restart your computer after resetting passwords

Your new passwords will take effect as soon as the system is restarted, and you will be able to use your accounts in the same way as before.

Warnings

  • Only use root account access if it is really necessary and log out as soon as you have completed your tasks there.
  • Only share your superuser password with people you trust and who will need to use it.

Popular by topic