Search code examples
unixcommand-linesolarispidfuser

Files being used by a unix process


The fuser command lets me know which processes are using a file or directory.

I'm looking for command that does the opposite: lets me know which files are being used by a process.


Update

Forgot to mention that it's for a Solaris system.


Solution

  • While I wouldn't begrudge anyone learning Dtrace or gaining experience installing software, in Solaris there is a command to see the files a process has open: /usr/bin/pfiles

    % tail -f /etc/motd &
    [1] 6033
    
    % pfiles 6033
    6033:   tail -f /etc/motd
    
          Current rlimit: 256 file descriptors
           0: S_IFREG mode:0644 dev:182,65538 ino:163065 uid:0 gid:3 size:54
              O_RDONLY|O_LARGEFILE
              /etc/motd
           1: S_IFCHR mode:0620 dev:299,0 ino:718837882 uid:101 gid:7 rdev:24,3
              O_RDWR|O_NOCTTY|O_LARGEFILE
              /dev/pts/3
           2: S_IFCHR mode:0620 dev:299,0 ino:718837882 uid:101 gid:7 rdev:24,3
              O_RDWR|O_NOCTTY|O_LARGEFILE
              /dev/pts/3