How can run sudo commands inside another user, or grant a user the same privileges as an admin?

33,326

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.
Share:
33,326

Related videos on Youtube

Starkers
Author by

Starkers

Updated on September 18, 2022

Comments

  • Starkers
    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 into Permission 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 run sudo when inside postgres. 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
    Starkers over 10 years
    Ah awesome. There's no security issues with doing this? I'll be able to run sudo commands inside postgres?
  • Ashutosh Nigam
    Ashutosh Nigam almost 9 years
    I tried it but it did not work for me.
  • Avinash Raj
    Avinash Raj over 7 years
    @AshutoshNigam drop into root shell and run the above command.