next up previous contents
Next: 11.2 Text Editors: emacs, Up: 11. Introduction to Unix Previous: 11. Introduction to Unix   Contents

11.1 Unix

Now that you are a proficient MATLAB programmer, you are ready to start writing programs in FORTRAN90/95. The purpose of this chapter is to get you started learning the Unix operating system (and it's many free incarnations known as GNU/Linux) because most programming in FORTRAN90/95 C, C++, etc., is done in this operating system (OS). Moreover, most scientific (especially computational or simulation-based) research in the physical sciences relies on computers running the Unix/Linux operating system, not Windows. The Unix operating system is a completely different computing paradigm than Windows-type OS's. So it takes some getting used to. The most noticeable difference between a Windows-based platform and a Unix one is that Unix platforms are designed for and intended to be used mainly via remote login by multiple and simultaneous users. Consequently, users interact with the computer in different way (mainly by typing text commands at a command line). The Unix system we will use for this course is dana. You can also use the physics department's main server Bohr if you already have an account on that machine, but for this part of the tutorial, use your Dana account even if you normally would be using Bohr. The following instructions will guide you through the login process and give you a very basic introduction to using the Unix operating system.
  1. Login To login to your dana account, you must telnet or ssh into it from your current PC. An ssh program is available on the PCs in the Arts & and Sciences Computer Lab by clicking on Programs$\rightarrow$SSH Secure Shell$\rightarrow$DANA Secure Shell Client. When prompted to ``accept the new host'' Click Accept/Yes then type in your password.
  2. Command line It's likely that you will now be confronted with an annoying text-based menu system--follow the directions to turn it off, logout, and then login again. You should now be confronted with a bunch of text and the last line should look something like dana%. This is the prompt or the command line. To interact with the computer, you will enter commands at the command line. (If you are familiar with DOS, there are many similarities.)
  3. Your files Your files in your dana account can be listed by typing ls (for ``list''?). Try it and you will see the files and folders (a.k.a. directories) in your home directory. If you have been storing files on your Z drive, you will probably notice that they are contained on dana in a folder called PC. Your Z drive is, in fact, the PC folder in your home directory on your dana account. Any files that you create in the PC folder in your dana account, will be visible from your Z drive as well. Most unix commands can be modified by giving additional options and arguments. For example try, ls -l to list your files again but with more details (``l'' for ``long'' listing?). List all your files/directories that start with the letter ``A'' using wildcards. Try, ls A*. To find all the files ending in ``m'', type ls *m. The character ``*'' is a wildcard that stands for any number of arbitrary characters.
  4. Backspace At this point, you're probably annoyed that the Backspace key ``doesn't work.'' This can be remedied by typing stty erase at the command prompt, then inserting a space and pressing the Backspace key (which probably makes a ^H appear), and then hitting return. Now when you use the Backspace key, it should do what you expect.
  5. Basic commands Practice some of the basic Unix commands by referring to the Basic Unix page on NAU's IT page (given above) and do the following.
    1. Make a new directory in your home directory using the mkdir command.
    2. Enter the new directory using the cd command, like this: cd dirname where dirname is the name of the new directory.
    3. Create a new, empty file in this directory using touch filename. Use ls to verify that the new file was created.
    4. Make a second copy of the file using cp file1 file2. Again, use ls to make sure it worked.
    5. Rename one of the files using mv oldname newname. Then use ls again.
    6. Now remove the files using rm.
    7. Go up one directory (back to your home directory in this case) using cd ... (cd with no arguments will always take you back to your home directory from anywhere in your directory tree.)
    8. When you are not sure what directory your are in, type pwd (print working directory).
    9. Use logout or exit to logout when your are finished.

Table 11.1: Common Unix commands with examples of additional options and arguments
Command examples Description
ls list files in the current directory
ls -l ``long'' list files in current directory
ls -a list all files, including ``hidden'' files
ls -alt list all files in chronological order
mv oldname newname rename a file called oldname to newname
mv filename dirname move a file called filename inside the directory called dirname
cd dirname change to the directory called dirname
cd dirname1/dirame2/ move to the directory dirname2 inside of the dirname1 directory
cd .. Move up one directory in the directory tree
cd Move back to your home directory
cd ~/dirname1 Change to the directory dirname1 starting at your home directory.
  ~ is a shortcut for you home directory. To see the ``full path''
  of your home directory, type cd and then pwd.
pwd show the current directory (print working directory)
rm filename delete the file named filename
rm * remove (delete) all the files in the current directory
mkdir newdir make a new directory named newdir
rmdir dirname delete a directory named dirname
logout or exit logout of the current shell

Insert day 2 of unix intro here
next up previous contents
Next: 11.2 Text Editors: emacs, Up: 11. Introduction to Unix Previous: 11. Introduction to Unix   Contents
Gus Hart 2005-01-28