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.
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:
If you need to find some pictures on your disk but excluding some path.
do it, disown it and exit without time for a mess
sudo when you mean it
ps aux | grep $USER
sudo when you mean it
ps aux | grep $USER
Starts a bunch of background jobs to write random garbage to everyone else's terminals. The "\n" in IFS should be an actual newline, but I can't put that in the command.
recurse through all files, get the message hash, flip the output as filename, hash value
Run one script after another in such a way that second script starts after finishing first one. Without using Pipe | or ampercent && i.e. the first process is already running and you want second one to start after the first one finishes. And this can be done in different folder in case the output of second script will affect the output of first script. So run this on any folder you wish to.
Where $PID is the process id of the already running job (add PID number)
script2 is your script you wish to run after first script ends
sleep 1 is sleep for one second (SUFFIX may be ?s? for seconds (the default), ?m? for minutes, ?h? for hours or ?d? for days, read man sleep)
Useful if localhost is a small machine running BusyBox, which uses a slightly unusual format to set the date. Remotehost can be pretty much any Linux machine, including one running BusyBox. Uses UTC for portability.
Use find's built-in "exec" option to avoid having to do any weirdness with quoting.
It's somewhat common ISPs to intercept DNS queries at port 53 and resolve them at their own.
To check if your ISP is intercepting your DNS queries just type this command in the terminal.
"#.abc" it's an OK answer.
But if you get something like "I am not an OpenDNS resolver.", yep, you are beign cheated by your ISP.
In order to write bash-scripts, I often do the task manually to see how it works. I type ### at the start of my session.
The function fetches the commands from the last occurrence of '###', excluding the function call. You could prefix this with a here-document to have a proper script-header.
Delete some lines, add a few variables and a loop, and you're ready to go.
This function could probably be much shorter...
Useful to add a timestamp to every line printed to stdout.
You can use `-Ins` instead of `-Iseconds` if you want more precision.
I'm not sure what apt this is, but it seems to work on most X screens, an is useful for saving power, and not straining your eyes
Check if your open ports as listed by lsof are actually accepting connections using netcat.
Requires that bash has extglob enabled: shopt -s extglob
Edit YYYY and MM at the beginning of the command with the year and month you want.
Note that `DD=$(printf "%02d" $d)` will pad single digit integers with a leading zero.
Substitute `echo $YYYY$MM$DD` at the end of the line with the command you want to launch, for instance
script.pl --yyyymmdd $YYYY$MM$DD