• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

SysAdmin series – Understanding the lsof output

Daniel Wren

  • 8 min read
SysAdmin series – Understanding the lsof output

Generating audio, please wait...

lsof command displays the list of open files. It could be the list of files opened by a process or it could be a list of files opened by a user or it could be a list of files opened by an IP or it could be a list of files opened by a port.

Let’s analyse the lsof command and its output. Only when you understand the output, you have a better idea of how it could be made useful.

[root@server ~]# lsof

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

init 1 root cwd DIR 253,0 4096 2 /

init 1 root rtd DIR 253,0 4096 2 /

init 1 root txt REG 253,0 150352 92012573 /sbin/init

init 1 root mem REG 253,0 66432 90974918 /lib64/libnss_files-2.12.so

init 1 root mem REG 253,0 1924768 90963979 /lib64/libc-2.12.so

init 1 root mem REG 253,0 90912 90963993 /lib64/libgcc_s-4.4.7-20120601.so.1

init 1 root mem REG 253,0 44472 90974925 /lib64/librt-2.12.so

The fields displayed are:

 COMMAND is the command which is responsible for the file

 PID - Process ID

 TID - Thread ID

 USER - Owner of the process

 FD - File Descriptor

 Type - Type of files

 DEVICE - Type of device with major, minor numbers

 SIZE/OFFSET - Size of the file

 NODE - inode number of the file

 NAME - name of the file

The File Descriptor can take the following values:
 cwd - current working directory

 rtd - root directory

 txt - program text (code and data)

 mem - memory-mapped file, usually for shared library

 1r - file descriptor 1 opened for reading.

 pd - parent directory

In FD column, numbers like 1u is actual file descriptor and followed by u,r,w which indicates itʼs mode as:

 u - File open with Read and Write permission

 r - File open with Read permission

 w - File open with Write permission

 W - File open with Write permission and with Write Lock on entire file

 mem - Memory mapped file, usually for share library

 mmap - Memory mapped device

TYPE displays type of files and itʼs identification.

DIR – Directory

REG – Regular file

CHR – Character special file.

FIFO – First In First Out

Let’s get into few usages of lsof.

List of open files of a user, root

[root@server ~]# lsof -u root

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

init 1 root cwd DIR 253,0 4096 2 /

init 1 root rtd DIR 253,0 4096 2 /

init 1 root txt REG 253,0 150352 92012573 /sbin/init

init 1 root mem REG 253,0 66432 90974918 /lib64/libnss_files-2.12.so

init 1 root mem REG 253,0 1924768 90963979 /lib64/libc-2.12.so

init 1 root mem REG 253,0 90912 90963993 /lib64/libgcc_s-4.4.7-20120601.so.1

init 1 root mem REG 253,0 44472 90974925 /lib64/librt-2.12.so

init 1 root mem REG 253,0 143280 90964003 /lib64/libpthread-2.12.so

init 1 root mem REG 253,0 265736 90964061 /lib64/libdbus-1.so.3.4.0

Exclusion is lsof is with ^ (carrot symbol)
eg: lsof -p ^5341 (will list open files 3ll processes excluding the one with 5341 PID)

lsof -u ^root (will list 3ll open files, except the ones opened by root)

List of Open Files – By Process Name Starting With

Promotional banner

[root@server ~]# lsof -c dovecot

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

dovecot 5328 root cwd DIR 253,0 4096 2228598 /var/run/dovecot

dovecot 5328 root rtd DIR 253,0 4096 2 /

dovecot 5328 root txt REG 253,0 93740 56364377 /usr/sbin/dovecot

dovecot 5328 root mem REG 253,0 2279343 2098498 /var/db/nscd/hosts
dovecot 5328 root mem REG 253,0 143280 90964003 /lib64/libpthread-2.12.so

dovecot 5328 root mem REG 253,0 44472 90974925 /lib64/librt-2.12.so

dovecot 5328 root mem REG 253,0 20024 90974866 /lib64/libdl-2.12.so

dovecot 5328 root mem REG 253,0 18712 90964028 /lib64/libattr.so.1.1.0

dovecot 5328 root mem REG 253,0 1924768 90963979 /lib64/libc-2.12.so

Find Parent process ID of a process. Here in this case, 1 is the parent process of the PID 7597

[root@server ~]# lsof -p 7597 -R

COMMAND PID PPID USER FD TYPE DEVICE SIZE/OFF NODE NAME

httpd 7597 1 root cwd DIR 8,3 4096 2 /

httpd 7597 1 root rtd DIR 8,3 4096 2 /

httpd 7597 1 root txt REG 8,3 662696 4202194 /usr/sbin/httpd

httpd 7597 1 root DEL REG 0,4 0 /SYSV000015b3

httpd 7597 1 root mem REG 8,5 217032 4980742 /var/db/nscd/passwd

httpd 7597 1 root mem REG 8,5 217032 4980743 /var/db/nscd/group

httpd 7597 1 root DEL REG 0,4 3482411066 /dev/zero

httpd 7597 1 root DEL REG 0,4 3482411067 /dev/zero

