Check if a port is open in Linux

1. Use the lsof command to check whether the port is open

lsof -i:6379 //If it is displayed, it means it has been opened. If it is not displayed, it means it is not open
[root@localhost ~]# lsof -i:6379

2. Use the netstat command to check whether the port is open.

netstat -aptn |grep -i 6379 //Check whether it is listening at 0.0.0.0:6379

netstat -lptn |grep -i 6379 //View TCP type ports

netstat -lpun |grep -i 6379 //View UDP type ports

3. Use telnet to test whether the remote host port is open.

telnet 127.0.0.1 6379 //telnet IP port number

Guess you like

Origin blog.csdn.net/keepandkeep/article/details/129812960