DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Running Commands as Another User via sudo

You want one user to run commands as another, without sharing passwords.

Suppose you want user smith to be able to run a given command as user jones.

smith  ALL = (jones) /usr/local/bin/mycommand
User smith runs:
smith$ sudo -u jones /usr/local/bin/mycommand
smith$ sudo -u jones mycommand                     If /usr/local/bin is in $PATH
User smith will be prompted for his own password, not jones’s. 
The ALL keyword, which matches anything, in this case specifies that the line is valid on any host.

sudo exists for this very reason!

To authorize root privileges for smith, replace “jones” with “root” in the above example.

Do you like this story?

1 comment:

  1. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks!
    DevOps Training
    DevOps Online Training