File: lslocks.8

package info (click to toggle)
util-linux 2.42~rc1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 101,680 kB
  • sloc: ansic: 185,710; sh: 24,450; yacc: 1,288; makefile: 534; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (238 lines) | stat: -rw-r--r-- 5,797 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
'\" t
.\"     Title: lslocks
.\"    Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.20
.\"      Date: 2026-02-18
.\"    Manual: System Administration
.\"    Source: util-linux 2.42-rc1
.\"  Language: English
.\"
.TH "LSLOCKS" "8" "2026-02-18" "util\-linux 2.42\-rc1" "System Administration"
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
.  mso www.tmac
.  am URL
.    ad l
.  .
.  am MTO
.    ad l
.  .
.  LINKSTYLE blue R < >
.\}
.SH "NAME"
lslocks \- list local system locks
.SH "SYNOPSIS"
.sp
\fBlslocks\fP [options]
.SH "DESCRIPTION"
.sp
\fBlslocks\fP lists information about all the currently held file locks in a Linux system.
.SH "OPTIONS"
.sp
\fB\-b\fP, \fB\-\-bytes\fP
.RS 4
Print sizes in bytes rather than in human\-readable form.
.sp
By default, sizes are shown in units that are powers of 1024 bytes.
The formal abbreviations for these units (KiB, MiB, GiB, ...) are
further shortened to just their first letter: K, M, G, ....
.RE
.sp
\fB\-H\fP, \fB\-\-list\-columns\fP
.RS 4
List the columns that can be specified with the \fB\-\-output\fP option.
Can be used with \fB\-\-json\fP or \fB\-\-raw\fP to get the list in a machine\-readable format.
.RE
.sp
\fB\-i\fP, \fB\-\-noinaccessible\fP
.RS 4
Ignore lock files which are inaccessible for the current user.
.RE
.sp
\fB\-J\fP, \fB\-\-json\fP
.RS 4
Use JSON output format.
.RE
.sp
\fB\-n\fP, \fB\-\-noheadings\fP
.RS 4
Do not print a header line.
.RE
.sp
\fB\-o\fP, \fB\-\-output\fP \fIlist\fP
.RS 4
Specify which output columns to print. Use \fB\-\-help\fP to get a list of all supported columns.
.sp
The default list of columns may be extended if \fIlist\fP is specified in the format \fI+list\fP (e.g., \fBlslocks \-o +BLOCKER\fP).
.RE
.sp
\fB\-\-output\-all\fP
.RS 4
Output all available columns.
.RE
.sp
\fB\-p\fP, \fB\-\-pid\fP \fIpid\fP
.RS 4
Display only the locks held by the process with this \fIpid\fP.
.RE
.sp
\fB\-Q\fP, \fB\-\-filter\fP \fIexpr\fP
.RS 4
Print only the locks that meet the conditions specified by the expr.
.sp
This feature is EXPERIMENTAL. See also \fBscols\-filter\fP(5). For example
exclude POSIX type locks, but print all READ mode ones locks on files
with \fI.qcow2\fP as extension:
.RE
.RS 3
.ll -.6i
.sp
.if n .RS 4
.nf
.fam C
lslocks \-\-filter \*(AqTYPE != "POSIX" and MODE == "READ" and PATH =~ ".*\(rs.qcow2"\*(Aq
.fam
.fi
.if n .RE
.br
.RE
.ll
.sp
\fB\-r\fP, \fB\-\-raw\fP
.RS 4
Use the raw output format.
.RE
.sp
\fB\-u\fP, \fB\-\-notruncate\fP
.RS 4
Do not truncate text in columns.
.RE
.sp
\fB\-h\fP, \fB\-\-help\fP
.RS 4
Display help text and exit.
.RE
.sp
\fB\-V\fP, \fB\-\-version\fP
.RS 4
Display version and exit.
.RE
.SH "OUTPUT"
.sp
COMMAND
.RS 4
The command name of the process holding the lock.
.RE
.sp
PID
.RS 4
The process ID of the process.
.RE
.sp
TYPE
.RS 4
The type of lock; can be LEASE (created with \fBfcntl\fP(2)), FLOCK (created with \fBflock\fP(2)), POSIX (created with \fBfcntl\fP(2) and \fBlockf\fP(3)) or OFDLCK (created with \fBfcntl\fP(2)).
.RE
.sp
SIZE
.RS 4
Size of the locked file.
.RE
.sp
INODE
.RS 4
The inode number.
.RE
.sp
MAJ:MIN
.RS 4
The major:minor device number.
.RE
.sp
MODE
.RS 4
The lock\(cqs access permissions (read, write). If the process is blocked and waiting for the lock, then the mode is postfixed with an \*(Aq*\*(Aq (asterisk).
.RE
.sp
M
.RS 4
Whether the lock is mandatory; 0 means no (meaning the lock is only advisory), 1 means yes. (See \fBfcntl\fP(2).)
.RE
.sp
START
.RS 4
Relative byte offset of the lock.
.RE
.sp
END
.RS 4
Ending offset of the lock.
.RE
.sp
PATH
.RS 4
Full path of the lock. If none is found, or there are no permissions to read the path, it will fall back to the device\(cqs mountpoint and "..." is appended to the path. The path might be truncated; use \fB\-\-notruncate\fP to get the full path.
.RE
.sp
BLOCKER
.RS 4
The PID of the process which blocks the lock.
.RE
.sp
HOLDERS
.RS 4
The holder(s) of the lock.  The format of the holder is \fIPID\fP,\fICOMMAND\fP,\fIFD\fP.
If a lock is an open file description\-oriented lock, there can be more than one holder for the lock.
See the NOTES below.
.RE
.SH "ENVIRONMENT"
.sp
LSLOCKS_COLUMNS=
.RS 4
Specifies a comma\-separated list of output columns to print. All columns listed by \fB\-\-list\-columns\fP can be used.
.RE
.SH "NOTES"
.sp
The \fBlslocks\fP command is meant to replace the \fBlslk\fP(8) command, originally written by \c
.MTO "abe\(atpurdue.edu" "Victor A. Abell" ""
and unmaintained since 2001.
.sp
"The process holding the lock" for leases, FLOCK locks, and
OFD locks is a fake\-concept.  They are associated with the open file
description on which they are acquired.  With \fBfork\fP(2) and/or
\fBcmsg\fP(3), multiple processes can share an open file description. So
the holder process of a lease (or a lock) is not uniquely determined.
\fBlslocks\fP shows the one of the holder processes in COMMAND and PID columns.
.sp
The default output is subject to change. So whenever possible, you should avoid using default output in your scripts.
.sp
For OFD locks, the PID column may show \-1. Such lines cannot be
selected by the filter, because the current filter engine does not
support negative numbers.
.SH "AUTHORS"
.sp
\c
.MTO "dave\(atgnu.org" "Davidlohr Bueso"
.MTO "cgoesc2\(atwgu.edu" "Christian Goeschel Ndjomouo" ""
.SH "SEE ALSO"
.sp
\fBflock\fP(1),
\fBfcntl\fP(2),
\fBlockf\fP(3),
\fBscols\-filter\fP(5)
.SH "REPORTING BUGS"
.sp
For bug reports, use the \c
.URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "."
.SH "AVAILABILITY"
.sp
The \fBlslocks\fP command is part of the util\-linux package which can be downloaded from \c
.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."