Open the Terminal app and create a directory for this class:
[ltoma@dover:~]$ pwd /home/ltoma [ltoma@dover:~]$ mkdir CompGeom [ltoma@dover:~]$ cd CompGeom [ltoma@dover:~/CompGeom]$ ls [ltoma@dover:~/CompGeom]$We'll set up a folder for the first C program:
[ltoma@dover:~/CompGeom]$ mkdir hello [ltoma@dover:~/CompGeom]$cd hello
xemacs &The ampercend at the end of the command means that the command is to be run in the background; the shell prompt does not wait for this command to be finished, instead it starts it and comes right back to you (to really understand the difference you might want to start xemacs without the ampercend at the end).
Once you started xemacs you can start typing the first program:
#include < stdio.h > int main() { printf("Hello world!\n"); return 1; }Save this program as "~/CompGeom/hello/hello.c". (The symbol "~" expands in Unix to the name of your home directory).
[ltoma@dover:~/CompGeom]$ cd hello/ [ltoma@dover:~/CompGeom/hello]$ ls hello.c [ltoma@dover:~/CompGeom/hello]$ ls -l total 4 -rw-r--r-- 1 ltoma cs 78 Sep 8 22:51 hello.c [ltoma@dover:~/CompGeom/hello]$Note the file is readable and writeable to the owner, and readable only to everybody else. The file is not executable.
gcc hello.cI suggest you use the -g flag to include debugging information (stored in a dsym folder, see below):
gcc -g hello.c
[ltoma@dover:~/CompGeom/hello]$ gcc -g hello.c [ltoma@dover:~/CompGeom/hello]$ ls -l total 12 -rwxrwxr-x 1 ltoma cs 7641 Sep 9 12:23 a.out -rw-r--r-- 1 ltoma cs 78 Sep 8 22:51 hello.c [ltoma@dover:~/CompGeom/hello]$ [ltoma@dover:~/CompGeom/hello]$ ./a.out hello, world [ltoma@dover:~/CompGeom/hello]$
a.out is the default name for the executable. To specify a different name use option "-o":
[ltoma@dover:~/CompGeom/hello]$ gcc -g hello.c -o hello [ltoma@dover:~/CompGeom/hello]$ ./hello hello, world [ltoma@dover:~/CompGeom/hello]$ ls a.out hello hello.c [ltoma@dover:~/CompGeom/hello]$ rm a.out [ltoma@dover:~/CompGeom/hello]$I suggest you also use option "-Wall" to generate all warnings:
[ltoma@dover:~/CompGeom/hello]$ gcc -g -Wall hello.c -o hello [ltoma@dover:~/CompGeom/hello]$
To connect to Bowdoin server dover, find the 'Terminal' application and double-click on it to open a terminal. Then type:
bid19628:~ ltoma$ ssh -X dover.bowdoin.eduNote that we use flag '-X' to enable X11 (windows) forwarding. This will come handy for e.g. if you want to run any application that will open windows remotely on the machine where you sit. Just to test that '-X' worked you could for e.g. run xterm & and expect to see a new terminal window pop up.
Now you are on dover. You can do anything you would on your laptop. You can access dover from anywhere on campus, and your home directory is automatically backed up.
If you prefer to work locally on your laptop: open a terminal and cd to the place where you have your folder that you want to copy over.
To copy to dover you'll use use 'scp' (stands for secure copy).
bid19628:hello ltoma$ scp hello.c ltoma@dover.bowdoin.edu:~/CompGeom/hello/ ltoma@dover.bowdoin.edu's password: hello.c 100% 78 0.1KB/s 00:00 bid19628:hello ltoma$