Linux command-view port occupancy

Common commands

  • lsof -i:端口号
  • netstat -tunlp|grep 端口号

lsof -i

  • Used to show qualified progress

  • lsof(list open files)Is a tool to list the open files of the current system
    Insert picture description here

  • lsofThe meaning of each column of output is:

    • COMMAND: The name of the process or the way the process was started
    • PID: Process id
    • USER: Process owner
    • FD: File descriptor
    • TYPE:agreement type
    • DEVICE:The port number
    • SIZE/OFF: Offset
    • NODE: Protocol name
    • NAME: Node name

netstat -tunlp

  • Used to display tcp, udpport and process related information
    Insert picture description here

  • Command in the t, u, n, l, phave different meanings:

    • -t Only display related to tcp
    • -u Only display related to udp
    • -n Unlimited aliases, can display all the numbers converted to numbers
    • -l Only display those in the Listen state
    • -p Display the name of the program that established these connections

netstat -tunlp|grep port number

  • Used to view the process of the specified port number
    • For example, check the situation of port 22:netstat -tunlp|grep 22

Guess you like

Origin blog.csdn.net/weixin_43438052/article/details/114280404