How to sudo without password on CentOS Linux

To run sudo without a password prompt on CentOS Linux, you can edit the /etc/sudoers file. Here’s the process:

  1. Open the /etc/sudoers file using the visudo command:
sudo visudo
  1. Add the following line at the end of the file, replacing username with the name of the user who should not be prompted for a password:
username ALL=(ALL) NOPASSWD:ALL
  1. Save and exit the file.
  2. Test the change by running a sudo command as the specified user:
sudo ls -l

Note: This change is a security risk because it allows the specified user to run any sudo command without a password. Be sure to only grant this privilege to trusted users.

Leave a Comment