VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file

⇱ How To Edit the Sudoers File Safely | DigitalOcean


πŸ‘ How To Edit the Sudoers File Safely

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.

Senior Technical Writer at DigitalOcean

πŸ‘ Vinayak Baranwal
Vinayak Baranwal
Editor
Technical Writer II
See author profile

Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator. Technical Writer @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Awesome wrote up Justin! Very handy. Thank you!

bookmarking for ever… Absolute beginner and found it awesome…

absolute not useful! a lot of divagations, but again telling what do do instead HOW to do. beginners need to find HOW the fuck to do it!

@castleless: Sorry you feel that way! This article is trying to provide background material to help people understand the commands. Maybe something like the initial server setup guide is more your speed:

https://www.digitalocean.com/community/articles/initial-server-setup-with-ubuntu-14-04

If you want to add sudo privileges for a user named β€œmyuser”, run the command:

<pre> visudo </pre>

Then add the following line to the file:

<pre> myuser ALL=(ALL:ALL) ALL </pre>

Done!

Never mind how to do it differently; how to do it the original way before you change it would be more helpful.

So to recap… add

Then on nano as visudo,

``` to writeout and save the file /etc/sudoers.tmp

And it's this sudoers.tmp file which is read by sudo as the config file?

Using a tmp file as a config file is a bit counter-intuitive. Does visudo rename it when it's saved?

Answering my own question, that does seem to be the case. So never mind the name of the file, just do it... :/

@rshpeley: visudo ensures that you don’t leave /etc/sudoers in a broken state. It’s saved to the temp file, checked for errors, then renamed.

I found this really helpful actually. Thanks Justin, much appreciated!

Maybe I’m on a later version of Ubuntu since this was written, but it looks like the current config advises using an extra file to add user settings to sudoers.

Is it now correct to uncomment the last line of sudoers #includedir /etc/sudoers.d then add a file in the etc/sudeors.d/ containing your additions?

Also, do I need to restart anything for the changes to take affect?

Hi, Very helpful article. By the way, how can we add an ldap user (normal user) to the sudoer’s file?

πŸ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow β€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Β© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.