lsof (LiSt Open Files) -- shows open files, network ports, and UNIX domain sockets on a Linux system.
See
AboutThesePages.
Did you ever try to unmount a filesystem and fail because umount tells you that it is still in use?
So you logout from all Your virtual consoles which might have their current directory somewhere along the path.
You close all your programs who might access the filesystem.
But still you cannot unmount.
lsof gives you a list with all the open files in the system.
$ lsof | grep <YourFilesystemsDirectory>
will give you the process IDs of all programs accessing files on the filesystem you want to get rid of. And then you can take action to close those files. (You might want to look
up 'man kill'
Contents
Notes
From:
TechRepublic
Presents your
LINUX E-NEWSLETTER for July 30, 2002
When you try to unmount a filesystem and are denied with a Filesystem
Busy message, use lsof to determine what process is holding onto the
mountpoint. For example:
# /usr/sbin/lsof /mnt/cdrom
In this case, /mnt/cdrom is the mountpoint in question, and lsof will
tell you if any processes have opened any files on that particular
filesystem.
You can also use lsof to find open network connections by giving it the
"-i" parameter. If you prefix this with an IP address, you can find all
open network connections to or from the specific IP address or domain
name. For instance:
# /usr/sbin/lsof -i@10PLEASENOSPAM.0.35.8
This command will display all open network connections to or from the IP
address 10.0.35.8.
List all open TCP connections by using:
# /usr/sbin/lsof -i tcp
Normal users can use lsof to list all open files, but there are
restrictions to the information they can obtain.
Resources
See
ResourceRecommendations. Feel free to add additional resources to these lists, but please follow the guidelines on
ResourceRecommendations including
ResourceRecommendations#Guidelines_for_Rating_Resources.
Recommended
- (stw) man lsof --
- (stw) man kill --
- (rhk) [[][]] --
<Currently, no significant content below this line.>
Recommended for Specific Needs
Recommended by Others
No Recommendation
Not Recommended
Contributors
- (stw) StefanWaidele - 09 Jul 2002
- <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>
stw
Page Ratings