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:
nc localhost 9876
This is just a default ssh-keygen command. Prompts for a password that you can use to secure the keys more and uses a higher bit value than the default along with naming the key something other than id_rsa for better file identification.
By this command you can take the snapshot of you harddisk (full) and create the image , the image will be directly store on remote server through ssh. Here i am creating the image of /dev/hda and saving it at 184.108.40.206 as /root/server.img.
get master info:
head -n 40 /home/db_bak.sql |awk '$0~/MASTER_LOG_FILE/
change master ??.
Copy a local directory to a remote server using ssh+tar (assume server is lame and does not have rsync).
this will tar/send/untrar a whole directory.
It requires https://jqplay.org/, that comes with brew: brew install jq
The files are automatically uncompressed when they reach the destination machine. This is a fast way to backup your server to your local computer while it's running (shutting down services is recommended).
A file named "exclude.txt" is needed at /tmp/ containing the following :
Should be the notify-send package installed
Tested on Windows 8 w/SSH, Cygwin - it can be tricky to quote if you dont use the $(..) syntax to echo it back out
Provides a SOCKS5 proxy on localhost port 8080 which will tunnel all connections through srv1 and run in the background.
Tunneling an SSH session through TOR for anonymity.
Using openbsd's netcat.
Tested on Ubuntu 14.04
This also works with any proxy type: http, socks4 and socks5
For http proxy, replace -X 5 with -X connect
For socks4 proxy, replace -X 5 with -X 4 (DNS leak may occur)
Proxy host defined after -x
Replace -x localhost:9050 with proxy server of your choice
Copies files between hosts which don't have access to each other. It uses a proxy host which has access to both of them.
ssh from local to remote and pipe output of file to the local clipboard
While `sshfs $REMOTE_HOST:$REMOTE_PATH $LOCAL_PATH` "pulls" a directory from the remote server to the local host, the above command does the reverse and "pushes" a directory from the local host to the remote server.
This makes use of the "slave" option of sshfs which instructs it to communicate over plain stdin/stdout and the `dpipe` tool from vde2 to connect the sftp-server stdout to the sshfs stdin and vice-versa.
Copy changed files from remote git repository, _including binary ones_, staged and unstaged alike. Note that this command doesn't handle deleted files properly.
Securely stream a file from a remote server (and save it locally).
Useful if you're impatient and want to watch a movie immediately and download it at the same time without using extra bandwidth.
This is an extension of snipertyler's idea.
Note: This command uses an encrypted connection, unlike the original.
I sue this in my .bashrc file
This will also do auto-completion for scp and sftp
If you are blocked or need to use a Socks proxy