21
votes
7answers
812 views

Should scripts that require sudo fail if they don't have it, or use sudo and prompt?

I have a script which gives me fine-grained control over my backlight brightness and requires sudo to run. It's essentially this: backlight="/sys/class/backlight/acpi_video0/brightness" echo $1 | tee ...
14
votes
3answers
1k views

If I sudo execute a Bash script file, will all commands inside the Bash script be executed as sudo as well?

I want to write an automated post-installation script in Bash (called post-install.sh, for instance). The script will automatically add and update repositories, install and update packages, edit ...
1
vote
2answers
75 views

Script to su -c into a screen is not working as intended

I'm working on a script that will allow me to load up a screen from a user via sudo and su -c. However, when I use it, it will just show the shell of the user: sudo su -c "script /dev/null; screen -r ...
-3
votes
1answer
60 views

where is this HOME environment variable and what do I have to add -H too it?

I recently attempted to run a boot up script which failed I didn't know why it failed so I posted a question about that here. chkconfig bootup script failing, script runs good manually Where the ...
1
vote
1answer
143 views

Exiting a Bash script when a sudo child quits

I'm trying to launch a couple of sub-programs from a bash script and then wait on either of them to quit before quitting the other and exiting the script. CMD1PID= CMD2PID= exit_trap () { ...
7
votes
3answers
773 views

which shell will sudo use to execute a shell script without the shebang line

My environment is Ubuntu 12.04 LTS, and the sudo version is 1.8.3p1. First I login as a normal user: $ whoami fin $ cat /etc/passwd | grep -i "root\|fin" root:x:0:0:root:/root:/bin/bash ...
2
votes
1answer
561 views

Why does this Bash NRPE plugin not return a variable to Nagios?

This is a very specific question I have here, maybe one has a simple answer for it. This script I have here works locally just fine: #! /bin/bash volts=`sudo vcgencmd measure_volts core|sed ...
1
vote
3answers
91 views

Confused on user and su in linux

How could I run a script as a specific user (non-root)? As this? sudo su - john /usr/share/script.pl for user john?
2
votes
2answers
2k views

How to run sudo commands remotely via ssh -t?

I have a script that logs into a remote host via ssh -t and uses sudo service foo restart. The requirement is to avoid the prompt for a password on the remote host. The remote host authenticates via ...
1
vote
1answer
225 views

chmod and chown not working in sudo called script

Based on this Serverfault question, my git user has permission in sudoers to run a wrapper script to move files into my webroot with git. Everything is working fine except for the chmod and chown ...
10
votes
4answers
7k views

Why doesn't “sudo su” in a shell script run the rest of the script as root?

A sample script can be as below: #!/bin/bash sudo su ls /root When using ./test.sh as the normal user, instead run ls as super user and exit, it switches to root; and when I logout, it executes ls ...
3
votes
1answer
163 views

How does having /dev/fd make running shell scripts under sudo safe?

At the end of the man page for sudo, there's the following remark: Running shell scripts via sudo can expose the same kernel bugs that make setuid shell scripts unsafe on some operating systems ...
1
vote
1answer
186 views

Cannot enter in centOS with any user

I am using cent OS Operating system without GNOME. In the starting, it asks localhost login: Password: It has one user named service under group name service whose password is also service. I ...
3
votes
2answers
1k views

How to solve sudo: unable to execute /bin/ls: Argument list too long

When I run this command from php sudo -u db2inst1 ls -t /var/lib/edumate/bdrs/*/*/daily/*NODE* | sort -r I receive sudo: unable to execute /bin/ls: Argument list too long ls lists all daily backup ...
2
votes
1answer
497 views

Default fedora 15 install, how do you get a network drive to mount after login?

I am running a default fedora 15 install. My goal is to have a couple of network drives get mounted right after the user logs in graphically (not via ssh). The script I want to execute is basically ...
5
votes
4answers
2k views

Allow users to run only specific binaries with root permissions/privileges

I would like to allow a specific user to be able to sudo /sbin/iptables only. I have a bash script which configures iptables. The problem is that configuring /sbin/iptables as sudoable is not enough ...
11
votes
2answers
1k views

How to safely pass variables to root-enabled scripts?

This question is totally general and not only applicable to my situation, but... I have a small busybox appliance where I want a non-root user to be able to execute a particular script with root ...