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:
pauses exactly long enough to wake at the top of the hour
Watch file's contents that is getting overwritten
This creates a permanent stock ticker in the terminal. it has scrolling action and refreshes when each cycle is done to get the latest news.
Cleaned up and silent with &>/dev/null at the end.
Execute commands serially on a list of hosts. Each ssh connection is made in the background so that if, after five seconds, it hasn't closed, it will be killed and the script will go on to the next system.
Maybe there's an easier way to set a timeout in the ssh options...
This puts a clock in the top right of the terminal. This version doesn't use tput, but uses escape codes
Using the output of 'ps' to determine CPU usage is misleading, as the CPU column in 'ps' shows CPU usage per process over the entire lifetime of the process. In order to get *current* CPU usage (without scraping a top screen) you need to pull some numbers from /proc/stat. Here, we take two readings, once second apart, determine how much IDLE time was spent across all CPUs, divide by the number of CPUs, and then subtract from 100 to get non-idle time.
Same effect, only shell commands.
apt-get install cmatrix cmatrix-xfont wmctrl transset-df
Need to restart computer for mtx font to work
Commands while cmatrix is running:
1 - 9 = Change speed
SHIFT + 1 - 7 = change colors
Q = Quit
Tested in Ubuntu 10.04
Random choose numbers from 1 to 100 with 5 seconds interval without duplicates.
For use when you can't use "watch" (user-defined functions, aliases). This isn't mine - its an alternate posted in the comments by flatcap, and is the shortest and easiest to remember.
usage: alarmclock TIME
TIME is a sleep(1) parameter which tells function how long to wait until raise the alarm.
repeat a command every X seconds , output show the creation of partition image using fsarchiver, each line show the size of the image.
Displays an animated hourglass for x amount of seconds
compare to alternative :
- directly tests the -STOP of the process to continue or stop loop,
- background operator should be set (or not) at the call of the function
For extension i suggest a slowPID() based on kill like above and a slowCMD based on killall.
Some IO intensive process make the system unresponsive. This function periodically starts/stops a process, which hopefully releases some resources for other activities.
This function is useful when ionice is not available
This takes a webcam picture every everytime the mouse is moved (waits 10 seconds between checking for movement) and stores the picture wherever you want it.
Use in conjunction with a dropbox type application to see who is using your computer
Use /dev/input/mice if /dev/input/mouse* doesn't work
Use the bones of this to make a simple screensaver
Replace "email@example.com" with your carrier's SMS gateway identifier. The one in the sample is for AT&T. More here https://en.wikipedia.org/wiki/List_of_SMS_gateways. Helpful for getting notifications about long running commands. ";" executes regardless of exit status of last command. && will only notify you if the command succeeds.
A tweak using Patola's code as a base, this full-width green matrix display has all the frills (and all the printable characters).
You don't need the surrounding parens if you don't care about losing globbing capabilities. Z-shell (/bin/zsh) needs neither the parens nor the `set -o noglob`
Screen shot (animated): http://desmond.imageshack.us/Himg32/scaled.php?server=32&filename=matrixh.gif&res=landing
If it's too slow, try lowering the `sleep 0.05` or even replacing it with `true` (which is faster than `sleep 0`).
I squashed it as narrow as I could to conserve space, though somebody could probably squeeze a char or two out.
watch ls -l
Basic but usable replacement for the "watch" command for those systems which don't have it (e.g. the Solaris I'm trapped on).
Type Ctrl+V to escape the following Ctrl+L which clears the screen. It will be displayed as "^L".