Computer Science

Advice for Mac Users

Submitted on Thursday, 1/23/2014, at 10:21 AM

This page has information for students and others who want to use Macintosh computers to access Unix systems or to do Java programming at Amherst.  Topics addressed below include:

  • Using X Windows 
  • Copying files to and from a Unix server
  • Creating aliases on a Mac
  • Doing Java programming directly on a Mac

 

X11

General information on the use of X windows appears at

https://cms.amherst.edu/academiclife/departments/computer_science/computing/xwindows

You should read and understand that page before continuing here.  If you are working from off-campus or need to use Mathematica, you should consider using NX instead of X windows to access our Unix systems.

The X windows application on Macs is X11. It is usually located in the Utilities folder, which is within the Applications folder. It is installed on all of the computer center Macs. If you start the application, it will give you a terminal window in which you can give commands to the Mac itself. (OS X is based on Unix.)

 

Getting X11 on your own Mac

X11 is preinstalled in many versions of OS X.  If you can't find it, you might need to install XQuartz.

Let us know if you have problems getting X11or 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 you@romulus.amherst.edu 

By you, we mean your username. That will give you an initial terminal session on romulus. Within that window, you can type "gnome-terminal" to get an additional windows o romulus. See the general information page for more info on what you can do in the window.

You can always create another terminal window by using the Applications menu of the X11 application and selecting Terminal. Newly created terminal windows allow you to issue commands to the Mac, and you can use the SSH command to make additional connections to the Unix machines.

Copying files to and from your Mac

As mentioned on the page on transferring files, you can use the program Fetch to transfer files to and from your Mac. There's another way too...

Create a terminal window that is connected to the Mac but not to the Unix machine. In other words, don't use SSH in that window. Recall that the Mac is really based on Unix. This means that you can issue "cd" commands within the terminal window to move around your directory structure. Begin by moving to the directory that 1) contains a directory or files that you want to move to the Unix system, or 2) is the place into which you want to move a directory or files.

To copy a whole directory into your current one, use the command

scp -r you@romulus.amherst.edu:dirname .

where dirname is a path name relative to your home directory on romulus, e.g. cs12/lab3. Note the period at the end of the line. Do use it; it means "the current directory". In other words, you're copying from a place on romulus to the current directory on your current machine.

To copy a whole directory the other direction, use

scp -r theDir you@romulus.amherst.edu:dirname

This copies theDir into dirname. Again, dirname should be a (potential long) directory name that is relative to your home directory on the Unix system.

To copy a single file to your Mac, use something like

scp you@romulus.amherst.edu:cs12/lab3/filename .

To go the other way, use

scp filename you@romulus.amherst.edu:cs12/lab3

To copy multiple files to your Mac, use something like

scp 'you@romulus.amherst.edu:cs12/lab3/*.java' .

To go the other way, use

scp *.java you@romulus.amherst.edu:cs12/lab3

Creating shortcuts

It's possible to set up an alias so that you can simply type "romulus" in a terminal window to make an SSH connection to romulus. Here's what's involved.

Determine which "shell" you are using on the Mac

Issue the command

echo $shell

in a terminal window for the Mac. If it says "/bin/tcsh", you can skip the next step.

If necessary, change your shell

Issue the command

chpass -s /bin/tcsh

Edit your .cshrc file

Type the command

emacs ~/.cshrc

Enter the lines

alias romulus ssh -Y you@romulus.amherst.edu
alias remus ssh -Y you@remus.amherst.edu

Then type CTRL-X CTRL-C to save the file. Close your terminal windows and exit the X11 application. Restart the X11 application. You should be able to type "romulus" or "remus" in a Mac terminal window to open a connection to the given machine.

Doing Java programming on the Mac

You can develop Java programs right on the Mac: just type your usual commands in a Mac terminal window but not in an SSH session. You might want to download a flexible version of emacs, called aquamacs, from aquamacs.org.