- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to run a command as root using sudo (indicatin...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2011 04:01 PM
08-02-2011 04:01 PM
How to run a command as root using sudo (indicating the password) from a script.
Hi all,
let me tell you what i have:
HP-UX B.11
my userid is : myuser1
this user has to run /usr/sbin/lpshut and /usr/sbin/lpsched.
the user myuser1 has privileges to use "sudo su -" , when myuser1 has privileges to use "sudo su -" the password is required (pass of myuser1 to use sudo, i have the password of myuser1, it is "secret") , this a rule for the company for using the sudo.
when myuser1 uses sudo su - , then i can run lpshut and lpsched.
i am bulding a script in which has to shutdown (/usr/sbin/lpshut) the scheduler and then start it (/usr/sbin/lpsched.)
Could you please let me know how i can to run the comands lpshut and lpsched using myuser1 knowing it has sudo privileges and i have to enter the password?
how can i code that in a script?
Thank you in advance.
- Tags:
- sudo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2011 11:40 PM
08-02-2011 11:40 PM
Re: How to run a command as root using sudo (indicating the password) from a script.
Hi,
> How to run a command as root using sudo (indicating the password) from a script.
# cat script.sh
ssh myuser1@localhost sudo /usr/sbin/lpshut
ssh myuser1@localhost sudo /usr/sbin/lpsched
#---End of script
This will ask you to enter password of myuser1 & then as myuser1 is having password-less rights to access sudo, it will directly execute lpshut & lpsched commands without asking for root user passwords.
Hope this is what u wants....Cheers....
Was this post useful? - You may click the KUDOS! star to say thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2011 01:03 AM
08-03-2011 01:03 AM
Re: How to run a command as root using sudo (indicating the password) from a script.
>the user myuser1 has privileges to use "sudo su -"
Then he can do any root command. Unless you tell sudo that he can only do lpshut and lpsched.
>Could you please let me know how I can to run the commands lpshut and lpsched using myuser1
The user will have to type the password in for each of those commands. Unless you can combine them together in one script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2011 05:23 AM
08-03-2011 05:23 AM
Re: How to run a command as root using sudo (indicating the password) from a script.
Hi:
You should be able to do something like:
myaccount ALL=(ALL) NOPASSWD:/usr/sbin/lpshut NOPASSWD:/usr/sbin/lpsched
The documentation on the 'sudo' home is your best source of information:
xhttp://www.gratisoft.us/sudo/man/1.8.1/sudoers.man.html
The idea of using SUDO is to provide accountability and often to confer privilege in a granular way. Defining users who can run *anything* as root when the user needs only a specific function is making swiss cheeze of security.
Regards!
...JRF...