How Do I Become a Root User in Linux?
All privileged commands on a Linux server must be executed as root or as superuser. Unlike Windows, Linux doesn’t permit users other than superuser and root to execute many commands. As root users or superusers, we have many options in Linux.
Method 1: Use ‘sudo -i’
If a root user already logged in to the Ubuntu system, that system would block that user by default. This can be accomplished by logging in as a non-root user before logging in as a root user with sudo -i.
The output of sudo prompts the current user for a password if he does not have sudo access. If the user already has sudo access, the system does not ask for a password.
[sudo] password for test:
root@test-localhost:~#
Method 2: Use ‘sudo -s’
Linux-based cloud instances typically use this method, which requires us to log in as a different user first and then use sudo-s to switch to the root user. Default settings block the root user.
root@test-localhost:/home/test#
Method 3: Use ‘sudo su -‘
Here su means switch user. If we are logged in as a non-root user, we can log in as root-users using su-command.
root@test-localhost:~#
As we can see in the output of the above command, if $ appears in the output, it indicates a non-privileged user. Instead of # in the output, it means that our user is a root user.
Method 4: Use ‘su – root’
This method is also another method through which we can switch the non-root user as a root user.
Password:
Last login: Sun Jan 30 21:27:59 EDT 2021 from 192.168.0.101 on pts/0
Method 5: Use ‘su -‘
Suppose we use only su-command instead of specifying root user with su command, then by default. In that case, it will change from current user to superuser and non-root user.
Password:
Last login: Sun Jan 30 21:27:59 EDT 2021 from 192.168.0.101 on pts/0
Conclusion
In the above article, we have explained how to use the root user, and we have also explained to you its advantages and disadvantages. We hope you understand and use it better. Our article has multiple ways to become a root user in Linux.
from https://ift.tt/3AdzZU0

0 Comments