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:
no need for installing mii-tools, all generic tools
working under archlinux.
`mount -o remount` doesn't pick up new NFS options (eg. timeo, soft, retrans, etc) so you need to do a full mount/remount cycle. This one-liner makes it quick and easy :) Update your fstab with the new options, then run it.
a() function in bc is for arctangent, available if using -l option included.
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.
Prints 0's and 1's in The Matrix style. You can easily modify to print 0-9 digits using $RANDOM %10 insted of %2.
/dev/random is said to by cryptographically secure, and unpredictable, as it gathers data from external sources, influenced by human timing interactions with computers, to fill the entropy pool. As such, this is a quick way to do a true random fair-6 dice roll. Using this method, you could easily create passphrases with Diceware http://diceware.com.
for i in {1..5}; do echo -n $((0x$(head -c5 /dev/random|xxd -ps)%6+1)); done; echo
Also shows files as they are found. Only works from a tty.
while commandt
do
command
command
...
done
{commandt is executed and its exit status tested.}
for i in 1 2 3
> do
> echo $i
> done
Use `scsi_id` to positively identify which LUNs are which (i.e. compare with the list of LUNs you created on your disk array)
(shown: RHEL5 usage)
Debian usage:
# for i in /dev/sd* ; do wwn=`/lib/udev/scsi_id -g --device $i` ; [ "$wwn" != "" ] && echo -e ${i##*/}'\t'$wwn ;done
This is the fastest way to burn a DVD-Video from the command line.
Dependencies:
libav-tools
dvdauthor
growisofs
The first command:
avconv -i input.avi -target pal-dvd dvd.mpg
converts any given video file avconv can handle into MPEG2-PS (6 Mbit/s) with AC3 audio (448 kbit/s). If your distribution is not up to date, just use ffmpeg - the syntax is the same. Hint: If you want to create an NTSC DVD, type ntsc-dvd instead ;-)
The second command:
echo PAL > ~/.config/video_format
sets PAL as your default video format. This is a workaround for an old dvdauthor bug. If you want NTSC, guess what? Type NTSC instead!
The third command:
dvdauthor -o dvd/ -t dvd.mpg
creates .VOB files and adds them to the dvd/ folder. You don't have to create this folder yourself. You can add as many titles as you like, just keep in mind that there's a maximum of 4482 MiB (4.37 GiB) for normal DVDs.
The fourth command:
dvdauthor -o dvd/ -T
finishes the DVD-Video.
Now you can burn your DVD using growisofs:
growisofs -Z /dev/dvd -dvd-video dvd/
Sources:
manpages
http://tuxicity.wordpress.com/2006/12/01/avi-to-dvd-with-ffmpeg-and-dvdauthor/
This will take the packages matching a given `apt-cache search` query (a collection of AND'd words or regexps) and tell you how popular they are. This is particularly nice for those times you have to figure out which solution to use for e.g. a PDF reader or a VNC client.
Substitute "ubuntu.com" for "debian.org" if you want this to use Ubuntu's data instead. Everything else will work perfectly.
Now we can capture only a specific window (we have to chose by clicking on it)
ffmpeg complains about "Frame size must be a multiple of 2" so we calculate the upper even number with (g)awk trickery.
We remove the grep, we are already using (g)awk here ....why losing time with grep !!! ;)
The command will make it easy to determine free IP ranges in a crowded sub-net.
Never ending music, generated via a C snippet, piped to aplay. Taken from: http://canonical.org/~kragen/bytebeat/
This will parse a random command json entry from http://commandlinefu.com
A must have in your .bash_profile to learn new shell goodies at login!!!
Echoes text horizontally centralized based on screen width