Usermod: Permission Denied

When I try to use a usermod command to add me to the sudoers file but it says usermod: permission denied usermod: cannot lock /etc/passwd try again later. When I search things up it told me to add me to sudoers and I need to use usermod but I need usermod access which requires me to be in sudoers file to setup.

3

1 Answer

You'll need to use visudo to edit the sudoers file.

To access it, you'll need to be root. You'll also need to edit this file with visudo which in Ubuntu is linked to the nano editor.

$ visudo
visudo: /etc/sudoers: Permission denied
$ sudo su -
[sudo] password for your_current_user_name: 
root@ # visudo 

visudo is used for safety sake to avoid making a mistake that could completely foul up your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest