Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just bought a NAS (Lenovo ix4-300d) that's running Debian, and I just found out how to enable SSH. I want to install Apache, MySQL and PHP for local development.

When I'm trying to use apt-get, I get the following error:

login as: root
root@192.168.1.76's password:
root@ix4-300d:/# apt-get install php5
E: Could not open lock file /var/lib/dpkg/lock - open (2 No such file or directory)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
root@ix4-300d:/# su
sh-3.2# apt-get install php5
E: Could not open lock file /var/lib/dpkg/lock - open (2 No such file or directory)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

Even though I sued to get root access, it still tells me I'm not root when trying to use apt-get.

How do I fix apt-get here?

share|improve this question

closed as off-topic by longneck, jscott, EEAA, mdpc, Ladadadada Jul 31 '13 at 11:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – jscott, EEAA, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 0 down vote accepted

Well, it looks like for some reason, Debian was unable to open up the lock file apt uses. This seems to be a massively common thing according to Google.

This seems to be a logical solution - that /var/lib/dpkg/lock dosen't exist - so checking for the existence of and creating /var/lib/dpkg/ might help.

If it also complains that /var/lib/dpkg/status doesn't exist, you should be able to copy it from a backup by doing cp /var/backups/dpkg.status.0 /var/lib/dpkg/status as root.

share|improve this answer

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