European Molecular
Biology Computing Network - Biocomputing Tutorials DNA Sequence Analysis UNIX Basics

UNIX Basics


Table of Contents

UNIX Commands
Text Files
Directories
X-Windows


Staden, GCG, and EGCG programmes can be run in many different ways. They can be given as text commands in a UNIX session, they can be accessed through a graphical front-end (XStaden, WPI, and GDE), and E/GCG is available via a WWW forms system developed at the Belgian EMBNet node.

While these systems look and feel very different, they all run the DNA sequence analysis programmes by passing the simple text commands to the computer. Thus, it is important to have an understanding of what the text commands look like and how their different options can affect the programmes. To start, we will look at the few UNIX commands that you need to know in order to run the Staden, GCG, and EGCG programs and to look at their results.


UNIX Commands

UNIX commands are entered at the prompt> and delivered to the system with the <RETURN> key.

UNIX commands have a syntax, just like any language; there is a correct order for the words in a command, and MANY incorrect orders. Mix up the order, and UNIX is unlikely to be clever enough to understand what you want it to do! The most general form of UNIX command syntax is

The command is WHAT you want to do, the -flags help refine the command, saying HOW you want it done, and the arguments tell the OBJECT of the command - the things to be acted upon.

UNIX expects all of its commands to be lower-case, though flags and arguments may be a mixture of cases. Remember, UNIX is case-sensitive!

As a trivial example, suppose you wanted to translate the following English request

into UNIX. The translation might look something like In fact, given the absence of vowels and longer words from most UNIX commands and flags, the actual command is more likely to be where rk is short for rake, -f is short for fast (=quickly), and -n is short for now (=today).

For a genuine example of a UNIX command, consider

Here, ls is short for list, -l is short for long (=all details), and -a is short for all (=all files, even the hidden ones). Dirname is the name of the directory of files for which you want the listing.

For a partial listing of useful UNIX commands, complete with correct syntax and examples, check our Useful UNIX commands page. If the command you want isn't there, try

UNIX may have the command, but condensed or renamed beyond recognition!

Finally, when using E/GCG commands in UNIX, there is one important "feature" for the arguments; the case you use for the names of database entries is unimportant, but all filenames must be in lower case.


Text files

Data on computers (text, programmes, sequences etc.) is held in blocks of information called 'files'.

Different files have different names and/or different locations - and there is a convention that filenames end with a three letter extension that indicates the type of data held in the file, e.g., .txt for text, .seq for sequences, .pep for peptides, .dat for generic data, etc.

Files can be created, deleted, altered, overwritten, moved around, copied, renamed, printed out to a screen or a printer, searched, compared, sorted, counted and transferred over the network to computers on other sites.

Some UNIX commands for file management:

touch filename   - create a file [ holding no information! ]

pico filename   - edit the file using the pico editor [ use <CTRL> X to exit ]

cp filename newfilename   - copy a file to a new file [ retains the old file ]

mv filename newfilename   - move (rename) a file to a new file [ deletes the old file ]

cat filename   - concatenate (print) a files contents to the screen

more filename   - print a files contents to the screen, one page at a time [ use <SPACE> to see the next page ]

cat filename1 filename2 > filename3   - concatenate (print) the contents of the first two files into the third

rm filename   - remove (delete) the file

 

Exercise DNA Analysis - UNIX 1: create and manage files
Create a file named easyunix.txt

prompt> touch easyunix.txt

Edit the file and enter "UNIX is EASY!". Exit by typing <CTRL> X and save the changes. (NB: you may use any UNIX text editor you like - pico is probably the simplest.)

prompt> pico easyunix.txt

Print easyunix.txt to the screen.

prompt> more easyunix.txt

Copy easyunix.txt to the file opinion.txt (How would you do this with cat? Hint!)

prompt> cp easyunix.txt opinion.txt

Rename easyunix.txt to unixcmds.txt

prompt> mv easyunix.txt unixcmds.txt

Edit the file unixcmds.txt . Move down the screen with the arrow cursor keys and type what you now know about UNIX. Exit and save the new changes.

prompt> pico unixcmds.txt

Print unixcmds.txt to the screen to see how clever you have become.

prompt> more unixcmds.txt

Delete opinion.txt.

prompt> rm opinion.txt

Once a file has been created, can you add information to it without using an editor? (Hint!)


