Check the connection of the maximum number of IP Show Sample Output
netstat doesn't always function similarly across the board. Also the use of three commands in the original (netstat followed by grep followed by grep) is a waste of pipes
This is very handy for troubleshooting apps connection to internet. Shows an app's outgoing ip/port before and after connection established. Run this command and init the app you're investigating. I used that when trying to understand what is the destination's ip/port needed to open in firewall, for a specific VPN app. Similar for windows cmd: netstat -nafo | find /v "LISTENING" | find /v "0.0.0.0" | find /v "127.0.0.1"
When bootstrapping or repairing a node this is a simple way to keep tabs on what a node is actively doing. Show Sample Output
From 'man netstat' "netstat -i | -I interface [-abdnt] [-f address_family] [-M core] [-N system] Show the state of all network interfaces or a single interface which have been auto-configured (interfaces statically configured into a system, but not located at boot time are not shown). An asterisk (``*'') after an interface name indicates that the interface is ``down''. If -a is also present, multicast addresses currently in use are shown for each Ethernet interface and for each IP interface address. Multicast addresses are shown on separate lines following the interface address with which they are associated. If -b is also present, show the number of bytes in and out. If -d is also present, show the number of dropped packets. If -t is also present, show the contents of watchdog timers."
Can be used to discover what programms create internet traffic. Skip the part after awk to get more details. Has anyone an idea why the uniq doesn't work propperly here (see sample output)? Show Sample Output
Tested on CentOS, Ubuntu, and MacOS.
This command allows you to find the effective uid and gid of the Apache process regardless of process name (which can be apache2 or httpd depending on distro).
find all computer connected to my host through TCP connection Show Sample Output
Monitoring TCP connections number showing each state. It uses ss instead of netstat because it's much faster with high trafic. You can fgrep specific ports by piping right before awk: watch "ss -nat | fgrep :80 | awk '"'{print $1}'"' | sort | uniq -c" Show Sample Output
Open Port Check
Output contains also garbage (text parts from netstat's output) but it's good enough for quick check who's overloading your server.
Useful to check DDoS attacks on servers. Show Sample Output
Sometimes I need a quick visual way to determine if there is a particular server who is opening too many connections to the database machine.
Shows you all listening tcp/udp ports, and what program has them open(depending on rights)
shell loop to scan netstat output avoiding loolback aliases (local/remote swap for local connections) Show Sample Output
This obtains a list of open connections that a user is connected to if he/she is using a SSH tunnel
This counts all established sessions on port 80. You can change :80 to any port number you want to check. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: