Commands by Koobiac (12)

What's this? 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.

Share Your Commands

Check These Out

Current running process ordered by %CPU
Useful to detect which process is causing system loads. It shows process PID so as we can take further actions.

Top ten (or whatever) memory utilizing processes (with children aggregate)
This command loops over all of the processes in a system and creates an associative array in awk with the process name as the key and the sum of the RSS as the value. The associative array has the effect of summing a parent process and all of it's children. It then prints the top ten processes sorted by size.

Salvage a borked terminal
This is more or less the same as 'reset', but with two advantages: the initial LF character makes sure you're starting a new line to the tty driver, the final one is more reliably a line-end as CR is often unset; and second, 'stty sane' is reliable on older UNIX systems, especially Berkeley-based ones.

Unbelievable Shell Colors, Shading, Backgrounds, Effects for Non-X
I've been using linux for almost a decade and only recently discovered that most terminals like putty, xterm, xfree86, vt100, etc., support hundreds of shades of colors, backgrounds and text/terminal effects. This simply prints out a ton of them, the output is pretty amazing. If you use non-x terminals all the time like I do, it can really be helpful to know how to tweak colors and terminal capabilities. Like: $ echo $'\33[H\33[2J'

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Resample a WAV file with sox
Change the sample rate with sox, the swiss army knife of sound processing.

quickly change all .html extensions on files in folder to .htm

watch process stack, sampled at 1s intervals
This command repeatedly gets the specified process' stack using pstack (which is an insanely clever and tiny wrapper for gdb) and displays it fullscreen. Since it updates every second, you rapidly get an idea of where your program is stuck or spending time. The 'tac' is used to make the output grow down, which makes it less jumpy. If the output is too big for your screen, you can always leave the 'tac' off to see the inner calls. (Or, better yet--get a bigger screen.) Caveats: Won't work with stripped binaries and probably not well with threads, but you don't want to strip your binaries or use threads anyway.

Pimp your less
# s = combine multiple lines of whitespace into 1 # x4 = set the tabstop to 4 instead of 8 # F = Exit if the output fits on 1 screen. This is similar to git diff # R = Raw control chars. This allows you to pipe colordiff straight to less. ie: alias sdi="svn diff | colordiff | less" # S = Chop off long lines # X = Dont send termcap init and deinit scrings to the terminal

Stay in the loop…

Follow the Tweets.

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.


Subscribe to the feeds.

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: