I am creating a bash script that requires to run commands as a specific user. As a result I am using the command:
I have tested this script and it works perfectly in Ubuntu Server 14.10. However, when testing it on 14.04 and 12 I run into the following error:
runuser: command not found
This happens any time the runuser command is used.
I am using the following command to create a new user:
adduser --no-create-home --home "/home/$homedir" --disabled-password --gecos "$realname" "$uname" ; usermod -p "$passwd" "$uname"
Is there something specific that needs to be specified when creating the new user? Is there a particular dependency that is missing?
Edits For Questions:
Output of echo $PATH
Output of ls -l /sbin/runuser
ls: cannot access /sbin/runuser: No such file or directory
The reason why I want to use runuser vs su is because of the following:
When using runuser I can run the following commands:
runuser user -c 'cd' runuser user -c 'wget http://file.com'
Whereas with su I have to chain the commands like this:
su user -c 'cd; wget http://file.com'