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:
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim. Drop this in your .bash_aliases and make sure that file is initialized in your .bashrc.
Purely frivolous - print a sine/cosine curve to the console - the width varies as it progresses. Ctrl-C to halt.
Use Ruby's standard Curses module to display a Lissajous curve in the console. Replace the "0.2" with different numbers for different curves.
for exemple :
var="echo hello"; $var
this will display "hello" with bash
with zsh, by default, this will make an error :
"command not found : echo hello"
hwordsplit option permit zsh to act like bash on this point
make sure that flac and lame are installed
sudo apt-get install lame flac
The above command will open a Remote Desktop connection from command line, authenticate using default username and password (great for virtual machines; in the exampe above it's administrator:password), create a shared folder between your machine and the other machine and configure resolution to best fit your desktop (I don't like full screen because it make the desktop panels to disappear). The command will run in the background, and expect to receive parameters. You should enter hostname or IP address as a parameter to the command, and can also override the defaults parameters with your own.
Dumps a compressed svn backup to a file, and emails the files along with any messages as the body of the email
Usage:
translate <phrase> <source-language> <output-language>
Example:
translate hello en es
It grabs all the database names granted for the $MYSQLUSER and gzip them to a remote host via SSH.
When you start screen as `ssh-agent screen`, agent will die after detatch.
If you don't want to take care about files when stored agent's pid/socket/etc, you have to use this command.
See http://code.google.com/apis/analytics/docs/concepts/gaConceptsCookies.html if you are unclear about the Google Analytics cookie system. If Firefox is your daily browser, be a good Orwellian and run this command regularly.
If you see, 'SQL error near line 1: database is locked', close Firefox and run again.
file displays a files type
the -L flag means follow sym-links (as libraries are often sym-linked to another this behavior is likely preferred)
more complex behavior (*two* grep commands!) could be used to determine if the file is or is not a shared library.
Determines the flavor of a shared library by looking at the addresses of its exposed functions and seeing if they are 16 bytes or 8 bytes long. The command is written so the library you are querying is passed to a variable up font -- it would be simple to convert this to a bash function or script using this format.
This is to fetch the Gateway Ip Address of a machine. Use the below format to put the value in a variable if you wish to find the gateway ip in a script
GATEWAY=$(netstat -nr | awk 'BEGIN {while ($3!="0.0.0.0") getline; print $2}')
This function is used to sort selected lines of a text file to the end of that file. Especially useful in cases where human intervention is necessary to sort out parts of a file. Let's say that you have a text file which contains the words
rough
slimy
red
fluff
dough
For whatever reason, you want to sort all words rhyming with 'tough' to the bottom of the file, and all words denoting colors to the top, while keeping the order of the rest of the file intact.
'$EDITOR' will open, showing all of the lines in the given file, numbered with '0' padding. Adding a '~' to the beginning of the line will cause the line to sort to the end of the file, adding '!' will cause it to sort to the beginning.
ifconfig can't properly display interface's name longer 9 symbols, so 'ip' should be used instead. This alias properly shows long names, bond interfaces and interface aliases. loopback interface is ignored, since its IP is obvious
if you haven't already done so, install lame and flac:
sudo apt-get install lame flac