Nifty Solaris fuser trick


I was reading through Planet Sun, and came across Pete Shanahan’s fuser trick. This trick can be used to get the process name of each PID accessing a file system:

$ ps -o pid,ppid,rss,args -p "(fuser / 2>/dev/null)"

PID PPID RSS COMMAND
0 0 0 sched
1 0 776 /etc/init -
2 0 0 pageout
3 0 0 fsflush
49 1 1376 /usr/lib/sysevent/syseventd
56 1 1904 /usr/lib/picl/picld
127 1 1136 /usr/sbin/inetd -s
229 1 816 /bin/sh /usr/local/mysql/bin/safe_mysqld --user=mysql --bind-address=127.0.0.1
165 1 696 /usr/lib/utmpd
250 1 1280 /usr/lib/ssh/sshd
18312 250 3224 /usr/lib/ssh/sshd
255 1 1160 /usr/lib/saf/ttymon -g -h -p winnie console login: -T sun -d /dev/console -l c
204 1 1824 /usr/sbin/mdmonitord
251 1 4064 /usr/local/openldap/libexec/slapd -f /usr/local/openldap-common/etc/slapd.conf
2001 1 1736 /usr/sbin/syslogd -t

Thanks for the awesome trick Pete!

This article was posted by Matty on 2005-01-26 00:11:00 -0400 -0400