Archive for December, 2013

h1

Handy command line thingies

Monday, December 23rd, 2013

A compilation of handy commands I use when working remotely and/or on command line.

File sharing from remote server

I used to use scp a bunch for transferring files between my local machine and some server. However, I found that ssh file share is waaay handier.

Essentially, you define a local folder from which you mount a directory in a remote server by typing the following:

sshfs <username>@<servername.host.domain>: <name_of_local_folder>/

So, for example, here I’d use sshfs sammi@nonado.net: MyNonadoFiles/ in the location where my MyNonadoFiles/ folder is.

Search previous commands

Another handy shortcut I use a lot since learning to use the command line is reusing previous commands. Pressing the ‘up’ scrolling button is fine but if I’ve been typing a lot of cd here and there or running scripts repeatedly then it can take a while to find a specific command (such as the sshfs above) which I use seldomly but is super useful. Here’s a couple of shortcuts:

  • Ctrl-r + “what you’re searching for”
    • e.g. pressing Ctrl and r, and then ssh would find your most recent command that has ssh in it.
    • To look further back, keep pressing Ctrl+r
  • history -“number of lines”
    • e.g. history -100 returns your most recent 100 commands