Что такое формат файла LOCK?
A .lock file is used to lock a resource or file, supported by various operating systems and programs. When files or resources are accessed concurrently by multiple processes or users, the .lock file signals other applications to wait until the resource is released. The .lock file is typically an empty (zero-byte) file; however, it can contain a short plain-text payload - such as a process ID (PID), hostname, username, or timestamp - depending on which application created it. .lock files are widely supported on Linux, macOS, Windows, and other platforms, going well beyond the early Unix-based systems where the convention originated.
There is no fixed internal format or magic number; the file's mere existence indicates the resource is in use. A second important application of .lock is in modern package managers: tools like npm (package-lock.json), Yarn (yarn.lock), Cargo (Cargo.lock), and Bundler (Gemfile.lock) write structured dependency manifests under this same extension to pin exact versions and ensure reproducible builds.
Related formats include .tmp temporary files and .pid process-ID files, which serve similar operational roles.
Безопасность и защита
РИСК: LOWA .lock file is inert - it cannot run and usually contains nothing. The only real risk is deleting one while the owning program is genuinely active, which can cause two processes to write the same database/file simultaneously and corrupt it. Always close/verify the owning app first. A .lock left behind by ransomware-style malware is a different thing entirely (it marks an encrypted file); if .lock files appear suddenly on many personal documents, treat it as a possible ransomware indicator, not a normal lock.
Детали формата
в двух словах- Package-manager dependency lock file - Files like Cargo.lock, Gemfile.lock, yarn.lock, poetry.lock, flake.lock pin exact dependency versions - real, editable text manifests, not empty markers.
- Application profile/session lock - Browsers and apps (e.g. Firefox profile .parentlock, LibreOffice .~lock files) create a lock to stop a second instance opening the same profile/document.
Программы, открывающие файлы LOCK
Технические подробности
глубокая спецификация| Mechanism type | Advisory (cooperative) locking: applications must voluntarily check for the file; the OS does not enforce exclusion |
| Lock signal | Mere existence of the file indicates the resource is held - no contents required |
| Typical file size | 0 bytes to a few KB; the vast majority are 0 bytes (empty sentinel) |
| Body encoding | Empty, or plain-text ASCII/UTF-8 - PID, hostname, username, file path, or timestamp |
| Magic bytes / header | None - no magic number or fixed header; identified by name and extension only |
| Platform support | Linux, Unix, macOS, Windows; cross-platform by convention |
| Lifecycle | Created by the owning process when it acquires the resource; deleted on clean release |
| Stale lock risk | If the owning process crashes without cleanup, the .lock file must be manually removed to restore access |
| Structured variant | Package manager manifests (package-lock.json, Gemfile.lock, Cargo.lock, yarn.lock, poetry.lock) share the extension but contain structured dependency data |
| Common applications | Text editors (LibreOffice, vim), databases (SQLite), browsers (Firefox profile), package managers (npm, Yarn, Bundler, Cargo, Poetry) |
| OS-level alternative | flock/fcntl on Unix, LockFileEx on Windows - often used alongside lock files for stronger guarantees |
| MIME type | application/octet-stream (empty/binary) or text/plain (text payload) |
| Выпущен | Long-standing Unix convention (1970s-1980s); used across many OSes and apps |
| Последняя версия | N/A - no single specification; meaning is defined per application |
Конвертации LOCK
Вопросы и ответы сообщества
спрошено пользователямиВопросов пока нет - станьте первым, кто спросит о файлах LOCK.