fuser — list process IDs of all processes that are using one or more named files
[XSI] fuser [-cfu] file...
For each file operand, in order, fuser shall write one line of output, some of it to standard output, and the rest to standard error, giving information about processes running on the local system that are using the file. A process shall be considered to be using a file if it has at least one open file descriptor associated with the file or if the file is a directory that is the current working directory or the root directory for the process, and may be considered to be using a file for other implementation-dependent reasons. If file names a block special device that contains a mounted file system, and the -f option is not specified, any processes using any file on that mounted file system and any processes that are using the device file itself shall be listed.
Any output for processes running on remote systems that are using a named file is unspecified.
A user may need appropriate privileges to invoke the fuser utility.
When standard output and standard error are directed to the same file, the output for each file operand shall be interleaved so that it is written to the file in the following order:
On standard error, a pathname for the file, immediately followed by a <colon> and zero or more <blank> characters. The pathname shall be either the file operand (unaltered) or the pathname that would result from a successful call to the realpath() function, defined in the System Interfaces volume of POSIX.1-2024, with the file operand as its file_name argument.
For each process using the file:
On standard output, the process ID in the format:
" %1d", <process ID>On standard error, information about the file's use by the process, in the following format:
"%s", <use chars>if the -u option is not specified, or in the following format:
"%s(%s)", <use chars>, <user name>if the -u option is specified, where <use chars> is a string of zero or more characters indicating the use of the file and <user name> is the user name corresponding to the real user ID of the process or, if the user name cannot be resolved from the real user ID of the process, the real user ID of the process in decimal. The value of <use chars> shall include the character 'c' if the process is using the file as its current directory and the character 'r' if the process is using the file as its root directory; implementations may include other alphabetic characters to indicate other uses of the file.
On standard error, a <newline> character.
When standard output and standard error are not directed to the same file, the data written to each shall be as described above but the ordering of writes to standard output relative to writes to standard error is unspecified. For example, fuser might first write the information for all file operands to standard error and then write all of the process IDs to standard output.
The fuser utility shall conform to XBD 12.2 Utility Syntax Guidelines .
The following options shall be supported:
- -c
- If a file operand names a directory that is the mount point of a mounted file system, all processes using any file on that file system shall be listed as if they were using the named directory. The behavior for any file operand that names an existing file that is not the mount point of a mounted file system is unspecified.
- -f
- The report shall be only for the named files.
- -u
- The user name, in parentheses, associated with each process ID written to standard output shall be written to standard error.
The following operand shall be supported:
- file
- A pathname of a file for which the processes using the file are to be reported.
Not used.
The user database.
The following environment variables shall affect the execution of fuser:
- LANG
- Provide a default value for the internationalization variables that are unset or null. (See XBD 8.2 Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalization variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).
- LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.- NLSPATH
- Determine the location of messages objects and message catalogs.
Default.
See DESCRIPTION.
The fuser utility shall write diagnostic messages to standard error.
The fuser utility also shall write information to standard error as specified in the DESCRIPTION section.
None.
None.
The following exit values shall be returned:
- 0
- Successful completion.
- >0
- An error occurred.
Default.
Things can change while fuser is running; the snapshot it gives is only true for an instant, and might not be accurate by the time it is displayed.
The command:
fuser -fu .writes to standard output the process IDs of processes that are using the current directory and writes to standard error an indication of how those processes are using the directory and the user names associated with the processes that are using the current directory.
fuser -c <mount point>writes to standard output the process IDs of processes that are using any file in the file system which is mounted on <mount point> and writes to standard error an indication of how those processes are using the files.
fuser <mount point>writes to standard output the process IDs of processes that are using the file which is named by <mount point> and writes to standard error an indication of how those processes are using the file.
fuser <mounted block device>writes to standard output the process IDs of processes that are using any file on the mounted file system contained by <mounted block device> and of processes that are using the device file <mounted block device> itself, and writes to standard error an indication of how those processes are using the files.
fuser -f <mounted block device>writes to standard output the process IDs of processes that are using the file <mounted block device> itself and writes to standard error an indication of how those processes are using the file.
The definition of the fuser utility follows existing practice.
If this utility is directed to display a pathname that contains any bytes that have the encoded value of a <newline> character when <newline> is a terminator or separator in the output format being used, implementations are encouraged to treat this as an error. A future version of this standard may require implementations to treat this as an error.
XBD 8. Environment Variables , 12.2 Utility Syntax Guidelines
First released in Issue 5.
SD5-XCU-ERN-90 is applied, updating the EXAMPLES section.
SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.
Austin Group Defect 251 is applied, encouraging implementations to report an error if a utility is directed to display a pathname that contains any bytes that have the encoded value of a <newline> character when <newline> is a terminator or separator in the output format being used.
Austin Group Defect 1122 is applied, changing the description of NLSPATH .
Austin Group Defect 1746 is applied, clarifying the output written to standard output and standard error.
return to top of page