Suppose, I have just entered the Metasploitable 2 Linux like the following command:username : msfadminpassword : msfadminNow, I need to gain 'root' privilege so that I do not need to use 'sudo' - command again and again. For example, in order to shutdown the machine I just want to type:shutdown -h 1not,sudo shutdown -h 1How to do that?
How to achieve root privilege in Metasploitable 2 Linux?
metasploit
On UNIX like system root rights are defined by the user id (which is 0 for the root user). I will offer two preferable options first.1. Switching to root userIf you want to become the root user for the current session only a $ sudo sushould be sufficient.2. Disabling sudo password checkYou can edit the sudoers file using$ sudo visudo, append the following line and save the file.msfadmin ALL=(ALL) NOPASSWD: ALLNote: if the visudo command uses an unwanted editor you can use (replacing nano by the editor you want to use):$ EDITOR=nano sudo visudo3. Setting user id to 0I would really not recommend this way but to make msfadmin a root user change its user id to 0.$ sudo nano /etc/passwd, change the line starting with msfadmin tomsfadmin:x:0:0:msfadmin,,,:/home/msfadmin:/bin/bashand reboot.