• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Using SUDO

 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not much of a Unix guy, but need to run one of my scripts as ROOT.
I believe I cn do it with SUDO (SUID being a risk), can someone help me how do I use SUDO stepwise.

TIA,
- Manish
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is one of the great links that talks about setting up sudo files for permissions:

http://www.linuxhomenetworking.com/linux-hn/addusers.htm
http://www.courtesan.com/sudo/man/sudoers.html

Once you are setup with sudo, you need to run the script using the following syntax:

sudo sh - user -c command_or_script

Thanks
Vijay
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vijay Chinnasamy:
sudo sh - user -c command_or_script



um, that looks terribly insecure to me... i believe for that to work, you'd have to add /bin/sh to /etc/sudoers as a sudo-able command, wouldn't you? but that surely wouldn't be right, there's no end of ways the security of the shell could be breached.

i believe the "right" way to do this is to put the "command_or_script" into /usr/local/bin with root.root ownership, non-world-writable, and add that command_or_script only to /etc/sudoers. that way, you can run it as user with:

<pre>sudo -u user command_or_script</pre>

and let the system worry about the interpreter and its command line options.
[ January 14, 2005: Message edited by: M Beck ]
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic