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:
unzips all zip files in any subdirectory under the current directory. The zip files are unzipped in their respective subdirs
This uses Bash's "process substitution" feature to compare (using diff) the output of two different process pipelines.
I find that I create a directory and then cd into that directory quite often. I found this little function on the internets somewhere and thought I'd share it. Just copy-paste it into you ~/.bash_profile and then `source ~/.bash_profile`.
This command create a new temp directory using mktemp (to avoid collisions) and change the current working directory to the created directory.
Based on linkinpark342 suggestion.
Sometimes you have to browse your way through a lot of sub-directories. This command cd to the previous sub-directory in alphabetical order. For example, if you have the directories "lectures/01-intro", "lectures/02-basic", "lectures/03-advanced" and so on, and your PWD is "02-basic", it jumps to "01-intro".
Another version based on linkinpark342's contribution.
Sometimes you have to browse your way through a lot of sub-directories. This command cd to the next sub-directory in alphabetical order. For example, if you have the directories "lectures/01-intro", "lectures/02-basic", "lectures/03-advanced" and so on, and your PWD is "02-basic", it jumps to "03-advanced".
Sometimes you have to browse your way through a lot of sub-directories. This command cd to the next sub-directory in alphabetical order. For example, if you have the directories "lectures/01-intro", "lectures/02-basic", "lectures/03-advanced" and so on, and your PWD is "02-basic", it jumps to "03-advanced".
It copies the entire current working directory to the destination directory with compression enabled.
ec commits changes to etckeeper
must have etckeeper installed with bzr to use this
place inside bashrc
can be used from any directory to commit changes
During this operation :
# mv Joomla_1.5.10-Stable-Full_Package.zip /var/www/joomla/
I invoke /var/www/joomla/ as last command argument. To change in this directory I can use
# cd !$
So I go to
hob:/var/www/joomla#
This command looks for a single file named emails.txt which is located somewhere in my home directory and cd to that directory. This command is especially helpful when the file is burried deep in the directory structure. I tested it against the bash shells in Xubuntu 8.10 and Mac OS X Leopard 10.5.6
When you fill a formular with Firefox, you see things you entered in previous formulars with same field names. This command list everything Firefox has registered. Using a "delete from", you can remove anoying Google queries, for example ;-)
An alias i made for myself to play music in a faster way.
Works great when you have Guake / Tilda installed (Console that drops down like in the game QUAKE)
---
I put this in my bash_alias file (I'm on ubuntu, the bash_alias file does autostart with the right config) but it works putting it in bashrc too. Or anything that autostarts when the console is opened.
---
Needs Mplayer and music files to work. With out music theres nothing to play!
Oh, and also, without modification, this alias will try to play stuff from your ~/Music folder! (case sensitive). Make sure that folder exists and has music OR edit this alias to fit your needs.
After typing cd directory [enter] ls [enter] so many times, I figured I'd try to make it into a function. I was surprised how smoothly I was able to integrate it into my work on the command line.
Just use cdls as you would cd. It will automatically list the directory contents after you cd into the directory. To make the command always available, add it to your .bashrc file.
Not quite monumental, but still pretty convenient.
Often, the very next command after the cd command is 'ls', so why not combine them?. Tested on a Red Hat derivative and Mac OS X Leopard
Update: changed ${1:-$HOME} to "${@:-$HOME}" to accomodate directories with spaces in the names
Add the functions to the .bashrc to make it work
Example: First go to the iso file directory and type:
----------------------------------------------------------------------------------------------------
user@box:~$ miso file.iso
----------------------------------------------------------------------------------------------------
It will put you into a temporary mounting point directory (ISO_CD) and will show the files
You can umount the iso file whatever the directory you are
----------------------------------------------------------------------------------------------------
user@box:~/ISO_CD$ uiso
----------------------------------------------------------------------------------------------------
It wil umount the iso file and remove the temporary directory in your home
If you use symlinks a lot, especially nested symlinks, this puts you back on the absolute path to command-line-fu-nirvana. (Note the backticks around pwd).