What is the difference between "su --command" and "su --session-command"?
Posted
by
oliver
on Server Fault
See other posts from Server Fault
or by oliver
Published on 2014-05-30T11:23:43Z
Indexed on
2014/05/31
3:30 UTC
Read the original article
Hit count: 526
Running # su - oliver --command bash gives a shell but also prints the warning bash: no job control in this shell, and indeed Ctrl+Z and fg/bg don't work in that shell.
Running # su - oliver --session-command bash gives a shell without printing the warning, and job control indeed works.
The suggestion to use --session-command comes from Starting a shell from scripts using su results in "no job control in this shell" which states "[a security fix for su] changed the behavior of the -c option and disables job control inside the called shell".
But I still don't quite understand this. When should one use --command and when should one use --session-command? Is --command (aka -c) more secure? Or should one always use --session-command, and --command is just left in for backwards compatibility?
FWIW, I'm using RHEL 6.4.
© Server Fault or respective owner