Difference between fuser and lsof command


 
Thread Tools Search this Thread
Operating Systems Solaris Difference between fuser and lsof command
# 1  
Old 03-13-2013
Difference between fuser and lsof command

Hi,
Can anyone explain me the difference between fsuer and lsof commands. As per my knowledge both the commands are used to find the processes used by the current file system or user. Apart from that what is the major difference between these commands
rogerben
# 2  
Old 03-13-2013
If you read the man pages for each of the two commands you will quickly see the differences. In general, use fuser for portability on POSIX systems because lsof is not available on all platforms.
# 3  
Old 03-13-2013
fuser is kind of akin to pgrep, in that it finds processes holding open the files you name. It even has options to kill the processes it finds.

lsof is more general. By default it lists everything. It can't kill things by itself but can produce terse output that can easily be piped into things which do ( ... | xargs kill )

[edit] Okay, fuser's probably more portable then. Neither of these applications come standard AFAIK however.
# 4  
Old 03-13-2013
Fuser has been standard with Solaris for as long as I can remember. There's been kernel support in Solaris for it, too. Look in '/usr/include/sys/utssys.h', IIRC.
This User Gave Thanks to achenle For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Lsof command

Hi, I am trying to find the files in a specific directory that are currently in open state. I need this information to archive the old files that are not active in the directory. I get the following output when I try the command $ lsof +d '/var/tmp/'|awk '{print $9}'|sort -u NAME... (1 Reply)
Discussion started by: ryzen7
1 Replies

2. UNIX for Advanced & Expert Users

Fuser alternative OR running fuser on a script

Hi, Not sure whether there is a fuser alternative or any better way to check for file in use or not. I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of... (0 Replies)
Discussion started by: newbie_01
0 Replies

3. AIX

Lsof command giving while loop

Hello, There is a process in AIX which is actually a oracle database user session but is running very slow When I use lsof it give below output lsof /proc/21955180 In while loop:256 In while loop:256 In while loop:256 In while loop:256 Value of I :183 np:1024 Please... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

4. Shell Programming and Scripting

How to fetch PIDs from the fuser command output

All, I have to have my script wait for another script when it is being executed. I used fuser -f scriptname to get the PID of the script but when passed the PID to wait command, the command does not accept it as a PID. Below is the example: my.script1: fuser_result=`fuser -f my.script2`... (4 Replies)
Discussion started by: bharath.gct
4 Replies

5. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

6. UNIX for Dummies Questions & Answers

fuser

Anyone ever use fuser, i tried this command fuser /database.bk but it only returns datbase.bk: I read some of the forums online, one of them said when he used fuser, it broke down the box, i really don't want that happen. I thought fuser is to see who is accessing that file, right? any... (8 Replies)
Discussion started by: adrianlearnpro
8 Replies

7. Shell Programming and Scripting

help needed in fuser command

Hi all, I want to know if fuser command can be used to check if a file is being written or not??? Thanks In Advance Anju (1 Reply)
Discussion started by: anju
1 Replies

8. UNIX for Advanced & Expert Users

STDOUT redirect to a FILE, when fuser command is used !!

Hi all, I have the following script: ------------------------------------------------- #SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY. MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/" MAIL_RECIPIENTS="vg517@dcx.com" Subject="File accessed in last... (6 Replies)
Discussion started by: varungupta
6 Replies

9. UNIX for Dummies Questions & Answers

require alternate command for lsof

Using lsof command i can find out which process-id is associated with the port. lsof -i :51000 . But as part of process i cant have lsof in the server. I am using sun solaris 8 and only kshell. Is there a way to find out which process is using the above port. as of now i am gettn port... (1 Reply)
Discussion started by: logic0
1 Replies

10. AIX

command lsof

hello Sorry but i don't understand very well the lsof command with the man. Can you explain to me what is the use of this command ? thank you (2 Replies)
Discussion started by: pascalbout
2 Replies
Login or Register to Ask a Question