Using X11 to Access Unix from a Mac

Submitted on Sunday, 4/2/2023, at 1:53 PM

Students in introductory computer science classes work on two Unix systems, remus.amherst.edu and romulus.amherst.edu. The two machines are interchangable, so you can work on whichever one you want. In general you can refer to the machines by their short names when you are on-campus and by their full names, including the amherst.edu suffix, when you are off-campus.

Students in advanced classes may use systems managed by our own department.  Most of the ideas mentioned here can be applied equally well to our departmental systems.

One way to access the Unix systems is with X windows. When you use a connection of this kind, you have one or more windows to the other machine, which appear as part of your Mac desktop.

Getting X11 on your own Mac

X11 is preinstalled in older versions of OS X.  If you can't find it on your system, you should install XQuartz.

Let us know if you have problems getting X11 or XQuartz to work.

Connecting to the Unix machine

In the examples that follow, we'll suppose that you are trying to connect to romulus. Remus is accessed in precisely the same way.

Type the following in the terminal window that you got when you started X11:

ssh -Y -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa you@remus.amherst.edu

By you, we mean your Amherst username. Then press the key Return or Enter to submit it for processing.

You will be asked for your Amherst College password, but note that you won’t see any ●●●●● as you type it in. Press Return or Enter again.

That will give you an initial terminal session on romulus. See the Unix general information page for more information on what you can do in the window.

Once you have your first terminal window to the Unix server...

Create another terminal window that’s already logged in to the Unix server with the command

In the new white window, you can begin to issue Unix commands that will open a graphical version of the software on your local computer. Here are some examples:

emacs Whatever.java &
matlab &
xeyes &
gnome-terminal &

The emacs command runs the editor, matlab is a data analysis program, xeyes is a cool little graphical application, and the gnome-terminal command opens an extra terminal window. The ampersand tells the terminal window that you would like to run the program "in the background," meaning that you can immediately issue more commands in the terminal window.

You should note that if you use the Applications menu of the X11 application and select Terminal, you'll get a new window in which you can issue commands to the Mac. You can use the SSH command in that window to make an additional connection to one of the Unix machines.

You can work on the client machine, too.

It's possible, of course, to switch between running Unix programs and using applications directly on your client machine. If you happen to close all of your terminal windows to your Unix machine, you can create a new terminal connection without closing and reopening the X windows application. See the Mac page for more information.

When you're done with your Unix session...

Simply exit each of your Unix applications, for example by using the Exit menu item in Unix or by typing exit in the terminal windows. You might get a complaint in a terminal window if you try to exit before the programs running in the background, i.e. the ones started with &, have been closed. You can then close X windows application.

If you're off-campus...

If you do use X windows, you may find it advantageous to run emacs, our text editor, directly within a terminal window. By avoiding using a separate window for emacs, you may find the editor to be a bit more responsive. The downside is that you'll need to use special emacs keycodes to do things within the window. The emacs tutorial will tell you more about the codes. Don't worry too much about trying this out right away, but it's worth remembering that there is a way to get more sprightly performance if you need it. To run emacs in the terminal window, issue the command

emacs -nw Whatever.java &

in a terminal window for a Unix machine.

Questions or suggestions on this page?

Send email to jerager or talk to any of the computer science faculty.