What Is /Bin/Sh -C?

What Is /Bin/Sh -C?

What does /bin/sh -c mean? What does -c do?

0

2 Answers

From the man-page of bash:

-c string

If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

Example:

$ bash -c ls

will launch bash and execute the command ls.

/bin/sh is usually a symlink to a shell.

5

With -c (command) it returns to the first shell instead of let open a new one.
It is very similar to: sudo su -l -c 'echo "run a command and return"'
Example:

#sudo su -l knoppix -c 'echo "run a command as ${USER} and return"'
run a command as knoppix and return
#
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.