Simple Locking Wrapper for VI

This post presents a quick way to add file locking to the vi editor.

The vi editor is found on pretty much every unix system, which means it is often used by system administrators to update configuration files. Unfortunately vi does not lock the file being edited. This can lead to two or more people inadvertently editing the same file at the same time. Edits can become duplicated, confused or lost entirely, perhaps leaving the file in a non-working state.

Editing Critical Files

It is bad enough in the case of small files such as yum.conf or ntp.conf. More serious are files like /etc/fstab, where a simple syntax error could lead to an unbootable system. Worst of all are network-wide resources like DNS zone files. A mistake here could mess up more than one machine. Continue reading