In Linux, file locks are not stored directly in files. Instead, they are managed by the kernel and stored within the kernel's memory. The kernel maintains a data structure called "file_lock" for each file that has an associated lock. These file_lock structures contain information about the process that holds the lock, the lock type (read or write), the portion of the file locked (an offset and length), and other relevant data.
When a process requests a file lock using the "fcntl" system call or similar locking mechanisms, the kernel checks if any conflicting locks are already present on the file. If no conflicts are found, the kernel creates a new file_lock structure and attaches it to the file's internal data structures.
Since file locks are stored in kernel memory and associated with the specific file, they are not visible in the file system itself. File locks only exist during the duration of the lock and are automatically released when the process holding the lock releases it or terminates.