In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to understand the lsof command on the Linux operating system, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The full name of lsof is list opened files, which lists the files that have been opened in the system. As we all know, in a linux environment, everything is a file, a device is a file, a directory is a file, and even a sockets is a file. Therefore, the good use of lsof commands is very helpful to day-to-day linux management. Only ordinary root users can execute lsof commands. Ordinary users can see the / usr/sbin/lsof command, but ordinary users' execution will display "permission denied".
Let me summarize the usage of the lsof instruction:
Lsof abc.txt shows the process of opening the file abc.txt
Lsof-I: 22 know what program port 22 is running now
Lsof-c abc displays the files now opened by the abc process
Lsof-g gid shows the process that belongs to the gid
Lsof + d / usr/local/ displays the files opened by the process in the directory
Lsof + D / usr/local/ is the same as above, but will search the directory under the directory for a long time.
Lsof-d 4 shows processes using fd 4
Lsof-I is used to display eligible processes.
Syntax: lsof-I [46] [protocol] [@ hostname | hostaddr] [: service | port]
46-- > IPv4 or IPv6
Protocol-- > TCP or UDP
Hostname-- > Internet hostname
Hostaddr-- > IPv4 location
Service name in service-- > / etc/service (can be more than one)
Port-- > port number (can be more than one)
Example: TCP:25-TCP and port 25
@ 1.2.3.4-Internet IPv4 host address 1.2.3.4
Tcp@o.ks.edu.tw:ftp-TCP protocol host.ks.edu.tw service name:ftp
Lsof-n does not convert IP to hostname. By default, the-n parameter is not added.
Example: lsof-I tcp@o.ks.edu.tw:ftp-n
Lsof-p 12 to see which files are opened by the process with process number 12
Lsof + |-r [t] controls the repeated execution of lsof. Default is 15s refresh.
-rrecoery lsof will be executed forever until the interrupt signal is received
+ rforce lsof will be executed until no files are displayed
Example: constantly check the current ftp connection: lsof-I tcp@o.ks.edu.tw:ftp-r
Lsof-s lists the size of the open file, leaving it blank if there is no size
Lsof-u username lists open files in UID
Only ordinary root users can execute lsof commands. Ordinary users can see the / usr/sbin/lsof command, but ordinary users' execution will display "permission denied".
Let me summarize the usage of the lsof instruction:
Lsof abc.txt shows the process of opening the file abc.txt
Lsof-I: 22 know what program port 22 is running now
Lsof-c abc displays the files now opened by the abc process
Lsof-g gid shows the process that belongs to the gid
Lsof + d / usr/local/ displays the files opened by the process in the directory
Lsof + D / usr/local/ is the same as above, but will search the directory under the directory for a long time.
Lsof-d 4 shows processes using fd 4
Lsof-I is used to display eligible processes.
Syntax: lsof-I [46] [protocol] [@ hostname | hostaddr] [: service | port]
46-- > IPv4 or IPv6
Protocol-- > TCP or UDP
Hostname-- > Internet hostname
Hostaddr-- > IPv4 location
Service name in service-- > / etc/service (can be more than one)
Port-- > port number (can be more than one)
Example: TCP:25-TCP and port 25
@ 1.2.3.4-Internet IPv4 host address 1.2.3.4
Tcp@o.ks.edu.tw:ftp-TCP protocol host.ks.edu.tw service name:ftp
Lsof-n does not convert IP to hostname. By default, the-n parameter is not added.
Example: lsof-I tcp@o.ks.edu.tw:ftp-n
Lsof-p 12 to see which files are opened by the process with process number 12
Lsof + |-r [t] controls the repeated execution of lsof. Default is 15s refresh.
-rrecoery lsof will be executed forever until the interrupt signal is received
+ rforce lsof will be executed until no files are displayed
Example: constantly check the current ftp connection: lsof-I tcp@o.ks.edu.tw:ftp-r
Lsof-s lists the size of the open file, leaving it blank if there is no size
Lsof-u username lists open files in UID
Lsof-I tcp:22 to check the progress of port 22
After reading the above, have you mastered how to understand the lsof command on the Linux operating system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.