4

I set my password to ir****3 when installing Ubuntu, but when I try to use su - postgres on terminal and enter tge same password it shows authentication error: you are not a root user.

How can I fix this?

Zanna
  • 70,465
  • Please provide an example of the command you get the error on, or is it you cannot login. By default Ubuntu installs without a 'root' login, so sudo asks for your password and not root. Note: sudo is a command and not a login (it raises your privileges to root for the command that follows) – guiverc Feb 14 '18 at 06:44
  • I want to develop the database in my ubuntu but whenever I type su - postgres in my terminal of ubuntu it asks for a password thar I dont have – Ansh Gupta Feb 14 '18 at 07:03
  • I am entering my login password of ubuntu as a password in it but it shows as authentication error – Ansh Gupta Feb 14 '18 at 07:05
  • It sounds like you haven't given 'root' a password yet. Try setting a password using sudo, ie. sudo passwd (sudo will raise privileges to root then run passwd) – guiverc Feb 14 '18 at 07:06
  • 3
    su - postgres would require a login password for user postgres - that's nothing to do with "login sudo on terminal" as stated in your question nor of the root account's login password. – steeldriver Feb 14 '18 at 07:38

1 Answers1

7

In order to run

su - postgres 

you have to be root as the output says

=> If you are not root you have to run it with sudo like

sudo su - postgres

Or alternatively become root first using

sudo -i

su - postgres

Anyway both methods will only work, if your actual user is in the sudo group. You can check that listing all groups your user is in by running

groups

If it is not in the sudo group than you probably are not the one who installed this machine or have added this user afterwards.

By default the first added user during the installation is in the sudo group.

If this is the case you have to login as a user which is in the sudo group (or if this is not possible you can boot into a root terminal following this answer)

and add your user manually to the sudo group running

sudo adduser <username> sudo
dessert
  • 39,982
derHugo
  • 3,356
  • 5
  • 31
  • 51