I have seen a file named lock
in /var/cache/apt/archives
in my Ubuntu 14.04. This file has only root access. When I try to display the contents of this file using sudo nano lock
the file seems empty. What is actually the purpose of this file?
I have seen a file named lock
in /var/cache/apt/archives
in my Ubuntu 14.04. This file has only root access. When I try to display the contents of this file using sudo nano lock
the file seems empty. What is actually the purpose of this file?
The
lock
file you mention is used to avoid running more than one instance of any software able to add packages (apt-get
,aptitude
,synaptic
, ...).This is necessary because the list of installed software is saved in DB file. Having more than one process accessing this DB will lead to corruption into it and break your installed software DB.
Lock files are created by a program when it is necessary to have only one instance of this program running at the same time.
Generally, this is to avoid that local files/DB are accessed concurrently because this may corrupt them.
This is a marker file used to keep programs from changing a file simultaneously. Were that to happen, it's likely one of the changes would be lost.
So, you likely have a file in that directory that is being accessed by some program.