[Linux] linux Command learning-netstat, linux-netstat
Many linux services are related to the network. When the service cannot be called, the startup port is occupied, or the firewall is blocked, you need to query network problems, the netstat command only uses one or two parameters.
Common options:
- -A (all) shows all options. LISTEN is not displayed by default.
- -T (tcp) only displays tcp-related options
- -U (udp) only displays udp-related options
- -N: the alias is denied. All digits can be converted to digits.
- -L only lists the service statuses that have been listened to by Listen.
- -C runs the netstat command at a fixed interval.
- -S: displays network statistics
- -P: it is useful to list the pid of a program.
- -R: Display route table
- -E: display other extended information
Use Case:
1. view all tcp ports
$ netstat -at
2. view all tcp ports on the listener
$ netstat -lt
3. Find the port of the ssh service.
$ netstat -alpt|grep ssh
4. Display nic and Nic Information
$ netstat -ie
5. View tcp connections in all route tables
# netstat -ant
6. Only view the connection and pid information of the listener (commonly used)
# Netstat-tnlp
View tcp connections once per second
# netstat -ct
8. check whether a service is running.
netstat -alpnt|grep ssh
You can also add them frequently.
This article from the "orangleliu notebook" blog, reprint please be sure to keep this source http://blog.csdn.net/orangleliu/article/details/41044879
Author: orangleliu