Once you have connected to your virtual machine via Control Panel or SSH, you can perform commands with root user rights. To do this, you can use one of the two options: the
sudo command or the
sudo su superuser (root user) shell.
sudo (which stands for Super Do) is a free command-line utility used in Unix-like operating systems such as the Linux family of distributions (including Ubuntu, Debian, and CentOS).
sudo allows a regular user to temporarily elevate their privileges to a higher level, such as root, in order to execute tasks that require root user rights.
sudo su is a combination of
su means “switch user” or “substitute user.” Using
sudo su, you can switch to being the root user for the duration of an active session. Consequently, all actions within the current session will be performed with root user permissions.
Remember to exercise caution when using these commands because operating with root permissions allows for system-wide changes. Misuse could lead to unintentional system alterations or compromise.
sudo if you want to execute a specific command as a root user while staying logged in as a regular user.
sudo su if you want to log in as a root user and perform all commands with root permissions.
sudo to the beginning of your command. For example:
sudo apt-get update
All commands with
sudo at the beginning will be executed with root user rights. Commands without
sudo will be executed with regular rights.
Enter the command:
Having now logged in with the
sudo su command, you are in the superuser (root) shell. All further commands will be performed with root user rights.
To exit superuser mode and return to your user account, simply run the command
You can also enter an interactive and non-interactive superuser (root) shell:
sudo -i, the system might require your password to verify your identity and ensure that you have sudo rights, typically granted to administrators or users in the sudo group.
sudo -s starts a superuser shell without the need to enter the superuser password. This is handy if you need to run successive commands with superuser privileges within the current shell.
Was this article helpful?
Discover our offerings, including virtual instances starting from 3.7 euro/mo, bare metal servers, AI Infrastructure, load balancers, Managed Kubernetes, Function as a Service, and Centralized Logging solutions.