Simple use of find and grep to recursively search a directory for files that contain a certain term.
Use the aliased command 'nsl'
Counts number of lines of code in *.h and *.cc files
add this alias in .bashrc to fast check the ip address of your modem router alias myip="curl -s http://myip.dk | grep '' | sed -e 's/]*>//g'" Show Sample Output
List top 20 IP from which TCP connection is in SYN_RECV state. Useful on web servers to detect a syn flood attack. Replace SYN_ with ESTA to find established connections Show Sample Output
This will tell you who has the most Apache connections by IP (replace IPHERE with the actual IP you wish to check). Or if you wish, remove | grep -c IPHERE for the full list.
This is a 'killall' command equivalent where it is not available. Prior to executing it, set the environment variable USERNAME to the username, whose processes you want to kill or replace the username with the $USERNAME on the command above. Side effect: If any processes from other users, are running with a parameter of $USERNAME, they will be killed as well (assuming you are running this as root user) [-9] in square brackets at the end of the command is optional and strongly suggested to be your last resort. I do not like to use it as the killed process leaves a lot of mess behind.
I used this to confirm an upgrade to an SSH daemon was successful Show Sample Output
Reads a username from Show Sample Output
If you're like me and want to keep all your music rated, and you use xmms2, you might like this command. I takes 10 random songs from your xmms2 library that don't have any rating, and adds them to your current playlist. You can then rate them in another xmms2 client that supports rating (I like kuechenstation). I'm pretty sure there's a better way to do the grep ... | sed ... part, probably with awk, but I don't know awk, so I'd welcome any suggestions. Show Sample Output
connects to all the screen instances running.
change 24073 to your pid Show Sample Output
Note that this assumes the application is an SVN checkout and so we have to throw away all the .svn files before making the substitution.
Good for summing the numbers embedded in text - a food journal entry for example with calories listed per food where you want the total calories. Use this to monitor and keep a total on anything that ouputs numbers. Show Sample Output
find all email addresses in a file, printing each match. Addresses do not have to be alone on a line etc. For example you can grab them from HTML-formatted emails or CSV files, etc. Use a combination of
...|sort|uniq$
to filter them.
Show Sample Output
Uses logger in a while loop to log memory statistics frequently into the local syslog server.
Find Word docs by filename in the current directory, convert each of them to plain text using antiword (taking care of spaces in filenames), then grep for a search term in the particular file. (Of course, it's better to save your data as plain text to make for easier grepping, but that's not always possible.) Requires antiword. Or you can modify it to use catdoc instead.
The command could show you all conecctions if you skip "grep ESTABLISHED" 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: