Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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 have a PC with Ubuntu server and I use it with friends to program on a project over SSH. The problem is that sometimes we have the same file opened and if somebody changes something and saves the changes, he overwrites the changes of the other programmer.
How can I check (e.g. with Nautilus) if a file is already opened by somebody else or how can I block others from opening/editing the file I'm currently working on?
Thank you!

share|improve this question

You can try

lsof | grep <part_of_filename>

in the console. lsof will give you a list of all currently open files in the system. With grep you can filter out lines wich contain the search term.

If lsof is not available on your system, you can install it with

sudo apt-get install lsof
share|improve this answer
Thank you very much! Lsof is installed. Is there a possibility to implement this into the Nautilus, to see this immediately? Or to block the fies I opened? Anyway +1! – Roman Holzner Mar 13 '13 at 16:46
I just opened a file and did the command you gave me, but it is not displayed as open. It's just showing the DIRectories. What am I missing? – Roman Holzner Mar 13 '13 at 16:54
I'm not an expert on nautilus, but maybe you can write a script for that. – Michael Härtl Mar 13 '13 at 16:56
It probably depends on the editor, why the file is not listed as open. Maybe it opens the file, reads it into memory and then closes it again. In that case you're probably out of luck. You could try to use an editor with a locking option in that case. vim for example gives you a warning if you try to edit an already opened file. I'm not advocating to learn vim if you've never used it before, though - it has a really steep learning curve :) – Michael Härtl Mar 13 '13 at 16:58
You are almost certainly better off using some form of version control (subversion). – bodhi.zazen Mar 13 '13 at 16:58

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.