httpd 7597 1 root DEL REG 0,4 3482411070 /dev/zero

httpd 7597 1 root mem REG 8,3 163400 4194605 /usr/lib64/ld-2.17.so

If you just want to list the open files based on process ID, just issue, lsof -p 7597

List of open files to a specific port

[root@serveur ~]# lsof -i :80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

nginx 15462 root 6u IPv4 3437785568 0t0 TCP *:http (LISTEN)

nginx 15463 nginx 6u IPv4 3437785568 0t0 TCP *:http (LISTEN)

nginx 15466 nginx 6u IPv4 3437785568 0t0 TCP *:http (LISTEN)

nginx 15469 nginx 4u IPv4 3483569271 0t0 TCP serveur.ex2-p32.com:http->83.137.2.249:50698 (ESTABLISHED)

nginx 15469 nginx 6u IPv4 3437785568 0t0 TCP *:http (LISTEN)
nginx 15470 nginx 4u IPv4 3483569216 0t0 TCP serveur.ex2-p32.com:http->172.69.226.114:60336 (ESTABLISHED)

Find open connections to a specific host and that too of a specific port of a specific host

[root@serveur ~]# lsof [email protected]

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

french 5909 maqfr 8u IPv4 3483726686 0t0 UDP serveur.ex2-p32.com:64544->cdns.ovh.net:domain 

french 5911 maqfr 10u IPv4 3483774248 0t0 UDP serveur.ex2-p32.com:39678->cdns.ovh.net:domain 
french 5913 maqfr 14u IPv4 3483732945 0t0 UDP serveur.ex2-p32.com:60288->cdns.ovh.net:domain 

french 5914 maqfr 21u IPv4 3483774113 0t0 UDP serveur.ex2-p32.com:13654->cdns.ovh.net:domain 

french 5916 maqfr 20u IPv4 3483774259 0t0 UDP serveur.ex2-p32.com:50760->cdns.ovh.net:domain 
french 5917 maqfr 22u IPv4 3483771117 0t0 UDP serveur.ex2-p32.com:48329->cdns.ovh.net:domain 

exim 6016 mailnull 8u IPv4 3483768849 0t0 TCP serveur.ex2-p32.com:38514->dev.serveurex2.info:smtp (ESTABLISHED)

imap 6154 cyberren 7u IPv4 3483768128 0t0 TCP serveur.ex2-p32.com:imap->94-224-82-148.access.telenet.be:60681 (ESTABLISHED)

Or even

[root@serveur ~]# lsof [email protected]:80

will display the below output:

nginx 15488 nginx 20u IPv4 3483851490 0t0 TCP serveur.ex2-p32.com:http->79.103.55.23.dsl.dyn.forthnet.gr:61805 (ESTABLISHED)

nginx 15488 nginx 22u IPv4 3483850530 0t0 TCP serveur.ex2-p32.com:http->162.158.7.84:31578 (ESTABLISHED)
nginx 15488 nginx 24u IPv4 3483843477 0t0 TCP serveur.ex2-p32.com:http->102.132.37.126:53389 (ESTABLISHED)

nginx 15488 nginx 30u IPv4 3483858141 0t0 TCP serveur.ex2-p32.com:http->adsl196-188-162-217-196.adsl196-14.iam.net.ma:51282 (ESTABLISHED)

Search for all open instances of directory

[root@server ~]# lsof +D /home/ceeaco/mail/

Kill all processes run by the user sages

[root@server ~]# kill -9 `lsof -t -u sages`

List of Files in Repeat Mode

[root@serveur home]# lsof -i -a -c ssh -r2

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

sshd 9023 root 3u IPv4 3483661449 0t0 TCP serveur.ex2-p32.com:d2k-datamover2->launchpad2.majesticsupport.com:42901 (ESTABLISHED)

sshd 21514 root 3u IPv4 3483456549 0t0 TCP serveur.ex2-p32.com:d2k-datamover2->launchpad2.majesticsupport.com:42894 (ESTABLISHED)

sshd 30037 root 3u IPv4 2835783768 0t0 TCP *:d2k-datamover2 (LISTEN)

sshd 30037 root 4u IPv6 2835783770 0t0 TCP *:d2k-datamover2 (LISTEN)

=======

Uninterrupted service delivery can only be assured through constant monitoring of services and servers. Don’t worry. We are here to help you.

  • Linux
  • server
  • Sever management
Promotional banner
Promotional banner
SysAdmin series – Understanding the lsof output

Everything about SWAP in Linux – why do we need swapping ?

Everything about SWAP in Linux – why do we need swapping ?
  • Linux
  • server
  • Sever management
logo

How to install node.js on your shared server?

How to install node.js on your shared server?
  • server
  • Sever management
logo

How to secure SSH access to your server using TORʼs hidden service ?

How to secure SSH access to your server using TORʼs hidden service ?
  • Linux
logo

How to stand out from the crowd by providing 24*7 customer support?

How to stand out from the crowd by providing 24*7 customer support?
  • Customer Care
logo

Posts by Daniel Wren

An innovative and dedicated IT professional who is very curious to solve and find solutions to seemingly difficult tasks.