| Main index | Section 1 | 日本語 | Options |
The following options are available:
| | Restrict examination to files open in the same file systems as the named file arguments, or to the file system containing the current directory if there are no additional filename arguments. For example, to find all files open in the file system where the directory /usr/src resides, type ‘fstat -f /usr/src’. |
| | |
| Extract values associated with the name list from the specified core instead of the default /dev/kmem. | |
| | Include memory-mapped files in the listing; normally these are excluded due to the extra processing required. |
| | |
| Extract the name list from the specified system instead of the default, which is the kernel image the system has booted from. | |
| | Numerical format. Print the device number (maj,min) of the file system the file resides in rather than the mount point name; for special files, print the device number that the special device refers to rather than the filename in /dev; and print the mode of the file in octal instead of symbolic form. |
| | |
| Report all files open by the specified process. | |
| | Print socket endpoint information. |
| | |
| Report all files open by the specified user. | |
| | Verbose mode. Print error messages upon failures to locate particular system data structures rather than silently ignoring them. Most of these data structures are dynamically created or deleted and it is possible for them to disappear while fstat is running. This is normal and unavoidable since the rest of the system is running while fstat itself is running. |
| file ... | Restrict reports to the specified files. |
The following fields are printed:
| USER | The username of the owner of the process (effective uid). |
| CMD | The command name of the process. |
| PID | The process id. |
| FD |
The file number in the per-process open file table or one of the following
special names:
|
| jail | jail root directory |
| mmap | memory-mapped file |
| root | root inode |
| text | executable text inode |
| tr | kernel trace file |
| wd | current working directory |
If the file number is followed by an asterisk (‘*’), the file is not an inode, but rather a socket, FIFO, or there is an error. In this case the remainder of the line does not correspond to the remaining headers— the format of the line is described later under SOCKETS.
| MOUNT |
If the
|
| DEV |
If the
|
| INUM | The inode number of the file. |
| MODE |
The mode of the file.
If the
|
| SZamp;|DV | |
|
If the file is a semaphore,
prints the current value of the semaphore.
If the file is not a character or block special, prints the size of
the file in bytes.
Otherwise, if the
| |
| R/W | This column describes the access mode that the file allows. The letter ‘r’ indicates open for reading; the letter ‘w’ indicates open for writing. This field is useful when trying to find the processes that are preventing a file system from being down graded to read-only. |
| NAME |
If filename arguments are specified and the
|
For example, the addresses mentioned above are the addresses which the ‘netstat -A’ command would print for TCP, UDP, and UNIX-domain. Note that since pipes are implemented using sockets, a pipe appears as a connected UNIX-domain stream socket. A unidirectional UNIX-domain socket indicates the direction of flow with an arrow (‘<-’ or ‘->’ ), and a full duplex socket shows a double arrow (‘<->’).
When the
$ fstat | awk '$2 != "fstat"' USER CMD PID FD MOUNT INUM MODE SZ|DV R/W alice bash 469 text /usr/local 143355 -rwxr-xr-x 1166448 r alice bash 469 ctty /dev 346 crw--w---- pts/81 rw amp;...
Report all files opened by the current shell in the same file system as /usr/local including memory-mapped files:
$ fstat -m -p $$ -f /usr/local USER CMD PID FD MOUNT INUM MODE SZ|DV R/W bob bash 469 text /usr/local 143355 -rwxr-xr-x 1166448 r bob bash 469 mmap /usr/local 143355 -rwxr-xr-x 1166448 r amp;...
Requesting information about a file that is not opened results in just a header line instead of an error:
$ fstat /etc/rc.conf USER CMD PID FD MOUNT INUM MODE SZ|DV R/W NAME
All parameters after
$ fstat -f /usr/local -m -p $$ fstat: -m: No such file or directory fstat: -p: No such file or directory fstat: 469: No such file or directory amp;...
Show number of pipes opened by firefox processes:
$ fstat | awk '$2=="firefox" && $5=="pipe"' | wc -l
Show processes belonging to user "bob" whose standard error descriptor is opened in ttyv0:
$ fstat -u bob | awk '$4 == 2 && $8 == "ttyv0"' bob firefox 77842 2 /dev 103 crw------- ttyv0 rw bob xinit 1194 2 /dev 103 crw------- ttyv0 rw amp;...
Show opened TCP sockets. This output resembles the one produced by ‘netstat -A -p tcp’ :
$ fstat | awk '$7 == "tcp"' alice firefox 77991 32* internet stream tcp fffff800b7f147a0 alice firefox 77991 137* internet stream tcp fffff800b7f12b70 amp;...
Show a list of processes with files opened in the current directory mimicking the output of fuser(1) :
$ fstat . | awk 'NR > 1 {printf "%d%s(%s) ", $3, $4, $1;}'
2133wd(alice) 2132wd(alice) 1991wd(alice)
Create a list of processes sorted by number of opened files in descending order:
$ fstat | awk 'NR > 1 {print $2;}' | sort | uniq -c | sort -r
728 firefox
23 bash
14 sort
8 fstat
7 awk
| FSTAT (1) | November 19, 2020 |
| Main index | Section 1 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
| “ | Do you laugh when the waiter drops a tray full of dishes? Unix weenies do. They're the first ones to laugh at hapless users, trying to figure out an error message that doesn't have anything to do with what they just typed. | ” |
| — The Unix Haters' handbook | ||