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:
use this command via ssh on remote machine when you want play video
remove --directory if you want select single file
use this command via ssh on remote machine when you want play video stream or path to file
~ is the ssh control character. If you type it after a newline, you can example force close the ssh session.
, ~, then .
If you want more info, type ~? when you are connecting using ssh.
Very useful to kill of any hanging ssh sessions when nothing else works.
Do the same as pssh, just in shell syntax.
Put your hosts in hostlist, one per line.
Command outputs are gathered in output and error directories.
This command will download $file via server. I've used this when FTP was broken at the office and I needed to download some software packages.
Ever wanted to stream your favorite podcast across the network, well now you can.
This command will parse the iTunes enabled podcast and stream the latest episode across the network through ssh encryption.
This will allow you to convert an audio file to wav format, and send it via ssh to a player on the other computer, which will open and play it there. Of course, substitute your information for the sound file and remote address
You do not have to use paplay on the remote end, as it is a PulseAudio thing. If the remote end uses ALSA, you should use aplay instead. If it uses OSS, you should berate them about having a lousy sound system. Also, you're not limited to transmitting encoded as wav either, it's just that AFAIK, most systems don't come with mp3 codecs, but will play wav files fine.
If you know SoX is installed on the remote end and has mp3 codecs, you can use the following instead:
cat Klaxon.mp3 |ssh thelab@company.com play -t mp3 -
this will transmit as mp3. Again, use your specific information. if you're not playing mp3s, use another type with the -t option
Ssh to host1, host2, and host3, executing on each host and saving the output in {host}.log.
I don't have the 'parallel' command installed, otherwise it sounds interesting and less cryptic.
Require:
- tsocks (deb pkg)
- A working SOCKS proxy. It's easy with ssh:
$ ssh -N -D localhost:1080 your.home.pc -p 443
- tsocks configuration in your /etc/tsocks.conf (for the previous):
server = 127.0.0.1
server_port = 1080
The above command will send 4GB of data from one host to the next over the network, without consuming any unnecessary disk on either the client nor the host. This is a quick and dirty way to benchmark network speed without wasting any time or disk space.
Of course, change the byte size and count as necessary.
This command also doesn't rely on any extra 3rd party utilities, as dd, ssh, cat, /dev/zero and /dev/null are installed on all major Unix-like operating systems.
You may go to Internet by means of your home ssh server. You must configure your local proxy to send traffic through the proxy. Many programs allows that: firefox, pidgin, skype, gnome, etc.
Your home ssh server must listen in any of the ports permitted by your enterprise firewall. That usually includes 80 and 443.
Some servers don't have ssh-copy-id, this works in those cases.
It will ask for the destination server, this can be IP, hostname, or user@hostname if different from current user.
Ssh keygen will let you know if a pubkey already exists on your system and you can opt to not overwrite it.
you may create an alias also, which I did ;-)
alias sshu="ssh -o UserKnownHostsFile=/dev/null "
Useful to create an alias that sends you right in the directory you want :
alias server-etc="ssh -t server 'cd /etc && $SHELL'"
ssh_config is the system-wide configuration file for ssh.
For per-user configuration, which allows for different settings for each host:
echo 'ServerAliveInterval 60' >> ~/.ssh/ssh_config
On OSX:
echo 'ServerAliveInterval 60' >> ~/.ssh/config
or
echo 'ServerAliveInterval 60' >> ~/etc/ssh_config
Execute it from the source host, where the source files you wish backup resides. With the minus '-' the tar command deliver the compressed output to the standar output and, trough over the ssh session to the remote host. On the other hand the backup host will be receive the stream and read it from the standar input sending it to the /path/to/backup/backupfile.tar.bz2