• Home
  • About
  • Contact
  • Privacy
  • Terms
  • DCMA
  • Write For Us / Submit
Tech News, Magazine & Review WordPress Theme 2017
  • Tech
    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

    Enhance your omnichannel service strategies with data-driven insights.

    Black Market for Fraudulent Ad Accounts Found on Facebook

    Sen. Mark Warner and Sen. Marco Rubio at a hearing.

    Trump’s TikTok ban might have been right after all

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    6 Android Apps for Budget Management

    Twitter, Facebook, Lyft layoffs spark fears of dotcom crash 2.0

  • Gear
    • All
    • Camera
    • Laptop
    • Smartphone
    Latest Smart Home Gadgets for a Connected Life

    Latest Smart Home Gadgets for a Connected Life

    Eco-Friendly Products for Students

    Eco-Friendly Products for Students

    Essential Photography Equipment and Gadgets

    Mastering Your Shots: Essential Photography Equipment and Gadgets

    Level Up Your Game: Must-Have Gaming Gear!

    Level Up Your Game: Must-Have Gaming Gear!

    Pixel Watch in the test

    Google Pixel Watch in the Test

    Top 5 Websites To Buy Camera Lenses At Reasonable Price

    Top 5 Websites To Buy Camera Lenses At Reasonable Price

    Trending Tags

    • Best iPhone 7 deals
    • Apple Watch 2
    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • iOS 10
    • iPhone 7
    • Sillicon Valley
  • Gaming
    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    5 Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    9 Best Alternative Games Like Kahoot

    9 Best Alternative Games Like Kahoot

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

    Level Up Your Game: Must-Have Gaming Gear!

    Level Up Your Game: Must-Have Gaming Gear!

  • Crypto
    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

    Enhance your omnichannel service strategies with data-driven insights.

    Black Market for Fraudulent Ad Accounts Found on Facebook

    Sen. Mark Warner and Sen. Marco Rubio at a hearing.

    Trump’s TikTok ban might have been right after all

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    6 Android Apps for Budget Management

    Twitter, Facebook, Lyft layoffs spark fears of dotcom crash 2.0

  • Business
    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

    Enhance your omnichannel service strategies with data-driven insights.

    Black Market for Fraudulent Ad Accounts Found on Facebook

    Sen. Mark Warner and Sen. Marco Rubio at a hearing.

    Trump’s TikTok ban might have been right after all

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    6 Android Apps for Budget Management

    Twitter, Facebook, Lyft layoffs spark fears of dotcom crash 2.0

No Result
View All Result
Geeky Insider
  • Tech
    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

    Enhance your omnichannel service strategies with data-driven insights.

    Black Market for Fraudulent Ad Accounts Found on Facebook

    Sen. Mark Warner and Sen. Marco Rubio at a hearing.

    Trump’s TikTok ban might have been right after all

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    6 Android Apps for Budget Management

    Twitter, Facebook, Lyft layoffs spark fears of dotcom crash 2.0

  • Gear
    • All
    • Camera
    • Laptop
    • Smartphone
    Latest Smart Home Gadgets for a Connected Life

    Latest Smart Home Gadgets for a Connected Life

    Eco-Friendly Products for Students

    Eco-Friendly Products for Students

    Essential Photography Equipment and Gadgets

    Mastering Your Shots: Essential Photography Equipment and Gadgets

    Level Up Your Game: Must-Have Gaming Gear!

    Level Up Your Game: Must-Have Gaming Gear!

    Pixel Watch in the test

    Google Pixel Watch in the Test

    Top 5 Websites To Buy Camera Lenses At Reasonable Price

    Top 5 Websites To Buy Camera Lenses At Reasonable Price

    Trending Tags

    • Best iPhone 7 deals
    • Apple Watch 2
    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • iOS 10
    • iPhone 7
    • Sillicon Valley
  • Gaming
    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    5 Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    9 Best Alternative Games Like Kahoot

    9 Best Alternative Games Like Kahoot

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

    Level Up Your Game: Must-Have Gaming Gear!

    Level Up Your Game: Must-Have Gaming Gear!

  • Crypto
    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

    Enhance your omnichannel service strategies with data-driven insights.

    Black Market for Fraudulent Ad Accounts Found on Facebook

    Sen. Mark Warner and Sen. Marco Rubio at a hearing.

    Trump’s TikTok ban might have been right after all

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    6 Android Apps for Budget Management

    Twitter, Facebook, Lyft layoffs spark fears of dotcom crash 2.0

  • Business
    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

    Enhance your omnichannel service strategies with data-driven insights.

    Black Market for Fraudulent Ad Accounts Found on Facebook

    Sen. Mark Warner and Sen. Marco Rubio at a hearing.

    Trump’s TikTok ban might have been right after all

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    14 Gift Ideas for the Home Chef (2022): Vitamix, Cookbooks, and More

    6 Android Apps for Budget Management

    Twitter, Facebook, Lyft layoffs spark fears of dotcom crash 2.0

Submit
Geeky Insider
No Result
View All Result

How to Add a User to the sudoers File in Linux

by Staff Writer
October 30, 2022
in How To
Reading Time: 8 mins read
Linux laptop showing a bash prompt
Share on FacebookShare on Twitter

fatmawati achmad zaenuri/Shutterstock.com

If you’re being told a user “is not in the sudoers file,” you can give the user full sudo privileges with the usermod command. To control what a user can do with sudo, edit the sudoers file with visudo.

The people who can use the Linux sudo command are members of a small and select club, sometimes called the “sudoers” list. Each member has the same powers as root. So how do you join that club? We’ll walk through adding a person to sudoers as well as editing the sudoers file to limit permissions.

Table of Contents

  • sudo: Your Superpowered Alter-Ego
  • The sudoers File and visudo
  • Add a New sudo User in Ubuntu and Other Linux Distros
  • Limit sudo Privileges by Editing the sudoers File
  • Whosoever Holds This Command
    • READ ALSO
    • How to Turn Off Autoplay on YouTube
    • How to go through your CV in a job interview

sudo: Your Superpowered Alter-Ego

In Linux installations, the root user is the most highly-privileged user. They can perform any administrative task, access any file regardless of actually owns it, and they can create, manipulate, and even remove other users.

This level of power is dangerous. If root makes a mistake, the results can be catastrophic. They have the ability to mount and unmount file systems, and to over-write them entirely. A much safer way to work is to never log in as root.

Nominated users can use sudo to temporarily gain administrative powers, perform the action that is required, and then return to their normal, unprivileged state. This is safer because you consciously invoke your higher powers when you need them, and while you’re focused on doing whatever it is that requires them.

The sudo command is the Linux equivalent of shouting “Shazam.” When the scary stuff is over, you abandon your superpowered alter-ego and go back to your normal humdrum self.

Logging in as root is turned off by default on most modern distributions, but it can be reinstated. Using the root account for day-to-day work is inadvisable. Mistakes that would ordinarily impact a single user or that would be blocked altogether because of insufficient privileges, can run unhindered if root issues them.

Modern Linux distributions grant sudo privileges to the user account that’s created during the installation or post-installation configuration steps. If anyone else tries to use sudo , they’ll see a warning message like this:

mary is not in the sudoers file. This incident will be reported.

That seems plain enough. Our user mary can’t use sudo because she isn’t “in the sudoers file.” So let’s see how we can add her.

RELATED: How to Control sudo Access on Linux

The sudoers File and visudo

Before someone can use the sudo command we need to work with the sudoers file. This lists the user groups of the users who can use sudo. If we need to make amendments to the file, we must edit it.

The sudoers file must be opened using the visudo command. This locks the sudoers file and prevents two people trying to make changes at the same time. It also performs some sanity checks before saving your edits, ensuring they parse correctly and are syntactically sound.

Note that visudo isn’t an editor, it launches one of your available editors. On Ubuntu 22.04, Fedora 37, and Manjaro 21, visudo launched nano. That might not be the case on your computer.

If we want to give someone access to full sudo privileges, we only need to reference some information from the sudoers file. If we want to be more granular and give our user some of the capabilities of root, we need to edit the file and save the changes.

Either way, we need to use visudo.

RELATED: How to Exit the Vi or Vim Editor

Add a New sudo User in Ubuntu and Other Linux Distros

We’ve got two users who need access to root privileges in order to carry out their job roles. They are Tom and Mary. Mary needs to have access to everything root can do. Tom only needs to install applications.

Let’s add Mary to the sudoers’ group first. We need to start visudo.

sudo visudo

Launching visudo on Ubuntu Linux

Scroll down in the editor until you see the “User Privilege Specification” section. Look for a comment that says something similar to “Allow members of this group to execute any command.”

The sudoers file open in the nano editor

We’re told that members of the sudo group can execute any command. All we need to know in Mary’s case is the name of that group. It isn’t always sudo ; it might be wheel or something else. Now that we know the name of the group, we can close the editor and add Mary to that group.

We’re using the usermod command with the -a (append) and -G (group name) options. The -G option allows us to name the group we’d like to add the user to, and the -a option tells usermod to add the new group to the list of existing groups this user is already in.

If you don’t use the -a option, the only group your user will be in is the newly added group. Double-check, and make sure you’ve included the -a option.

sudo usermod -aG sudo mary

Using usermod to add the user mary to the sudo group

The next time Mary logs in, she’ll have access to sudo. We’ve logged her in and we’re trying to edit the file system table file, “/etc/fstab.” This is a file that is out of bounds to everyone but root.

sudo nano /etc/fstab

Using usermod to add the user mary to the sudo group

The nano editor opens up with the “/etc/fstab” file loaded.

user mary editing the /etc/fstab file by using sudo

Without sudo privileges, you’d only be able to open this as a read-only file. Mary no longer has those restrictions. She can save any changes she makes.

Close the editor and don’t save any changes you may have made.

Limit sudo Privileges by Editing the sudoers File

Our other user, Tom, is going to be granted permission to install software, but he isn’t going to receive all of the privileges that were awarded to Mary.

We need to edit the sudoers file.

sudo visudo

Launching visudo on Ubuntu Linux

Scroll down in the editor until you see the “User Privilege Specification” section. Look for a comment that says something similar to “Allow the members of this group to execute any command.” It’s the same point in the file where we found the name of the group we needed to add Mary to.

Add these lines below that section.

# user tom can install software
tom ALL=(root) /usr/bin/apt

Adding new entries to the sudoers file

The first line is a simple comment. Note that there is a Tab between the user name “tom” and the word “All.”

This is what the items on the line mean.

  • tom: The name of the user’s default group. Usually this is the same as the name of their user account.
  • ALL=: This rule applies to all hosts on this network.
  • (root): Members of the “tom” group—that is, user Tom—can assume root privileges, for the listed commands.
  • /usr/bin/apt: This is the only command user Tom can run as root.

We’ve specified the apt package manager here because this computer uses Ubuntu Linux. You’d need to replace this with the appropriate command if you’re using a different distribution.

Let’s log Tom in and see if we get the expected behavior. We’ll try to edit the “/etc/fstab” file.

sudo nano /etc/fstab

Trying to edit the /etc/fstab file without sudo privileges

That command is rejected, and we’re told that “user tom isn’t allowed to execute ‘/usr/bin/nano /etc/fstab’ as root …”

That’s what we wanted. User Tom is only supposed to be able to use the apt package manager. Let’s make sure they can do that.

sudo apt install neofetch

User Tom using the apt command with sudo

The command is successfully executed for Tom.

Whosoever Holds This Command

If all your users can use sudo, you’ll have chaos on your hands. But it is worth promoting other users so they can share your administrative burden. Just make sure they’re worthy, and keep an eye on them.

Even if you’re the only user on your computer, It’s worth considering creating another user account and giving it full access to sudo. That way, if you ever find yourself locked out of your main account, you have another account you can log in with to try to remedy the situation.

RELATED: How to Review sudo Command Usage on Linux



Source by
www.howtogeek.com

READ ALSO

How to protect yourself from phishing

Phishing: The nasty tricks of the cybercriminals – this is how they protect themselves

July 28, 2023
How to Unsend an Email in Outlook

How to Unsend an Email in Outlook

November 16, 2022

Related Posts

transfer whatsapp from android to iphone
Articles

How to Transfer WhatsApp from Android to iPhone!

September 19, 2023
How to prevent phishing attacks
How To

How to Prevent Phishing Attacks: Safeguarding Your Digital Identity

May 14, 2023
How to Activate Iphone With Sim Card
Apple

How to Activate Iphone With Sim Card

March 3, 2023
How to quickly divide or Split PDF files
Apps And Softwares

How to Quickly Divide or Split PDF Files

February 28, 2023

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Apple iPhone 13

Apple iPhone 13, Samsung Galaxy Z Flip4 5G to iQOO 9 Pro 5G- Technology News, Firstpost

September 29, 2022
Meta Reports First Revenue Decline and 36 Percent Profit Drop

Meta Reports First Revenue Decline and 36 Percent Profit Drop

July 27, 2022

Trending.

MicroSD card in hand.

How to Move Apps to SD Card on an Amazon Fire Tablet

October 5, 2022
Google's No Internet Dino game running on a laptop computer

How to Hack the Hidden Google Chrome Dinosaur Game

October 23, 2022
Symbolic Link Header Image. A Windows folder on a blue background.

The Complete Guide to Creating Symbolic Links (aka Symlinks) on Windows

July 27, 2022
Employee Payroll Management Software Simplifying Processes

Employee Payroll Management Software: Simplifying Processes

August 23, 2023
Docker logo

How to Run Docker Compose Containers With GPU Access

July 24, 2022
Geeky Insider

Geeky Insider is Web based independent Tech Magazine covering Topics Related to Technology, Gadgets, Software, Gaming, Crypto, Business And So on. Read More...

Submit a Techy Post | Write For Us

Feel free to contact us for submission queries. via contact form or email us at [email protected].

Categories

  • Android
  • Apple
  • Apps And Softwares
  • Articles
  • Business
  • Camera
  • Crypto
  • Education
  • Entertainment
  • Gadget and Gear
  • Gaming
  • How To
  • Laptop
  • Marketing
  • Microsoft
  • Review
  • Security
  • Smartphone
  • Technology
Understanding Blockchain Technology

7 Astonishing Ways Blockchain Technology

September 26, 2023
7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

September 26, 2023
Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

5 Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

September 26, 2023
  • Home
  • About
  • Contact
  • Privacy
  • Terms
  • DCMA
  • Write For Us / Submit

© 2022 GeekyInsider.com

No Result
View All Result
  • Home
  • Review
  • Apple
  • Gaming
  • Gadget and Gear
    • Camera
    • Smartphone
  • Microsoft
  • Security