Try   HackMD

Linux - switch to root without password

tags: linux

switch to root without password, ("sudo su" command)

1. edit "/etc/sudoers" file
modify or add new line "<username> ALL=NOPASSWD:ALL"

!!! switch account from <username> to root

2. comment out "%sudo ALL=(ALL:ALL) ALL"
=>            "#%sudo ALL=(ALL:ALL) ALL"

Use visudo, append line below. (update the username)

<username> ALL=(ALL) NOPASSWD:ALL

/etc/sudoers

  • All lines starting with # are comments

  • root ALL=(ALL:ALL) ALL – this line means that the root user has unlimited privileges and can run any command on the system

  • %admin ALL=(ALL) ALL – the % sign specifies a group. Anyone in the admin group has the same privileges as of root user

  • %sudo ALL=(ALL:ALL) ALL – all users in the sudo group have the privileges to run any command

Reference

https://www.cyberciti.biz/faq/linux-unix-running-sudo-command-without-a-password/
https://www.hostinger.com/tutorials/sudo-and-the-sudoers-file/