commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
Shows you all listening tcp/udp ports, and what program has them open(depending on rights)
see the TIME_WAIT and ESTABLISHED nums of the network
This is to fetch the Gateway Ip Address of a machine. Use the below format to put the value in a variable if you wish to find the gateway ip in a script
GATEWAY=$(netstat -nr | awk 'BEGIN {while ($3!="0.0.0.0") getline; print $2}')
Alternative of OJM snippet :
This one show the IP too, where ports bind. It's very important, because if there's only 127.0.0.1 instead of 0.0.0.0, connections from internet are rejected.
no need grep. its redundant when awk is present.
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.
Sample command to obtain a list of geographic localization for established connections, extracted from netstat. Need geoiplookup command ( part of geoip package under CentOS)
If you want prepend/append text just wrap in echo:
echo Connected: `netstat -an|grep -ci "tcp.*established"`
Works only on Linux.
Last option (n) turn name of service resolving (/etc/services) off.
worked on ubuntu 9.04 and cygwin with MS netstat
Show apps that use internet connection at the moment.
Can be used to discover what programms create internet traffic. Skip the part after awk to get more details, though it will not work showing only unique processes.
This version will work with other languages such as Spanish and Portuguese, if the word for "ESTABLISHED" still contain the fragment "STAB"(e.g. "ESTABELECIDO")
This corrects duplicate output from the previous command.
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)?
The command could show you all conecctions if you skip "grep ESTABLISHED"
The -p parameter tell the netstat to display the PID and name of the program to which each socket belongs or in digestible terms list the program using the net.Hope you know what pipe symbol means!
Presently we wish to only moniter tcp connections so we ask grep to scan for string tcp, now from the op of grep tcp we further scan for regular expression /[a-z]*.
Wonder what that means ?
If we look at the op of netstat -p we can see that the name of the application is preceded by a / ( try netstat -p ) so,now i assume application name contains only characters a to z (usually this is the case) hope now it makes some sense.Regular expression /[a-z]* means to scan a string that start with a / and contains zero or more characters from the range a-z !!. Foof .. is t
Just find out the daemon with $ netstat -atulpe. Then type in his name and he gets the SIGTERM.
Affiche des infos detaillees sur vos connexions reseaux.
Port en ?coute, protocole, paquets, adresses, ustilisateur, PID etc...