Cloud Playgroundchevron_right Serverschevron_right

Assuming Root User

Often times you will need to assume root to run certain commands. Whether these commands are tied to a specific Course Lecture, Hands-On Lab, or Cloud Playground server, the following methods are considered best practice in order from first to last.

sudo: Simply using `sudo` prior to a command is the most recommended way to run a command with elevated privileges. When you do this for the first time within a terminal session, you will be prompted for your `cloud_user` password. This will either be the one generated by a Lab, or one you have specified within a Playground server.

**Example**

sudo yum update


sudo su -: 
In some cases, you may find it easier to use this command as you will be directly logged into the root account. Once you have successfully logged into this "mode", you will no longer need to add `sudo` before a command requiring elevated privileges. Simply type the following command into your terminal, and when prompted enter your `cloud_user` password. This will either be the one generated by a Lab, or one you have specified within a Playground server. Please note that some normal commands cannot be used in this mode, and will require running an `exit` command to return to `cloud_user`.

**Example**

sudo su-

 
sudo -i: Sometimes this command may be required to complete a specific Hands-On Lab, or exercise and will be provided within the Lab instructions. You can use this command to simulate a login to the root user account. Depending on the configuration in the `/etc/sudoers` file, certain environment variables can be affected.

**Example**

sudo -i


Legacy Method:

su: You may notice a "Deprecated Credentials" section within a Cloud Playground server's details. Included in this section is an `su password`. This legacy feature allows you to login to root and run commands outside of your standard user account. Simply type `su` followed by the password provided in the Playground details (typically 123456) and set a new password. Please note that this method will be deprecated by July 2019, and removed from the default configuration. To use this method after July 1, you will need to reset the root user password with `sudo passwd root` before using `su` or `su -`.

**Example**

su