0

I have a script to setup a machine that need to change to another user. Unfortunately, I get a "permission denied" after the su command.

#!/bin/bash
# script executed from /home/foo/
touch hi_foo
cd /home/bar
sudo bar
touch hi_bar <-- permission denied

Any idea of a workaround? My script works well if I copy and paste it in the command line.

I am running Ubuntu 14.04

0

try:

#!/bin/bash
# script executed from /home/foo/
touch hi_foo
cd /home/bar
su bar touch hi_bar

you need to run your script with sudo so the process running your script will have sufficient rights to run su bar command

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.