LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2004, 04:36 PM   #1
Menestrel
Member
 
Registered: Oct 2003
Location: Bucharest
Distribution: Debian Sarge, Slackware Current, Ubuntu
Posts: 183

Rep: Reputation: 30
how can I see what programs are locking a certain file ?


Sometimes I can't unmount a device, and I know there is a command that tells me what programs are using that device, could you tell me what command is that ?
 
Old 07-27-2004, 04:42 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
lsof


Cheers,
Tink
 
Old 07-27-2004, 04:43 PM   #3
devinWhalen
Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Red Hat, openBSD,Mandrake,freeBSD,SunOS
Posts: 168

Rep: Reputation: 30
fuser -m /mnt/cdrom
will list all PIDs using the filesystem mounted at /mnt/cdrom and
fuser -km /mnt/cdrom
will kill them (as root of course).

Later
 
Old 07-27-2004, 05:06 PM   #4
Menestrel
Member
 
Registered: Oct 2003
Location: Bucharest
Distribution: Debian Sarge, Slackware Current, Ubuntu
Posts: 183

Original Poster
Rep: Reputation: 30
just one more question :)

first, thanx for the quick reply, your info helped me a lot . When I issue a command like fuser -m /mnt/cdrom I get the response :
/mnt/cdrom: 3014c. Is 3014c the PID of the program that locks /mnt/cdrom. If so, how can I find out what program has the 3014c PID ?

:: edit ::

ok I've got it. man fuser did the trick and ps -A |grep PID_no. 10x again

Last edited by Menestrel; 07-27-2004 at 05:19 PM.
 
Old 07-27-2004, 05:25 PM   #5
devinWhalen
Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Red Hat, openBSD,Mandrake,freeBSD,SunOS
Posts: 168

Rep: Reputation: 30
man fuser:

fuser displays the PIDs of processes using the specified files or file
systems. In the default display mode, each file name is followed by a
letter denoting the type of access:

c current directory.

e executable being run.

f open file. f is omitted in default display mode.

r root directory.

m mmap'ed file or shared library.



To see what process it is:

ps -p pid...or in your case ps -p 3014.

Try man on fuser and ps. These are great commands that can help you a lot.

Later


EDIT

Sorry, I guess you responed whilst I was typing .

You can also add -u to the fuser to add the user name of the person running the process. That might help.

Last edited by devinWhalen; 07-27-2004 at 05:28 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file locking in ftp krunal Linux - Newbie 2 10-20-2005 05:43 AM
locking a file permanently sooraj_pathe Linux - General 1 03-11-2004 02:58 PM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 06:35 AM
Wine File Locking MurrayL Linux - Software 3 02-12-2004 04:27 AM
KDE Mail and a few other programs locking up. BlackDogg Linux - Newbie 12 09-18-2002 03:43 AM


All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration