In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to get started with Linux's command artifact lsof, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Lsof is a Uber tool for system management / security. I use it most of the time to get information about network connections from the system, but that's only the first step in this powerful and little-known application. It's true to call this tool lsof because it means "list open files (lists openfiles)". One thing to keep in mind is that everything (including network sockets) in Unix is a file.
Interestingly, lsof is also one of the Linux/Unix commands with the most switches. It has so many switches, it has many options to support the use of the-and + prefixes.
As you can see, lsof has a really amazing number of options. You can use it to get information about devices on your system, and you can use it to know what a specified user is touching at a specified location, or even what files or network connections a process is using.
For me, lsof replaces all the work of netstat and ps. It can bring everything that those tools can bring, and it is much more than those tools. So, let's take a look at some of its basic capabilities:
Key option
It is important to understand some of the key things about how lsof works. Most importantly, when you pass it an option, the default behavior is to perform an OR operation on the result. Therefore, if you use-I to pull out a list of ports and-p to pull out a list of processes, you will get both results by default.
Here are some other things to keep in mind:
Default: no option, lsof lists all open files for active processes
Combination: you can group options together, such as-abc, but be careful which options require parameters
-a: the result is an "and" operation (instead of "or")
-l: displays the user ID instead of the user name in the output
-h: get help
-t: only get the process ID
-U: get the UNIX socket address
-F: format the output for other commands. Can be formatted in a variety of ways, such as-F pcfn (for process id, command name, file descriptor, file name, and terminating empty)
Get network information
As I said, I mainly use lsof to get information about how the system interacts with the network. Here are some topics about this information:
Use-I to display all connections
Some people like to use netstat to get a network connection, but I prefer to use lsof to do this. The results are presented in an intuitive way for me, and I can get more information with the same command simply by changing my grammar.
Use-I 6 to get only IPv6 traffic and display only TCP connections (in the same way, you can get UDP connections)
You can also display only TCP or UDP connection information by providing the corresponding protocol after-I.
Use-i:port to display network information related to the specified port
Alternatively, you can search through the port, which is great to find out what prevents another application from binding to the designated port.
Use @ host to display the specified connection to the specified host
This is useful when checking whether you have an open connection to a specified host on the network or on the Internet.
Display host-to-port-based connections using @ host:port
You can also combine the display information of the host and the port.
Find the listening port
Find the port that is waiting to connect.
You can also grep "LISTEN" to accomplish this task.
Find the connection that has been established
You can also display any connections that have been connected.
You can also do this by searching for "ESTABLISHED" on grep.
On how to get started with Linux command artifact lsof to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.