{"id":68630,"date":"2023-09-08T18:01:22","date_gmt":"2023-09-08T10:01:22","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=68630"},"modified":"2023-09-12T17:12:52","modified_gmt":"2023-09-12T09:12:52","slug":"linux-command-lsof","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/","title":{"rendered":"How to Use the &#8216;lsof&#8217; Command in Linux"},"content":{"rendered":"<p>The <code>lsof<\/code> command, standing for \u201cList Open Files,\u201d is a powerful tool in the Linux operating system that provides essential information about files that are opened by various processes. This versatile command allows system admins to monitor and manage files, sockets, and network connections, offering a comprehensive view of how resources are being utilized within the system.<\/p>\n<p>Similar to commands like <code>netstat<\/code> and <code>fuser<\/code>, the <code>lsof<\/code> command is used to identify the files that are being accessed by different processes, making it an indispensable tool for troubleshooting and system maintenance. Whether you\u2019re a network administrator seeking to resolve conflicts or a developer looking to optimize resource allocation, the <code>lsof<\/code> command, often used alongside commands like <code><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-grep\/\">grep<\/a><\/code>, can be a handy addition to your toolkit.<\/p>\n<h2>How to Install the <code>lsof<\/code> Command<\/h2>\n<p>In many Linux distributions, the <code>lsof<\/code> command comes pre-installed. However, if it\u2019s not available on your system, you can easily install it using the package manager specific to your distribution.<\/p>\n<p><strong>Debian-based Systems (e.g., Ubuntu) <\/strong><\/p>\n<p>Install:<\/p>\n<pre>sudo apt-get update\r\nsudo apt-get install lsof<\/pre>\n<p>Uninstall:<\/p>\n<pre>sudo apt-get remove lsof<\/pre>\n<p><strong>Red Hat-based Systems (e.g., CentOS, RHEL)<\/strong><\/p>\n<p>Install using <a href=\"https:\/\/www.cyberciti.biz\/faq\/rhel-centos-fedora-linux-yum-command-howto\/\" rel=\"nofollow\">Yum<\/a> (older versions):<\/p>\n<pre>sudo yum install lsof<\/pre>\n<p>Install using <a href=\"https:\/\/docs.fedoraproject.org\/en-US\/quick-docs\/dnf\/\">DNF<\/a> (newer versions):<\/p>\n<pre>sudo dnf install lsof<\/pre>\n<p>Uninstall using Yum:<\/p>\n<pre>sudo yum remove lsof<\/pre>\n<p>Uninstall using DNF:<\/p>\n<pre>sudo dnf remove lsof<\/pre>\n<p><strong>Fedora<\/strong><\/p>\n<p>Install (older versions using Yum):<\/p>\n<pre>sudo yum install lsof<\/pre>\n<p>Install (newer versions using DNF):<\/p>\n<pre>sudo dnf install lsof<\/pre>\n<p>Uninstall using Yum:<\/p>\n<pre>sudo yum remove lsof<\/pre>\n<p>Uninstall using DNF:<\/p>\n<pre>sudo dnf remove lsof<\/pre>\n<h2>How to Use <code>lsof<\/code><\/h2>\n<h3>1. List All Open Files<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all open files on the system.<\/p>\n<p><strong>Example:<\/strong> <code>lsof<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE\/OFF   NODE NAME\r\nsystemd    1 root  cwd    DIR  253,1     4096      2 \/\r\nbash    1234 user  txt    REG  253,1   111350 123456 \/bin\/bash\r\n<\/pre>\n<p>This output shows all the open files, including the command name, process ID (<code>PID<\/code>), user, file descriptor (<code>FD<\/code>), type, device, size, and the file\u2019s path.<\/p>\n<hr>\n<h3>2. List Files Opened by a Specific User<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof -u &lt;username&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all files opened by a specific user.<\/p>\n<p><strong>Example:<\/strong> <code>lsof -u john<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE\/OFF   NODE NAME\r\nbash    5678 john  cwd    DIR  253,1     4096  78901 \/home\/john\r\n<\/pre>\n<p>This output lists all the files opened by the user <code>john<\/code>, including the command name, PID, user, and other details.<\/p>\n<hr>\n<h3>3. List Files Used by a Specific Process<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof -p &lt;PID&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all files used by a specific process ID.<\/p>\n<p><strong>Example:<\/strong> <code>lsof -p 1234<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE\/OFF   NODE NAME\r\nbash    1234 user  cwd    DIR  253,1     4096  78901 \/home\/user\r\n<\/pre>\n<p>This output lists all the files used by the process with PID <code>1234<\/code>, including the command name, PID, user, and other details.<\/p>\n<hr>\n<h3>4. List Files on a Specific Port<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof -i :&lt;port&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all files associated with a specific network port.<\/p>\n<p><strong>Example:<\/strong> <code>lsof -i :80<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID  USER   FD   TYPE DEVICE SIZE\/OFF NODE NAME\r\napache  1234 www-data  4u  IPv4  12345      0t0  TCP *:http (LISTEN)\r\n<\/pre>\n<p>This output lists all the files associated with port 80, typically used for HTTP. It includes the command name, PID, user, and other details related to the network connection.<\/p>\n<hr>\n<h3>5. List Files Opened by a Specific Command<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof -c &lt;command_name&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all files opened by a specific command.<\/p>\n<p><strong>Example:<\/strong> <code>lsof -c sshd<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE\/OFF   NODE NAME\r\nsshd    1234 root  cwd    DIR  253,1     4096      2 \/\r\n<\/pre>\n<p>This output lists all the files opened by the <code>sshd<\/code> command, including the command name, PID, user, and other details.<\/p>\n<hr>\n<h3>6. List Files Opened on a Specific File System<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof +D &lt;directory&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all files opened within a specific directory or file system.<\/p>\n<p><strong>Example:<\/strong> <code>lsof +D \/var<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE\/OFF   NODE NAME\r\nsyslog  567 root    5w   REG  253,2     4096  12345 \/var\/log\/syslog\r\n<\/pre>\n<p>This output lists all the files opened within the <code>\/var<\/code> directory, including the command name, PID, user, and other details.<\/p>\n<hr>\n<h3>7. List Network Files of a Specific Protocol<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof -i &lt;protocol&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all network files using a specific protocol (e.g., TCP or UDP).<\/p>\n<p><strong>Example:<\/strong> <code>lsof -i TCP<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID  USER   FD   TYPE DEVICE SIZE\/OFF NODE NAME\r\nsshd    1234 root    3u  IPv4  56789      0t0  TCP *:ssh (LISTEN)\r\n<\/pre>\n<p>This output lists all the TCP network connections, including the command name, PID, user, and other details related to the network connection.<\/p>\n<hr>\n<h3>8. List Files Excluding Those Opened by a Specific User<\/h3>\n<p><strong>Syntax:<\/strong> <code>lsof -u ^&lt;username&gt;<\/code><\/p>\n<p><strong>Explanation<\/strong>: Lists all files excluding those opened by a specific user.<\/p>\n<p><strong>Example:<\/strong> <code>lsof -u ^john<\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre>\r\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE\/OFF   NODE NAME\r\nsystemd    1 root  cwd    DIR  253,1     4096      2 \/\r\n<\/pre>\n<p>This output lists all the files excluding those opened by the user <code>john<\/code>, including the command name, PID, user, and other details.<\/p>\n<hr>\n<h3 style=\"padding-bottom:10px\">More Linux commands:<\/h3>\n<table>\n<tbody>\n<tr>\n<td width=\"150\">Directory Operations<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/\"><code>rmdir<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-cd\/\"><code>cd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-pwd\/\"><code>pwd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-exa\/\"><code>exa<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ls\/\"><code>ls<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">File Operations<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-cat\/\"><code>cat<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-cp\/\"><code>cp<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-dd\/\"><code>dd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-less\/\"><code>less<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-touch\/\"><code>touch<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ln\/\"><code>ln<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-rename\/\"><code>rename<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-more\/\"><code>more<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-head\/\"><code>head<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">File System Operations<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-chown\/\"><code>chown<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-mkfs\/\"><code>mkfs<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-locate\/\"><code>locate<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">Networking<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ping\/\"><code>ping<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-curl\/\"><code>curl<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-wget\/\"><code>wget<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-iptables\/\"><code>iptables<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-mtr\/\"><code>mtr<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">Search and Text Processing<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-find\/\"><code>find<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-grep\/\"><code>grep<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-sed\/\"><code>sed<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-whatis\/\"><code>whatis<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ripgrep\/\"><code>ripgrep<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-fd\/\"><code>fd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-tldr\/\"><code>tldr<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">System Information and Management<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-env\/\"><code>env<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-history\/\"><code>history<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-top\/\"><code>top<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-who\/\"><code>who<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-htop\/\"><code>htop<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-glances\/\"><code>glances<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/\"><code>lsof<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">User and Session Management<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-screen\/\"><code>screen<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-su\/\"><code>su<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-sudo\/\"><code>sudo<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-open\/\"><code>open<\/code><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>","protected":false},"excerpt":{"rendered":"<p>Learn how to monitor and manage open files in Linux with the lsof command<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3397],"tags":[888,3316],"topic":[],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use the &#039;lsof&#039; Command in Linux - Hongkiat<\/title>\n<meta name=\"description\" content=\"Learn how to monitor and manage open files in Linux with the lsof command\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use the &#039;lsof&#039; Command in Linux\" \/>\n<meta property=\"og:description\" content=\"Learn how to monitor and manage open files in Linux with the lsof command\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-08T10:01:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-12T09:12:52+00:00\" \/>\n<meta name=\"author\" content=\"Hongkiat.com\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hongkiat.com\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/\"},\"author\":{\"name\":\"Hongkiat.com\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/7cc686597d92f9086729e4bcc1577ba3\"},\"headline\":\"How to Use the &#8216;lsof&#8217; Command in Linux\",\"datePublished\":\"2023-09-08T10:01:22+00:00\",\"dateModified\":\"2023-09-12T09:12:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/\"},\"wordCount\":548,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"keywords\":[\"Linux\",\"Linux Commands\"],\"articleSection\":[\"Desktop\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/\",\"name\":\"How to Use the 'lsof' Command in Linux - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"datePublished\":\"2023-09-08T10:01:22+00:00\",\"dateModified\":\"2023-09-12T09:12:52+00:00\",\"description\":\"Learn how to monitor and manage open files in Linux with the lsof command\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-lsof\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use the &#8216;lsof&#8217; Command in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/7cc686597d92f9086729e4bcc1577ba3\",\"name\":\"Hongkiat.com\",\"description\":\"This post is published by an HKDC (hongkiat.com) staff. (I.e., intern, staff writer, or editor).\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Use the 'lsof' Command in Linux - Hongkiat","description":"Learn how to monitor and manage open files in Linux with the lsof command","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/","og_locale":"en_US","og_type":"article","og_title":"How to Use the 'lsof' Command in Linux","og_description":"Learn how to monitor and manage open files in Linux with the lsof command","og_url":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2023-09-08T10:01:22+00:00","article_modified_time":"2023-09-12T09:12:52+00:00","author":"Hongkiat.com","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Hongkiat.com","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/"},"author":{"name":"Hongkiat.com","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/7cc686597d92f9086729e4bcc1577ba3"},"headline":"How to Use the &#8216;lsof&#8217; Command in Linux","datePublished":"2023-09-08T10:01:22+00:00","dateModified":"2023-09-12T09:12:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/"},"wordCount":548,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"keywords":["Linux","Linux Commands"],"articleSection":["Desktop"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/","url":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/","name":"How to Use the 'lsof' Command in Linux - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"datePublished":"2023-09-08T10:01:22+00:00","dateModified":"2023-09-12T09:12:52+00:00","description":"Learn how to monitor and manage open files in Linux with the lsof command","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Use the &#8216;lsof&#8217; Command in Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/7cc686597d92f9086729e4bcc1577ba3","name":"Hongkiat.com","description":"This post is published by an HKDC (hongkiat.com) staff. (I.e., intern, staff writer, or editor).","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/com\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-hQW","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/68630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=68630"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/68630\/revisions"}],"predecessor-version":[{"id":69236,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/68630\/revisions\/69236"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=68630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=68630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=68630"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=68630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}