commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Booting the VM headless via VBoxHeadless requires knowledge of the VM's network in order to connect. Using VBoxManage in this way and you can SSH to the VM without first looking up the current IP, which changes depending on how you have your VM configured.
Sometimes you need to compare two config files on different servers. Put the file names into the above script and let 'er rip.
This uses ssh to transfer the contents of one Mac's clipboard to another's. This only works with plain text, sadly. Trying to transfer images will just clear out the remote machine's clipboard, and rich text will be converted to plain text. Using the "Remote Login" must be enabled on the remote machine (via System Preferences' Sharing panel) for this to work.
Admittedly, I'd never have thought of this without the earlier examples, but here's one that you can execute from your workstation to just display the image from another, without separately doing a file transfer, etc. By the way, I hear a loud beep coming from the other room, so I guess it's not too stealthy :-D
This will show the throughput between two nodes.
Thanks to szboardstretcher, who posted it here: http://www.linuxquestions.org/questions/linux-networking-3/quick-and-easy-way-to-measure-throughput-between-two-nodes-868998/
This version compresses the data for transport.
parrallel execution of a command on remote host by ssh or rsh or ...
very useful for cluster management (software update)
In the example above 3 tables are copied. You can change the number of tables. You should be able to come up with variants of the command by modifying the mysqldump part easily, to copy some part of remote mysql DB.
until (ssh [email protected] 2> /dev/null); do date; sleep 15; done
In this case will execute "date" then "sleep 15" until we are able to ssh into server, such as after a reboot
Could also be like:
until ( ping 10.1.1.39 1> /dev/null); do echo "server 10.1.1.39 is down"; sleep 15; done
Need to query hundreds of hosts with an ssh command ?
Of course you'll have setup keys on all your remote HOSTs. But in the case a key is not present this command will skip that node, proceeding on to the next.
Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine. Also prevents unwanted stty messages being sent to console
-o "BatchMode yes"
If set to yes, passphrase/password querying will be disabled. This option is useful in scripts and other batch jobs where no user is present
Useful to get network access to a machine behind shared IP NAT. Assumes you have an accessible jump host and physical console or drac/ilo/lom etc access to run the command.
Run the command on the host behind NAT then ssh connect to your jump host on port 2222. That connection to the jump host will be forwarded to the hidden machine.
Note: Some older versions of ssh do not acknowledge the bind address (0.0.0.0 in the example) and will only listen on the loopback address.
Simply makes it possible to launch any X application residing on sshhost through sshproxy and display it on your screen where ever you are.
This may be listed already but this command is useful to untar a specific directory to a different server.
Nice command for when you don't have scp available for whatever reason.
Works with binaries.
Record off the microphone on a remote computer and listen to it live through your speakers locally.
Run local scripts on remote server. "-T Disable pseudo-tty allocation"
host B (you) redirects a modem port (62220) to his local ssh.
host A is a remote machine (the ones that issues the ssh cmd).
once connected port 5497 is in listening mode on host B.
host B just do a
ssh 127.0.0.1 -p 5497 -l user
and reaches the remote host'ssh. This can be used also for vnc and so on.
1. SSH into a machine
2. Tunnels VNC port to your local computer ("-L 5900:localhost:5900")
3. Runs a single use vnc server ("x11vnc -safer -localhost -nopw -once -display :0")
4. Goes into the background ("-f")
5. Runs VNC viewer on the local computer connecting to the remote machine via the newly created SSH tunnel ("vinagre localhost:5900")
I frequently use this trick to send my terminal settings to HPUX and older RHEL systems. This is due to the fact that terminfo support for rxvt-unicode (my preferred terminal app) does not exist on many older Linux and Unices.
Install a basic FreeBSD system on a distant server. I use this to install FreeBSD on servers that can only boot a Linux rescue system. This sytem loads on ram when booted, so it is possible to install freely. You can even install on ZFS root !