ESP-r & Essential Unix commands


Unix and/ or Linux, like all operating systems, provide facilities for moving around in its folder structure, manipulating files, searching for text, archiving work, accessing the internet and your colleagues models. Both offer security and robustness as well as a number of useful utilities for the simulation user.

Unix offers both graphical and command line facilities. Of the hundreds of possible options (you might explore UNIXhelp for Users, most simulation users will find that knowledge of a dozen commands is sufficient for most of their work.

 command   example                  description
 __________________________________________________________
 cd        cd /usr/esru/esp-r       Change folder to the
                                    main esp-r.
           cd ~paul/test            Change to  `user'  paul
                                    folder test.
           cd ../                   Change   to   folder
                                    about this one (parent).

 ls        ls test                  List the file names  in
                                    the folder test.
           ls -l test               List verbosely the files
                                    in test.

 pwd       pwd                      Print the current folder
                                    name.

 mv        mv filea fileb           Rename filea as fileb.
           mv filea ../test/fileb   Move filea up one folder
                                    and  over to test.

 cp        cp filea fileb           Copy filea to fileb.
           cp filea ../test/fileb   Copy filea up one level
                                    and over to the test
                                    folder.

 rm        rm filea                 Remove filea.

 more      more filea               List out filea (pausing
                                    if display is full).
           more zone*               List out all files starting
                                    with  characters zone.

 vi        vi filea                 Edit (default UNIX edi-
                                    tor) the file filea.

 grep      grep "string" file       search a file for a pattern


Moving around in Unix/Linux

Navigation in Unix uses the cd and pwd comands. Using the following folders and files as examples:

/		(root)
/home/jackson		(the home of user jackson)
/home/jackson/project_a		(one of jackson's project folders)
/home/jackson/memos		(one of jackson's document folders)

/usr/esru		(the home of the user esru (administer for esru)
/usr/esru/esp-r/bin		(where esp-r executables live)
/usr/esru/esp-r/training		(where exemplars live)
/usr/esru/esp-r/databases		(where corporate databases live)
/usr/esru/esp-r/climate		(where climate data-sets live)

When you log in you are placed in your own home folder. If you were user jackson and wanted to go into the project_a folder the command would be cd project_a. From the project_a folder you could shift to the memos folder by giving the command cd ../memos. The .. is short for "go to the parent folder".

If you get lost you can give the pwd command and to return to your home folder give the command cd followed by a carrage return.


Copying files:

If in the memo folder there was a file (say fax_121199) and you wanted to use this as a basis for a new memo you would issue the following command: cp fax_121199 fax_050400 (the syntax is cp [source[ [destination].

If in the folder /usr/esru/esp-r/databases there was a database which you wished to modify for use in a project you would first shift to your project folder and then copy the relevant file. The command sequence would be:

cd project_a
cp /usr/esru/esp-r/databases/pressc.db1 .

The "." means where I am now. If you wanted to modify the name of the database file as you copied it the command would be:

cp /usr/esru/esp-r/databases/pressc.db1 ./local_pressc.db


Creating folders:

If user jackson was beginning a new project and wanted to create a new folder project_b and then shift into that folder the command sequence would be:

cd
mkdir project_b
cd project_b


Finding out the contents of folders:

If user jackson had a folder called others_papers then the command to find out the files (and the results of that command) would be:

cd others_papers
ls
abdulfrq_q                      iibds_combine.ps.Z
appl_mod_2_hvac.paper.ps.Z      methodology_joe
biot                            moisture.Z
cfd_implementation.ps.Z         onions

A variant of the ls command will show the size and ownership of the files:

ls -l
-rw-r--r--   1 jackson      2454 Feb 17  1998 abdulfrq_q 
-rw-r--r--   1 jackson    114451 Feb 17  1998 appl_mod_2_hvac.paper.ps.Z 
-rw-r--r--   1 jackson     10375 Apr 11  1994 biot 
-rw-rw-rw-   1 jackson      2096 Feb 26  1999 moisture.Z 
drwxr-xr-x   1 jackson      1939 Feb 17  1998 onions 

The meaning of the "-rw-r--r--" is that it is a file which is readable by everyone, but only writable by jackson. The "-rw-rw-rw-" says other can modify the file and the "drwxr-xr-x" is a directory/folder.


Archiving your project files:

Paranoia is useful. To archive a project the command tar is similar in function to the PC zip facility. To create an archive of the folder project_a with the name project_a_040400.tar (040400 being the date) the command would be:

tar cvf project_a_040400.tar project_a

To see what is in this archive give the command:

tar tvf project_a_040400.tar

To extract the file README.txt from the archive give the command:

tar xvf project_a_040400.tar project_a/README.txt


Saving space:

To save space use either the compress [file name] in UNIX or gzip [file name] in Linux. These modify the file name, adding a .Z or .gz to the end of the file.

To expand the file the commands are uncompress [file name] or gunzip [file name]