Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In many cases "lsof" is not installed on the machines that with I have to work, but the "function" of lsof would be needed very much (ex. on AIX). :\

Are there any "lsof" like applications in the non-windows world?

UPDATE: for ex.: I need to know that what processes use the "/home/username" directory?

share|improve this question
1  
Could you be more specific, please? What systems apart from AIX (which is definitely supported by lsof) do you have in mind? Or is there only one specific type of use of lsof you have in mind? Generally: why not lsof? –  rozcietrzewiacz Aug 12 '11 at 6:25
    
I'm using Linux 2.6.18-92.el5 GNU, and I don't have lsof, nor do I have the capability to use lsof :( –  SSH This Jan 11 '13 at 17:52

3 Answers 3

up vote 6 down vote accepted

I know of fuser, see if is available on your system.

share|improve this answer
    
what do i have to give fuser as parameter to list all open files on a system? :O ty! –  LanceBaynes Aug 12 '11 at 8:08
    
The command sudo fuser -vm / 2>&1 | awk '$3 ~ /f|F/' | less can show all processes having open files on the filesystem mounted on /. See man page for specific help. –  enzotib Aug 12 '11 at 8:18
    
TY! it gives output like this: pastebin.com/raw.php?i=2z19g6Rk - i googled for it, but i can't find any way to output ex.: "gnome-screensaver", not "gnome-screensav" - so how can i output it with wide command names? :O –  LanceBaynes Aug 12 '11 at 8:29
    
it gives the same output for: pastebin.com/raw.php?i=Fe3EJvUv –  LanceBaynes Aug 12 '11 at 8:33
    
Something like this: sudo fuser -vm / 2>&1 | awk '$3 ~ /f|F/' | while read user pid flags rest; do printf '%10s %10s %10s %s\n' $user $pid $flags "$(</proc/$pid/cmdline)"; done | less –  enzotib Aug 12 '11 at 8:33

The Unix Rosetta Stone is a good resource for this kind of questions. It mentions a few alternatives for lsof (see below). Do not however that lsof is the de facto standard application for what it does.

If all you want is to find the process ID(s) that have a particular file open, then you can use fuser on any POSIX-compliant system.

On operating systems with a /proc directory, you can query the files open by a process (the reverse from lsof's most common mode of operation) through information in /proc. Some operating systems have commands for that:

share|improve this answer

If you happen to run Solaris, an alternative to lsof, which isn't installed by default and might choke on ZFS, is pfiles.

eg:

pfiles /proc/*

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.