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:
The arguments of "seq" indicate the starting value, step size, and the end value of the x-range. "awk" outputs (x, f(x)) pairs and pipes them to "graph", which is part of the "plotutils" package.
Displays six rows and five columns of random numbers between 0 and 1. If you need only one column, you can dispense with the "for" loop.
This example calculates the averages of column one and column two of "file.dat". It can be easily modified if other columns are to be averaged.
Another combination of seq and awk. Not very efficient, but sufficiently quick.
"seq 100" outputs 1,2,..,100, separated by newlines. awk adds them up and displays the sum.
"seq 1 2 11" outputs 1,3,..,11.
Variations:
1+3+...+(2n-1) = n^2
seq 1 2 19 | awk '{sum+=$1} END {print sum}' # displays 100
1/2 + 1/4 + ... = 1
seq 10 | awk '{sum+=1/(2**$1)} END {print sum}' # displays 0.999023
This loops through all tables and changes their collations to UTF8. You should backup beforehand though in case some data is lost in the process.
Show the number of failed tries of login per account. If the user does not exist it is marked with *.
Just type 'opened' and get all files currently opened for edit.
This command shows if there are any locked AFS volumes.
The output is a list of AFS volume IDs (or nothing if there are none locked).
Takes a input file (count.txt) that looks like:
1
2
3
4
5
It will add/sum the first column of numbers.
This command converts filenames with embedded spaces in the current directory replacing spaces with the underscore ("_") character.
Can pipe to tail or change the awk for for file size, groups, users, etc.
This command will kill all processes using a directory. It's quick and dirty. One may also use a -9 with kill in case regular kill doesn't work. This is useful if one needs to umount a directory.
This adds all new files to SVN recursively. It doesn't work for files that have spaces in their name, but why would you create a file with a space in its name in the first place?
Removes all unversioned files and folders from an svn repository. Also:
svn status --no-ignore | grep ^I | awk '{print $2}' | xargs rm -rf
will remove those files which svn status ignores. Handy to add to a script which is in your path so you can run it from any repository (a la 'svn_clean.sh').
This was useful to generate random passwords to some webpage users, using the sample code, inside a bash script
This command lets you see and scroll through all of the strings that are stored in the RAM at any given time. Press space bar to scroll through to see more pages (or use the arrow keys etc).
Sometimes if you don't save that file that you were working on or want to get back something you closed it can be found floating around in here!
The awk command only shows lines that are longer than 20 characters (to avoid seeing lots of junk that probably isn't "human readable").
If you want to dump the whole thing to a file replace the final '| less' with '> memorydump'. This is great for searching through many times (and with the added bonus that it doesn't overwrite any memory...).
Here's a neat example to show up conversations that were had in pidgin (will probably work after it has been closed)...
sudo cat /proc/kcore | strings | grep '([0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\})'
(depending on sudo settings it might be best to run
sudo su
first to get to a # prompt)
This command is much quicker than the alternative of "sort | uniq -c | sort -n".