FreeBSD Install lsof To Displays Information About Files Open to Unix processes

Posted on in Categories , , , last updated July 16, 2008

Q. How do I install the free, open-source, Unix administrative tool called lsof (for LiSt Open Files) under FreeBSD operating system to displays information about files open to Unix processes?

A. lsof lists information about files opened by processes
for the varios UNIX dialects. An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.

FreeBSD install lsof package

Type the following command to update current ports collection and install lsof from ports:
# portsnap fetch update
# cd /usr/ports/sysutils/lsof
# make install clean

Now you can use lsof commad, enter:
# lsof
# lsof -i -U
# lsof -i 4 -a -p 2053
# lsof -i 6
$ man lsof

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.