I am new to Linux, can anyone be kind enough to help me know how to install software from the terminal?

I tried to install java by entering the command in the terminal

sudo apt-get install openjdk-7-jdk

but i get errors ,

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?

I also tried root

su -

but it says that the password is incorrect, so what is root ?

Advance Thanks for the help Guys.


By using sudo, you are temporarily becoming root for the duration of that command, just like you'd switched to root with su - root, executed the command, and switched back with exit.

Out of the box, Ubuntu doesn't configure a password for root, so you cannot log in as root directly like you're attempting to do with su. You either have to use sudo, or configure a password for the root user. It is recommended that you simply use sudo.

Are you sure you used sudo when trying to run the install command?

  • To summarize, are you sure you used sudo when you ran the first command? If so, then maybe another package manager is running at the same time, though this seems unlikely. – thomasrutter Mar 18 '13 at 1:21

You will get that error if you have the gui (graphic user interface) open. Check the desktop, is synaptic package manager open?

Not the answer you're looking for? Browse other questions tagged or ask your own question.