How to run command as another user in Linux

Sometimes its necessary to execute commands as another user than the logged in. We can use runuser to achieve such requirements.

#runuser -l  username -c 'command'

Here we need to replace username and command appropriately.

Alternatively we can use su command also.

#su - username -c "command"

Here we need to replace username and command appropriately.

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *