Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can see there are many lock file here and there in my system. What is the exact role and purpose of those lock files?

In my system I got this list,

share|improve this question
up vote 2 down vote accepted

They are all lock files. Link for more information.

Different applications and daemons create their lock files, if they need to protect themselves from crashing or from corrupting information.

For example:


lock for whoopsie, it is Ubuntu Error Reporting daemon. It collects information about crashes, so it need to protect some information from changes until it collects everything.


Lock file for you cdrom device. Only one application at a time can control cdrom device, that's why it is there. The same thing for every devices.


Lock file for package managers. They usually blocking their sources database

Also a little quote from wikipedia:

The following example illustrates the interceding update problem:

  1. Process A reads a customer record from a file containing account information, including the customer's account balance and phone number.

  2. Process B now reads the same record from the same file so it has its own copy.

  3. Process A changes the account balance in its copy of the customer record and writes the record back to the file.

  4. Process B, which still has the original stale value for the account balance in its copy of the customer record, updates the account balance and writes the customer record back to the file.

  5. Process B has now written its stale account-balance value to the file, causing the changes made by process A to be lost.

This is one of examples. There many other situations that can lead to a problem. That's why OS need lock files

share|improve this answer

They're generally used to ensure only one instance of an application is running at once.

This is particularly important in programs like apt-get which may break if more than one instance runs at once.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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