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:
You need curl.. and a Mac of course.
This is a (last resort) way to automate applications that provide no other ways for automation, it would send 'Hello world' to the currently active window. See the manpage (and the -text and -window entries) for how to send special characters and target specific windows.
Using xwininfo, I get the id of my XPlanet background window:
[email protected]:19:51:0:~> xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x3600001 "Xplanet 1.2.0"
Absolute upper-left X: 0
Now I use xvkbd to tell it to close itself:
xvkbd -xsendevent -window 0x3600001 -text "Q"
Obviously, the best way is to put these commands in a shellscript - just make sure to include a short sleep (sleep .1 should suffice) after each xvkbd call, or some programs will become confused.
If you have a JAR that is not in a central Maven repository this will add it to your repository.
This lets you use your favorite vi edit keys to navigate your term.
To set it permanently, put "set editing-mode vi" in your ~/.inputrc or /etc/inputrc.
If you would like to edit a previous command, which might be long and complicated, you can use the fc (I think it stands for fix command). Invoke fc alone will edit the last command using the default editor (specified by $FCEDIT, $EDITOR, or emacs, in that order). After you make the changes in the editor, save and exit to execute that command. The fc command is more flexible than what I have described. Please 'man bash' for more information.
CDPATH tells the cd command to look in this colon-separated list of directories for your destination. My preferred order are 1) the current directory, specified by the empty string between the = and the first colon, 2) the parent directory (so that I can cd lib instead of cd ../lib), 3) my home directory, and 4) my ~/projects directory.
Watch the number of packets/bytes coming through the firewall. Useful in setting up new iptables rules or chains. Use this output to reorder rules for efficiency.
I had a hard time in finding the correct settings to get reasonable output from a coin selector which sends its data over a serial line. In the end, minicom came to the rescue and pointed me on the right track.
So, if you need to do something similar, these settings may help you.
Replace ttyUSB0 with your device file, 9600 with your baud rate, 5 with your read timeout (10ths of a second), and 1 with the minimum numbers of characters you want to read.
You can then open the device file like you are used to do, example:
DATA="`xxd -ps -l 5 \"$DEV\"`"
Replace the words between BEGIN and END.
Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting.
When typing out long arguments, such as:
cp file.txt /var/www/wp-content/uploads/2009/03/
You can put that argument on your command line by holding down the ALT key and pressing the period '.' or by pressing <ESC> then the period '.'. For example:
would put '/var/www/wp-content/uploads/2009/03/ as my argument. Keeping pressing 'ALT+.' to cycle through arguments of your commands starting from most recent to oldest. This can save a ton of typing.
Just type 'opened' and get all files currently opened for edit.
By 'pst' you can print out process tree with all details about all processes (including a command line, PID, and the current process you are running in).
By 'pst username' you can get an information about processes belonging to the particular user 'username'.
Alias two dots to move to parent directory. Put it into your .bashrc or .profile file.
It helps you save a lot of writing :-)
I think it would be wise if anyone voting down left a comment indicating the reason for that action. Don't keep it to yourself. Thanks.
The output of "echo $PATH" is hard to read, this is much easier. The parentheses ensure that the change to the input field separator (IFS) only happens the the sub shell and not affecting the current shell.
On my music directory, I create variable that contains all mp3s files, then I play them with mpg123. -C options enable terminal control key, s for stop, p for pause, f for forward to next song.