How To Switch To Root

Table of contents:

How To Switch To Root
How To Switch To Root

Video: How To Switch To Root

Video: How To Switch To Root
Video: How to Become Root User in Linux (Ubuntu 18.04) 2024, December
Anonim

In operating systems with a Unix-like architecture, there is usually an account with an ID equal to zero. By default, his login is root. A user with access to such an account has unlimited privileges in the system. Many administrative tasks can only be accomplished if it is possible to switch to root.

How to switch to root
How to switch to root

Necessary

  • - a computer with a Unix-like operating system;
  • - root credentials.

Instructions

Step 1

When working in a text-based console or a graphical terminal emulator, in case you need to execute multiple commands with root privileges, use the su command. Get information on how this program works by requesting internal help using the --help option:

su --help

You can also check the man or info documentation:

man su

info su

Switch to root by running su and entering your password. When finished, run the exit command to end the session.

Step 2

To switch to root for a single command, it is advisable to use the sudo command. Before using it, it is advisable to also familiarize yourself with the man, info documentation, or the built-in help, since it accepts quite a few options, and many of them may be useful (for example, -H, -S). However, to execute a command as root, it will be sufficient to execute sudo with a single parameter, which is a string containing the command. For example:

sudo env | grep SUDO

This may require you to enter a password for your own account. Note that your user must be in the permission lists defined by the / etc / sudoers file to be able to use sudo.

Step 3

You can switch to root by simply logging in with that user's credentials in the text console. Go to the free console by pressing Alt + Fx (or Ctrl + Alt + Fx when working in a graphical environment), where Fx is one of the twelve function keys. Enter root as the username. Then enter your password.

How to switch to root
How to switch to root

Step 4

When working in a graphical environment, you will not be able to switch to root in the same way as in Windows you can switch to administrator (by changing the user). However, you can unload the X server and restart it as root. Try shutting down the X server by exiting the graphical environment. If it starts up again or reboots, select the console login option on the login screen.

Step 5

Log in with root credentials in the text console. Run the startx command to start the graphical shell.

Recommended: