LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-20-2020, 05:03 AM   #1
anon093
LQ Newbie
 
Registered: Nov 2020
Location: Delhi, India
Posts: 10

Rep: Reputation: Disabled
[sudoers]How-to edit '/etc/sudoers'?


Hello,

May i ask that:
#1: How-to edit '/etc/sudoers'(aka 'sudo' Policy) file if:
The 'root' user want a nonRoot user 'bh0laJi' to be able to execute "/bin/shutdown -h now" and a script '/bin/rdshft.sh', and nothing else as 'sudo'.

#2: What does each of the 'ALL' in "ALL=(ALL:ALL) ALL" mean?

Distribution: Debian+, ArchLinux...

Thanking you...

Last edited by anon093; 12-20-2020 at 05:04 AM.
 
Old 12-20-2020, 05:21 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,366

Rep: Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335
edit sudo with visudo and test your results at once.
Plenty of examples online. It's very fussy on syntax, spacing, etc.
 
Old 12-20-2020, 05:42 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by bh0laJi View Post
[sudoers]How-to edit '/etc/sudoers'?
Very carefully.

In all seriousness, do remember to test your changes in another window before closing your editor session.

The manual page for sudoers is a bit overwhelming, see "man sudoers" anyway. In ALL=(ALL:ALL), the first part before the equal sign refers to the FQDN of the systems in question. The parts inside the parenthesis are the use and group one may switch to. Often people write (ALL:ALL) when they really mean (root:root) instead.

You might look at the second edition of sudo Mastery by Michael W Lucas for an excellent explanation of all the capabilities. He also did a presentation which is preserved in Youtube as sudo: You're Doing It Wrong, along with accompanying slides somewhere. However the book is better.

Then for your first question:

Quote:
Originally Posted by bh0laJi View Post
[sudoers]How-to edit '/etc/sudoers'?
#1: How-to edit '/etc/sudoers'(aka 'sudo' Policy) file if:
The 'root' user want a nonRoot user 'bh0laJi' to be able to execute "/bin/shutdown -h now" and a script '/bin/rdshft.sh', and nothing else as 'sudo'.
Try something like the following:

Code:
%bh0laJi  ALL=(root:root) /bin/shutdown -h now, /bin/rdshft.sh ""
The percentage sign means that the group is targeted and not just the one account. It makes debugging easier in many cases. Then the empty quotes after the script name mean that the account is not allowed to send parameters to it and must run it without them. If you want the group to be able to run many forms of shutdown, then leave off the options. Without any options and without the empty quotes, any and all options are allowed.

Code:
%bh0laJi  ALL=(root:root) /bin/shutdown, /bin/rdshft.sh ""
An instantaneous shutdown might not be most appreciated on a multi-user system.
 
1 members found this post helpful.
Old 01-02-2021, 01:51 PM   #4
RickDeckard
Member
 
Registered: Jan 2014
Location: Canton, Georgia, USA
Distribution: Debian 12
Posts: 205

Rep: Reputation: Disabled
Three ways exist to edit the sudoers file:

1) visudo
2) sudoedit
3) plain text editor, which I would strongly discourage unless you know what you're doing

I personally am in the habit of using sudoedit because I have a list of text files specified as needing privileged access to modify and sudoedit does the job nicely, without having to switch between apps.
 
1 members found this post helpful.
  


Reply

Tags
admin, sudo, sudoers, wheel



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora /etc/sudoers file and sudoers.d directory davejjj Linux - Newbie 2 10-21-2011 06:19 PM
How to edit /etc/sudoers so that I can run another users script vanish78 Linux - Newbie 6 05-15-2011 02:28 PM
cannot edit /etc/sudoers unisol Ubuntu 13 06-18-2006 09:35 AM
How to edit "/etc/sudoers" lchxr Fedora 5 04-02-2006 11:29 AM
I deleted /etc/sudoers and creates a new file call sudoers but now it doesnt for visu abefroman Linux - Software 1 11-10-2005 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration