Commands by treebeard (1)

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

Reset hosed terminal,
stty sane resets the tty to basic usable function. The ^J is a newline -- sometimes CR/LF interpretation is broken so use the ^J explicitly.

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

Change Random Wallpaper on Gnome 3
Change Random Wallpaper on Gnome 3

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Multi line grep using sed and specifying open/close tags
Working with log files that contains variable length messages wrapped between open and close tags it may be useful to filter the messages upon a keyword. This works fine with GNU sed version 4.2 or higher, so pay attention to some unix distros (solaris, hp-ux, etc.). Linux should be ok.

Copy ssh keys to user@host to enable password-less ssh logins.
Alternative for machines without ssh-copy-id

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Apply fade effect to a audio
fade [type] fade-in-length [stop-time [fade-out-length]] Apply a fade effect to the beginning, end, or both of the audio. An optional type can be specified to select the shape of the fade curve: q for quarter of a sine wave, h for half a sine wave, t for linear (`triangular') slope, l for logarithmic, and p for inverted parabola. The default is logarithmic. A fade-in starts from the first sample and ramps the signal level from 0 to full volume over fade-in-length sec? onds. Specify 0 seconds if no fade-in is wanted. For fade-outs, the audio will be truncated at stop-time and the signal level will be ramped from full volume down to 0 starting at fade-out-length seconds before the stop-time. If fade-out-length is not specified, it defaults to the same value as fade-in-length. No fade-out is performed if stop-time is not specified. If the file length can be determined from the input file header and length-changing effects are not in effect, then 0 may be specified for stop-time to indicate the usual case of a fade-out that ends at the end of the input audio stream. All times can be specified in either periods of time or sample counts. To specify time periods use the format hh:mm:ss.frac format. To specify using sample counts, specify the number of samples and append the letter `s' to the sample count (for example `8000s').

Makes the permissions of file2 the same as file1
Also works with: $chgrp --reference file1 file2 $chown --reference file1 file2

Show directories in the PATH, one per line

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: