0

When I run the following it works:

sudo -u apache 'whoami'

But when I run this, it says command not found:

sudo -u apache 'ls -al ~/.ssh'

How do I fix this?

1 Answer 1

2

sudo sees the entire ls -al ~/.ssh string as one argument and runs it as one, as if the apache user invoked

'ls -al ~/.ssh'

And this doesn't work because there is no tool named literally ls -al ~/.ssh as a whole. Your command should be more like

sudo -u apache ls -al ~/.ssh

Note this will expand ~ before sudo even starts, in the context of your actual user. This, on the other hand:

sudo -u apache ls -al ~apache/.ssh

may be what you really want.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .