pavement

Fstat

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Expanding on the fstat article)
Line 3: Line 3:
 
  '''fstat -f /usr/local/etc''' - only return locked files from the filesystem containing '''/usr/local/etc/''' ('''/usr''', on most systems)
 
  '''fstat -f /usr/local/etc''' - only return locked files from the filesystem containing '''/usr/local/etc/''' ('''/usr''', on most systems)
 
  '''fstat -p qmail-send''' - only return files locked by the '''qmail-send''' process
 
  '''fstat -p qmail-send''' - only return files locked by the '''qmail-send''' process
'''fstat -u jimbo''' - only return files locked by the user '''jimbo'''
 
 
  '''fstat /usr/local/sbin/smbd''' - only return info on processes and users locking the file '''/usr/local/sbin/smbd'''.
 
  '''fstat /usr/local/sbin/smbd''' - only return info on processes and users locking the file '''/usr/local/sbin/smbd'''.
  
see also: [[iostat]], [[netstat]]
+
=== User ===
 +
 
 +
To determine the file status for a particular user the '''-u ''username''''' option is used:
 +
 
 +
%fstat -u joeuser
 +
USER    CMD          PID  FD MOUNT      INUM MODE        SZ|DV R/W
 +
joeuser fstat      96741 root /            2 drwxr-xr-x    512  r
 +
joeuser fstat      96741  wd /usr    2378753 drwxr-xr-x    512  r
 +
joeuser fstat      96741 text /usr    2308260 -r-xr-sr-x  14340  r
 +
joeuser fstat      96741    0 /dev        93 crw--w----  ttyp0 rw
 +
joeuser fstat      96741    1 /dev        93 crw--w----  ttyp0 rw
 +
joeuser fstat      96741    2 /dev        93 crw--w----  ttyp0 rw
 +
joeuser fstat      96741    3 /dev        26 crw-r-----    mem  r
 +
joeuser fstat      96741    4 /dev        27 crw-r-----    kmem  r
 +
joeuser fstat      96741    5 /        25179 -rw-r--r--  40960  r
 +
joeuser csh          760 root /            2 drwxr-xr-x    512  r
 +
joeuser csh          760  wd /usr    2378753 drwxr-xr-x    512  r
 +
joeuser csh          760 text /        16628 -r-xr-xr-x  293060  r
 +
joeuser csh          760  15 /dev        93 crw--w----  ttyp0 rw
 +
joeuser csh          760  16 /dev        93 crw--w----  ttyp0 rw
 +
joeuser csh          760  17 /dev        93 crw--w----  ttyp0 rw
 +
joeuser csh          760  18 /dev        93 crw--w----  ttyp0 rw
 +
joeuser csh          760  19 /dev        93 crw--w----  ttyp0 rw
 +
joeuser sshd        759 root /            2 drwxr-xr-x    512  r
 +
joeuser sshd        759  wd /            2 drwxr-xr-x    512  r
 +
joeuser sshd        759 text /usr    1318917 -r-xr-xr-x  180452  r
 +
joeuser sshd        759    0 /dev          6 crw-rw-rw-    null rw
 +
joeuser sshd        759    1 /dev          6 crw-rw-rw-    null rw
 +
joeuser sshd        759    2 /dev          6 crw-rw-rw-    null rw
 +
joeuser sshd        759    3* internet stream tcp c23cf1d0
 +
joeuser sshd        759    4* local stream c23b47a8 <-> c23b4c94
 +
joeuser sshd        759    5* pipe c2335660 <-> c2335718      0 rw
 +
joeuser sshd        759    6* pipe c2335718 <-> c2335660      0 rw
 +
joeuser sshd        759    7 /dev        92 crw-rw-rw-  ptyp0 rw
 +
joeuser sshd        759    8 /dev        92 crw-rw-rw-  ptyp0 rw
 +
joeuser sshd        759    9 /dev        92 crw-rw-rw-  ptyp0 rw
 +
 
 +
=== See also ===
 +
 
 +
See also: [[iostat]], [[netstat]]
  
 
[[Category:System Commands]]
 
[[Category:System Commands]]

Revision as of 07:45, 4 January 2008

fstat is a command similar to the lsof command Linux users are familiar with. Simply put, it returns a list of all open files and what user context they've been opened in. Handy arguments:

fstat -f /usr/local/etc - only return locked files from the filesystem containing /usr/local/etc/ (/usr, on most systems)
fstat -p qmail-send - only return files locked by the qmail-send process
fstat /usr/local/sbin/smbd - only return info on processes and users locking the file /usr/local/sbin/smbd.

User

To determine the file status for a particular user the -u username option is used:

%fstat -u joeuser
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
joeuser fstat      96741 root /             2 drwxr-xr-x     512  r
joeuser fstat      96741   wd /usr     2378753 drwxr-xr-x     512  r
joeuser fstat      96741 text /usr     2308260 -r-xr-sr-x   14340  r
joeuser fstat      96741    0 /dev         93 crw--w----   ttyp0 rw
joeuser fstat      96741    1 /dev         93 crw--w----   ttyp0 rw
joeuser fstat      96741    2 /dev         93 crw--w----   ttyp0 rw
joeuser fstat      96741    3 /dev         26 crw-r-----     mem  r
joeuser fstat      96741    4 /dev         27 crw-r-----    kmem  r
joeuser fstat      96741    5 /         25179 -rw-r--r--   40960  r
joeuser csh          760 root /             2 drwxr-xr-x     512  r
joeuser csh          760   wd /usr     2378753 drwxr-xr-x     512  r
joeuser csh          760 text /         16628 -r-xr-xr-x  293060  r
joeuser csh          760   15 /dev         93 crw--w----   ttyp0 rw
joeuser csh          760   16 /dev         93 crw--w----   ttyp0 rw
joeuser csh          760   17 /dev         93 crw--w----   ttyp0 rw
joeuser csh          760   18 /dev         93 crw--w----   ttyp0 rw
joeuser csh          760   19 /dev         93 crw--w----   ttyp0 rw
joeuser sshd         759 root /             2 drwxr-xr-x     512  r
joeuser sshd         759   wd /             2 drwxr-xr-x     512  r
joeuser sshd         759 text /usr     1318917 -r-xr-xr-x  180452  r
joeuser sshd         759    0 /dev          6 crw-rw-rw-    null rw
joeuser sshd         759    1 /dev          6 crw-rw-rw-    null rw
joeuser sshd         759    2 /dev          6 crw-rw-rw-    null rw
joeuser sshd         759    3* internet stream tcp c23cf1d0
joeuser sshd         759    4* local stream c23b47a8 <-> c23b4c94
joeuser sshd         759    5* pipe c2335660 <-> c2335718      0 rw
joeuser sshd         759    6* pipe c2335718 <-> c2335660      0 rw
joeuser sshd         759    7 /dev         92 crw-rw-rw-   ptyp0 rw
joeuser sshd         759    8 /dev         92 crw-rw-rw-   ptyp0 rw
joeuser sshd         759    9 /dev         92 crw-rw-rw-   ptyp0 rw

See also

See also: iostat, netstat

Personal tools