Executing a command as another user
Sometimes, it's useful to execute commands as another user. For instance, management commands for some services are, by default, accessible to the system user associated with the service. You may also wish to test whether a user account is configured correctly and execute a command as another user to check if it will work as expected.
Getting ready
In this recipe, we will create a new PostgreSQL database named testdb
by issuing the createdb
command that is available to the postgres
user. If you do not have PostgreSQL installed yet, you may refer to Chapter 10, Running a PostgreSQL Database Server, for information about installing and running this database system.
How to do it...
To execute a command as another user, we will use the Running Processes module:
Navigate to System | Running Processes.
Select Run.. in the Display line.
Enter
createdb testdb
in the Command to run textbox.Select Wait until complete as Run mode.
Enter
postgres
in the Run as user textbox...