LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-10-2011, 10:19 AM   #1
tank junior
Member
 
Registered: Apr 2010
Posts: 42

Rep: Reputation: 0
sudo and providing rights to executable.


Hi,

I am newbie on linux.
I have written a custom tool that requires sudo in order to (only read) access to some hardware information.

How do I provide sudo rights to this tool permanently so that any user or particular can execute it without sudo prefix?

NOTE: I only need read access.


Prashant
 
Old 05-10-2011, 11:53 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
You need to look in the /etc/sudoers file. Something like
Code:
%users ALL=/usr/local/bin/yourTool
should allow everyone in the 'users' group access to your tool
 
Old 05-11-2011, 02:20 AM   #3
tank junior
Member
 
Registered: Apr 2010
Posts: 42

Original Poster
Rep: Reputation: 0
Hi Snark1994,

I added this line in /etc/sudoers:

%users ALL=NOPASSWD: /usr/bin/lshw

I also tried using my user name:
anarki ALL=NOPASSWD: /usr/bin/lshw

log-out and log-in

when I type "lshw" (without sudo), I am still getting a warning:
WARNING: you should run this program as super-user.

and I am not getting all the info with "lshw".

Any pointers?

Prashant
 
Old 05-11-2011, 02:20 AM   #4
tank junior
Member
 
Registered: Apr 2010
Posts: 42

Original Poster
Rep: Reputation: 0
Hi Snark1994,

I added this line in /etc/sudoers:

%users ALL=NOPASSWD: /usr/bin/lshw

I also tried using my user name:
anarki ALL=NOPASSWD: /usr/bin/lshw

log-out and log-in

when I type "lshw" (without sudo), I am still getting a warning:
WARNING: you should run this program as super-user.

and I am not getting all the info with "lshw".

Any pointers?

Prashant
 
Old 05-12-2011, 10:40 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Ah, sorry. You will still need to use 'sudo', it just won't ask anyone for a password. I don't know if this will work (I'm on my Windows machine atm so I can't test it) but you maybe able to try this:

Create a script '/usr/bin/lshwWrapper':
Code:
#!/usr/bin/bash
sudo /usr/bin/lshw
You can then call /usr/bin/lshwWrapper and with any luck it will run /usr/bin/lshw with root priveliges without you having to type 'sudo'
 
Old 05-12-2011, 09:57 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
3 options

1. use sudo : this is the normal way as you've discovered; recommended

2. put user in group owner of lshw ; reasonable

3. make user the owner instead of root; not recommended
 
  


Reply

Tags
sudo


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: The Ultimate Sudo FAQ To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 02:36 AM
Granting apache sudo rights secure? guerreroJesus Linux - Security 3 10-03-2010 06:23 AM
Directory based 'sudo chown' rights? TheYanster Linux - Security 11 11-09-2009 03:49 PM
bash/bin file wont executable, possible not the correct rights setup. Dutch2005NL Linux - Newbie 8 11-17-2008 02:50 AM
Can't execute an executable, even as sudo. davemar SUSE / openSUSE 2 06-25-2008 07:59 AM


All times are GMT -5. The time now is 02:54 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration