Home > unix > How to: Interact with remote Unix Systems

How to: Interact with remote Unix Systems

If you’re a software developer or sysadmin, chances are that you will not always be working with a local machine.  That is where remote access comes in.  I’ve had to pick up how to do this through trial and error; hopefully this post will pull together information from all the disparate sources and will help newbies like myself learn a little more quickly.

This post will go through all the tools you will need to interact with remote Unix based systems while using Windows or Mac OSX.   Why am I focusing on interacting with Unix based systems?  Many of the computers you will want to access remotely will be running a variant of Linux (servers come to mind).  Besides, I guarantee you will be a more productive programmer / computer operator if you learn Unix command line tools.  I will be covering Unix command line tools in much greater depth in a later post.


If all you need is to grab files off of a remote Unix computer or dump some files to said machine, you can use a client application to help.  If you’re on Windows, you will want a copy of WinSCP.   This is a GUI version of the command line tool secure copy (scp), and allows you to drag and drop files between your local machine and the remote computer.  For users uncomfortable with command line tools, this is the easiest way to add and grab files to remote machines.  WinSCP has some bizarre UI choices (the selection of file nodes is unlike anywhere else in the Windows OS) but it can be useful. For MacOSX you can use Fugu; it does much the same thing.


When copying and pasting files is not enough, you will need to roll your sleeves up and learn a few more tools. First, you need to get used to the idea of giving up your GUI windowing environment and interacting with a keyboard

The terminal.  Learn to love it

First, you will need to learn how to navigate a Unix directory tree, as you will not have the nice GUI environment you are used to.

Here is that same Directory viewed in the Terminal with the tree command:

Nick@Macintosh-2 ~/Desktop/TestDir$ tree .
|--  SubFolder1
|   |-- SubSubFolder1
|   `-- test.txt
|--  SubFolder2
`-- test.txt

3  directories, 2 files

I’m not going to duplicate all the information that’s already on the Internet about using the command line.  Here’s a few commands you’ll absolutely need to know.

cd change directory
ls list files in directory
cp copy files
mv move files
mkdir make directories

Once you are comfortable moving around your own directory structure using the command line, you’re ready to interact with a remote machine.


SSH stands for Secure Shell and is the primary way you will interact with remote computers.  When you have a connection to the computer via SSH, it is just as if you were a local user signed on and using the terminal.  Thus it is crucial that you understand how to use command line tools and navigate a UNIX based operating system.

See the man page for the full syntax, but the basic way to use ssh is as follows:

ssh  username@remotemachine

where remotemachine is either the name of the machine, if it’s on your local network and is mapped to an IP Address, or the IP address.  You must have an account on that machine, and permission to log in.  You will be prompted for a password if necessary.  There are plenty of guides online for how to use SSH, here’s a good intro guide.

Type ‘logout’ when you are finished.


You can now log on to the remote machine and interact with it as if it were a local machine.  But what if you need to run scripts that take a long time to complete?  As it stands now, if your connection is terminated (either by purposely logging out or the connection being interrupted), whatever you are running will exit.  This happened to me when I was working from home; I started a batch job that would take around 6 hours to finish and after about 3 hours my Internet connection hiccuped, I lost the connection, and the whole run had to be restarted later.
How do you get around this problem?  Enter screenScreen is a Unix command line tool that allows you to do two things really well: open multiple terminal windows in one window and cycle between them, as well as persist your sessions after you logout.  If all it did were the latter, it would still be worth using as it allows you to start jobs and not be tied to the connection; as long as the remote machine stays on, your job will keep working.  The former capability is extremely useful as well; prior to this I would find myself opening multiple putty or cygwin windows, each of which would have an ssh connection to the remote machine, and each of which would necessitate me typing the password again.  In some cases I had 8 windows open at once, since I had to start 8 long-running jobs simultaneously.  Now I only have to create one window, ssh into the remote machine, start (or resume) a screen session, create all the windows I need, start whatever work I need to do, detach the session, and now my work continues in the background.

If you’re on a Linux box, you’ve probably already got screen installed.  If you’re on Windows running Cygwin, there’s a patch to add screen support.  If you’re on Mac, you can use MacPorts (one of my essential pieces of Mac software) to install screen:

port  install screen
There are many excellent tutorials on screen; you should check them out for more in-depth looks at the options.  Check out the man page as well.  Here is the bare minimum of what you need to know how to do:
Before screen is launched (in standard terminal)
Launches the screen program; you might see information popup describing the program
screen -S name
Creates a new screen session instance named ‘name’
screen -r
If there’s only one saved screen session, resume it; else displays the list of screen sessions available
screen -r text
Resume the screen session whose name includes ‘text’; if it’s ambiguous it will tell you so and you need to be more specific

While screen is running

Ctrl-a ? Display all the keyboard commands
Ctrl-a “
List all the current windows in the screen session
Ctrl-a A
Rename the current window
Ctrl-a k Kill the current window (pops up a Dialog question)
Ctrl-a d Disconnect from the screen session; you can resume it later with screen -r
Ctrl-a c Create a new window
Ctrl-a p Go to previous window
Ctrl-a n Go to next window
Ctrl-a S Split the window
Ctrl-a Q Quit splitting the windows (go back to one)
Ctrl-a Tab Jump between split windows
Ctrl-a a Invoke a literal ctrl-a (jump to first character of input)

If you’re a Unix guru who’s used to navigating through text with Ctrl-a to jump to the start of a line, this last command is very useful (and I just found it while researching this post; it was driving me nuts previously).  On Windows the Ctrl-a a shortcut is not necessary; you can hit Home to jump to the front of the line.  On a Mac, however, the Home key pages up.


Being able to interact with machines that are not right in front of you is a crucial skill to have in the IT business.  It can also be useful if you’re in school and need to retrieve a file that you saved on a machine somewhere and that you don’t feel like walking across campus to access locally.  There are all sorts of uses for the tools I’ve introduced here; hopefully this piques your interest and causes you to read more about them.

Categories: unix Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: