Option -c
is understood by command su
, taking the next argument (not the remaining) to be the command. That next command is just cp
.
Try putting the command into quotes:
su - test -c 'cp /home/test/toto.txt /home/test/dir'
If this is problematic because you want to have quotes inside the command, try using escape instead of the inner quotes:
su - test -c 'echo hello\ \ there'