Here’s a quick note on how to run rsync over a non-standard port.
rsync -avz /some/local/path/ -e "ssh -p <theport>" remoteuser@remotehost:/some/remote/path/
IT and anything that fascinates me
Here’s a quick note on how to run rsync over a non-standard port.
rsync -avz /some/local/path/ -e "ssh -p <theport>" remoteuser@remotehost:/some/remote/path/
From time to time, you may want to check vital statistics about an application running on your computer. E.g. Suppose you have the application ID for a process, e.g. obtained from Activity Monitor on a Mac, here’s an easy way to find out the command path used to start the process:
ps xuwww -p <process id>
When using the find command you may want to combine conditions, e.g. using an OR.
Here’s a way to do that.
find . -type f \( -name "*deb" -o -name "*vmdk" \)
This command finds all files in current directory ending with db or vmdk.
When using OS X or Ubuntu, you may want to quickly find files modifed after a certain date and time. Here’s a way to do it using the find command:
find . -newermt "YYYY-MM-DD HH:II:SS"
Have you ever felt the discomfort of having to log in twice into a server so you can run two applications simultaneously? Have you wondered if there could be an easier way? Or are you looking for an easy way to start a long process on a server, detach from it, and connect back to the same session from a different client? Well, there’s a solution for all your worries. It’s called tmux! tmux allows you split a terminal into several subsections. It also allows you start a session over ssh and log out while the session keeps running, then log in via ssh on a possibly different machine and resume your session. So, the client becomes more irrelevant. I’ll discuss how to do a few things using tmux.
How to start a new tmux session run the following
tmux new -s session-name
or run the following
tmux new
It’s recommended to use the first format as it gives your sessions more meaningful names.
To detach from a session, run the following:
Ctrl-b d
or run the following
tmux detach
To list sessions, use the command
tmux ls
Note that tmux uses Ctrl-b as a prefix for its operations by default. This can be changed though as tmux is highly configurable.
To attach to an existing session use the following:
tmux a
This attaches to the first available session. You can also use the following:
tmux a -t session-name
To attach to a named session.
When logged in to a session, you can split the window into panes.
To split the window vertically, use the following command:
Ctrl-b %
To split it horizontally use the command:
Ctrl-b "
To switch pane, use the command
Ctrl-b arrow key
To resize a pane use the following command:
Hold Ctrl-b, then hold an arrow key
To scroll up a page on OS X, press Ctrl-b then [. This will put you in scroll mode. You can then use arrow keys to go up and down. To move page by page while in scroll mode, using PageUp and PageDown keys. On a laptop without PageUp key, you can simulate it by pressing Cmd-Up Arrow. To exit scroll mode press q.
To kill or delete a session use the command:
tmux kill-session -t myname
Some helpful resources on tmux can be found at:
dayid’s screen and tmux cheat sheet. http://www.dayid.org/os/notes/tm.html
tmux Tutorial – Split Terminal Windows Easily. http://lukaszwrobel.pl/blog/tmux-tutorial-split-terminal-windows-easily
A tmux Primer. https://danielmiessler.com/study/tmux/
Sometimes you may want to do some floating point arithmetic in your terminal and discover that running Basic Calculator (bc) only performs integer math. Here’s the command you need to make it work
bc -l
Now you can enjoy floating goodness!
Sometimes when trying to log in to a server via SSH you may come across an error like:
Bad owner or permissions on ~/.ssh/config
As the error implies, the folder has unacceptable permissions. Fix this by running the following command:
chmod 600 ~/.ssh/config
In order to enable vi mode for several readline-compatible (terminal) applications ilke ipython, MySQL, etc. on Unix (os X)
Set the following in your ~/.inputrc file:
set editing-mode vi set keymap vi set convert-meta on
Update:
In case someone’s wandering in here recently, IPython 5.0 switched from readline to prompt_toolkit, so an updated answer to this question is to pass an option:
$ ipython --TerminalInteractiveShell.editing_mode=vi
… or to set it globally in the profile configuration (~/.ipython/profile_default/ipython_config.py; create it with ipython profile create if you don’t have it) with:
c.TerminalInteractiveShell.editing_mode = ‘vi’
Source:
python – How do I use vi keys in ipython under *nix? – Stack Overflow. http://stackoverflow.com/questions/10394302/how-do-i-use-vi-keys-in-ipython-under-nix