user3275435
user3275435

Reputation: 1

Can not install postgres in ubuntu

I tried to install postgresql using the following command

apt-get install -t squeeze-backports postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1

but i got the following error message.

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

how to fix this?

Upvotes: 0

Views: 2083

Answers (3)

Shashwat Gupta
Shashwat Gupta

Reputation: 5264

Simple steps to install postgresql latest version (Believe me -- try these commends to install postgresql..it will works perfectly )

sudo bash -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ 
precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

sudo apt-get update

sudo apt-get install postgresql-9.3 pgadmin3

For Open Terminal of postgres

sudo -u postgres psql postgres

Upvotes: 0

Craig Ringer
Craig Ringer

Reputation: 324265

It looks to me like you aren't running the command as root. Prefix it with "sudo".

sudo apt-get install -t squeeze-backports postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1

per the error message:

E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

However, it looks like you don't understand the command, as you're running Ubuntu and Squeeze is a Debian dist. I think you need to go back to the basics and read the instructions:

Upvotes: 2

sirFunkenstine
sirFunkenstine

Reputation: 8495

Some other program has a lock on download operations. Have you got another terminal open or synaptic package manager or anything? Close everything and try again. You can also delete this file /var/lib/dpkg/lock if that doesnt work. Or it might be a root access issue. try running with sudo

Upvotes: 1

Related Questions