Directories

A directory is a group of files or other directories. A directory within another is often called a sub-directory, to reflect this hierarchical organisation.

Directories can be created, copied, deleted, renamed, searched and transferred over the network to computers on other sites. Files can be moved between or copied among specified directories.

You work in one directory at a time. This is known as the present working directory. The directory you begin with when you login is your home directory. You can easily return to your home directory from any other directory by giving the UNIX command "cd" with no argument.

Some UNIX commands for directory management:

cd dirname   - change to the directory named dirname

cd ..   - change to the directory above the present one [ ".." = up ]

cd   - change to your home directory [ the default argument for cd is your home directory ]

ls   - list the files in the present working directory

ls -l   - a file list that is longer, more detailed

mkdir subdirname   - make (create) a new sub-directory in the present directory

rmdir subdirname   - remove (delete) a sub-directory in the present directory

mv filename dirname   - move a file into a sub-directory

 

Exercise DNA Analysis - UNIX 2: create and manage directories
Create a sub-directory named Unixinfo

prompt> mkdir Unixinfo

Switch your present working directory to the new sub-directory

prompt> cd Unixinfo

Check to see you are there

prompt> pwd

Move a file from the directory above into your new present working directory (".." is a short form for the directory above, and "." is a short form for the present directory)

prompt> cp ../unixcmds.txt .

Has the file moved? It should occur in the second list (";" separates the two list commands)

prompt> ls -l .. ; ls -l

Get back to your home directory

prompt> cd


X-Windows

X-Windows is the name of the standard graphical front-end of the UNIX operating system. An X-Windows programme usually supports use of a pointing & selecting device - a mouse - and displays colours. We will be using X-Windows versions of some of the DNA analysis programmes in this tutorial, so some X-Windows basics are necessary. (NB: Running X-Windows isn't required for the tutorial, only recommended!)

Most computer mice have two or three buttons - generally when selecting text or clicking on a menu item, etc., the LEFT BUTTON is used.

X-Windows can be expanded to fill the full screen (or restored to their original size) by clicking on a button, usually in top left or right corner. Another button, also usually in the top left or right corner, causes an X-Window to shrink down to an icon. X-Window icons may be stored along the bottom or to one side of the screen. Icons can be re-opened into X-Windows by double clicking on them.

X-Windows can be dragged around the screen by pressing the left button when the pointer is on an edge of the window, and then moving the mouse. X-Windows can also grow and shrink under mouse movement control when the pointer is activated in a window corner.

You can only enter text (type things) in an X-Window when the pointer is over that window.

Exercise DNA Analysis - UNIX 3: X-Windows
Create a new X-Window interactive session

prompt> mxterm -n Practice &

(NB 1: the "-n Practice" flag names the new mxterm X-Window, and the "&" symbol runs this programme - mxterm - as a background process)
(NB 2: this command may not work! 1 )

Switch to the new Practice session by moving the mouse pointer over it and clicking once, if necessary. Print a text file to the screen, and highlight some of the text by clicking the left mouse button, dragging the mouse, and releasing the button. Type the command

prompt> cat > nonsense.txt

This command should appear at the UNIX prompt, irrespective of where the mouse pointer lies, and won't change the text you have highlighted. Now click the MIDDLE mouse button. (Two button mouse? Click both buttons at once.) The text you just highlighted should reappear on screen but below the command line; this text is now being stored in the file named nonsense.txt . Type <CTRL> D to stop entering text into nonsense.txt . The UNIX prompt will return.

(NB: This is a quick way to grab short pieces of text from a file and store them in another. To add more text to nonsense.txt , use "cat >> nonsense.txt" )

Use the mouse to re-size and/or move the mxterm X-Window. When finished with your mxterm Practice session, type exit at the prompt.

prompt> exit


1 If the command "mxterm -n Practice &" doesn't work ...

 


Table of Contents Please continue with Part 2 - DNA Sequence Assembly with Staden - 1   Sequence Assembly 1 (under construction!)

Instead, continue with Part 4 - DNA Sequence Editing and Exchange   Sequence Editing & Exchange



Comments? Questions? Accolades?
Please send them to David Featherston   ( dwf@biobase.dk )
Updated on Tuesday, 19 November, 1996
Copyright © 1995-1996 by Gary Williams, Peter Woollard, & David W. Featherston