Linux – Running su with -c gives unrecognized command error

linuxsu

I am trying to run a command as another user in Linux. Here is what I run:

su user1 -c '/bin/mkdir /tmp/zz'

However, this gives me this error:

fatal: unrecognized command '/bin/mkdir /tmp/zz'

Best Answer

You need to swap the single quotes for double quotes. Not that these are only required with commands that take parameters, or if you chain several commands together.

su user1 -c "/bin/mkdir /tmp/zz"