pavement

Fstat

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
m (Process option)
m (Slight typos)
Line 6: Line 6:
 
=== Process ===
 
=== Process ===
  
To determine the file status for a particular process the option '''-p ''pid-number''''' is used.  For example assuming [[sendmail]]is assigned a [[pid]] of 677 (determined from the [[ps]] commend):
+
To determine the file status for a particular process the option '''-p ''pid-number''''' is used.  For example assuming [[sendmail]] is assigned a [[pid]] of 677 (determined from the [[ps]] commend):
  
 
  %fstat -p 677
 
  %fstat -p 677

Revision as of 08:59, 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 /usr/local/sbin/smbd - only return info on processes and users locking the file /usr/local/sbin/smbd.

Process

To determine the file status for a particular process the option -p pid-number is used. For example assuming sendmail is assigned a pid of 677 (determined from the ps commend):

%fstat -p 677
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
smmsp    sendmail     677 root /             2 drwxr-xr-x     512   r
smmsp    sendmail     677   wd /var    1036294 drwxrwx---     512   r
smmsp    sendmail     677 text /usr    3014716 -r-xr-sr-x  583680   r
smmsp    sendmail     677    0 /dev          6 crw-rw-rw-    null   r
smmsp    sendmail     677    1 /dev          6 crw-rw-rw-    null   w
smmsp    sendmail     677    2 /dev          6 crw-rw-rw-    null   w
smmsp    sendmail     677    3* local dgram c23b49d8 <-> c23b4dac
smmsp    sendmail     677    4 /var     1036296 -rw-------      49  w

User

To determine the file status for a particular user the option -u username is used. For example when used against user account 'joeuser':

%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