Sudo for full script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Sudo for full script
# 1  
Old 07-13-2016
Sudo for full script

All,

When enabling sudo to run a script as root (install scripts, etc), is it required to enable sudo on all the actions/commands in the script or simply on the script itself and everything will run as root?

Thanks in advance,

HB
# 2  
Old 07-13-2016
You just need to enable sudo on the script itself.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 07-13-2016
Thank you for the confirmation Don..
# 4  
Old 07-15-2016
You also need to make sure that sudo is not called from within the script (as some do)

If this is the case and you cannot get them out, then assuming that you are running as root you need to check that root is authorised too. It might seem odd, but the rules for sudo can catch you. We just added a rule to say that root could run anything as root through sudo and all seemed fine.

You may have further problems to consider if you are saying would want to run as some sort of application or service account that then needs to sudo occasionally.



Sorry to chuck in a few worries, but probably best to be prepared.




Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SUDO command in script

hi, can some one explain the sudo -n equivalent in AIX Thanks Venkat K (5 Replies)
Discussion started by: venky.b5
5 Replies

2. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

3. Shell Programming and Scripting

Help with Shell Script on sudo

I want to execute a script(generateReport.sh) which resides on root home directory from shell script(localtrigger.sh) as root by using sudo. The thing is i cant edit /etc/sudoers (i can but m not allowed to do it , ethically) i cant change ownership of generateReport.sh script When i try... (7 Replies)
Discussion started by: saket
7 Replies

4. Shell Programming and Scripting

password in sudo script

salmo allikm warhmat allah wabrakato i want to do script with sudo like sudo su and want to put password in the script not get from user because i to made it startup when booting and i don't know how put in script for sudo thanks (5 Replies)
Discussion started by: pua06
5 Replies

5. Shell Programming and Scripting

HOw can i use sudo in a script

Hi Everyone, i am writing a script which will display all channels as below sudo /usr/bin/su - mycamqrd chs I kept the above two lines in a ksh and after ran that it is going to mycamqrd home dir(sudo /usr/bin/su - mycamqrd).. The script is coming out and it is not executing chs. Please... (5 Replies)
Discussion started by: rajesh212512
5 Replies

6. Shell Programming and Scripting

Maintain full path of a script in a var when sourcing it from a different script

Hi All, I've searched through the forum for a solution to this problem, but I haven't found anything. I have 2 script files that are in different directories. My first script, let's call it "/one/two/a.sh" looks like this: #!/bin/sh IN_DIR=`dirname $0` CUR_DIR=`pwd` cd $IN_DIR... (4 Replies)
Discussion started by: mrbluegreen
4 Replies

7. Shell Programming and Scripting

problem with sudo su and .sh script

here is my script: #!/bin/sh cd /Users/a echo "what is the name of the file u want?" read var1 var1=$var1... (1 Reply)
Discussion started by: cleansing_flame
1 Replies

8. Linux

full system backup script

Please help. I am new to linux. I wrote a script to run the backup on lunix machine but the job gave me an error. I am using Linux 2.6.14.3. Below is the sample of my script can anyone tell me where went wrong? Thanks in advance. #!/bin/sh dat=$(date +%d%b%y)... (5 Replies)
Discussion started by: clement
5 Replies

9. Shell Programming and Scripting

Full-Screen Script

Hi guys Pls I would like knew how to execut a script in full-screen. My shell is Korn in HP-UX 10.20. Thanks. Morcegao (1 Reply)
Discussion started by: Morcegao30
1 Replies
Login or Register to Ask a Question