All commands (14,187)

What's this?

commandlinefu.com 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

tail: watch a filelog
-f file(s) to be monitorized -n number of last line to be printed on the screen in this example, the content of two files are displayed

Run a command when a file is changed

strace like SystemTap script
The stap script is : #! /usr/bin/env stap probe syscall.* { if (pid() == target()) printf("%s %s\n", name, argstr); }

Compress a series of png pictures to an avi movie.
cd /path/to/your/png_pics mencoder "mf://*.png" -mf fps=2 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4 then you can get a movie named output.avi.

List all execs in $PATH, usefull for grepping the resulting list
##Dependancies: bash coreutils Many executables in $PATH have the keyword somewhere other than the beginning in their file names. The command is useful for exploring the executables in $PATH like this. $ find ${PATH//:/ } -executable -type f -printf "%f\n" |grep admin lpadmin time-admin network-admin svnadmin users-admin django-admin shares-admin services-admin

Check whether laptop is running on battery or cable
1 = on ac, 0 = on bat

Rename files in batch

Instantly load bash history of one shell into another running shell
By default bash history of a shell is appended (appended on Ubuntu by default: Look for 'shopt -s histappend' in ~/.bashrc) to history file only after that shell exits. Although after having written to the history file, other running shells do *not* inherit that history - only newly launched shells do. This pair of commands alleviate that.

Get the next weekday for an 'at' command
Line can be modified as needed. This considers weekdays to be Mon-Fri. If run any working day it'll provide a parameters for the next working day for "at". "beep" provided as a sample command. This can be modified easily to include wait time. If you need something to run "D" days after today: # D=4;if [ $(date +%u --date="${D} days") -lt 5 ];then AT="+${D} days";else AT="next monday";fi; echo "beep" | at noon ${AT}

Remote screenshot
Say if you're logged into a remote system via ssh and this system has an x window system, but yet you still want a screen shot of what's going on graphically. This will do it for you. :-)


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: