Executing Linux Command as Another User

Sometimes you need to execute a command as another user to test newly installed or configured software. For instance, if you just installed snort you want to make sure it’s going to run ok as the snort user. It’s relatively simple.

su username -c command
So if you wanted to execute a backups script called backup.sh as the user named backupadmin then you would type:

su backupadmin -c backup.sh

Leave a comment

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