How can run sudo commands inside another user, or grant a user the same privileges as an admin?
you must add the postgres user to the sudo group by running the below command.
sudo usermod -a -G sudo postgres
Logout and login back to take effect.
If the above command won't work then you need to drop into root shell and then apply the above command..
How to drop into root shell?
- Restart your PC.
- On the group menu, select Ubuntu Recovery Option.
- select
root
- From the root shell, run the above mentioned command.
Related videos on Youtube
Starkers
Updated on September 18, 2022Comments
-
Starkers over 1 year
Noob here, so just please tell me if this is stupid. Apologies also if the jargon in the title is a little off.
Here's my problem. I have a user,
postgres
which I use for all tasks involving the postgres database server. However, I'm constantly running intoPermission denied
when running scripts in postgres. I have to keep logging out of postgres, chowning certain directories to postgres, and, obviously maybe, you can't runsudo
when insidepostgres
. If I do Ubuntu gives me this message:postgres is not in the sudoers file. This incident will be reported.
Kinky. How can I run sudo inside postgres or give postgres more privileges?
-
Starkers over 10 yearsAh awesome. There's no security issues with doing this? I'll be able to run sudo commands inside postgres?
-
Ashutosh Nigam almost 9 yearsI tried it but it did not work for me.
-
Avinash Raj over 7 years@AshutoshNigam drop into root shell and run the above command.