File locking in Linux

File locking is a mutual-exclusion mechanism for files. Linux supports two major kinds of file locks: advisory locks mandatory locks Below we discuss all lock types available in POSIX and Linux and provide usage examples.