|
Background
- What is an Operating System?
- What is Unix?
- What is a shell?
- What are X-windows and X11 emulators?
- Why use Unix at all?
Getting Started with molbiol
- CBRG accounts - molbiol
- Using SSH on PC's or SSH on macs to connect to molbiol
- Choosing a good password - (Chicago Univ.)
Unix Commands
- Unix Commands
- What are Unix option (flags)
- How do I know what command to use?
- How do I find out what a command does?
- What happens if I dont know the name of the command?
- Saving time on the command line
Files and Directories
- Files and Filenames
- Paths and Pathnames
- Whats inside a file? How do I see it?
- Removing files
- Removing directories
- Renaming files and directories
- Editing text files
External Links
- UNIXhelp (at Edinburgh)
What is an Operating System?
An operating system controls the computer hardware
(the circuit boards, disks, RAM and chips) so that when you enter commands useful things
happen. For example, when you press the key a you expect the letter
"a" to appear on the screen. For this to happen your key-press is converted into
an electrical signal, this is transferred to the motherboard, then to the main processor
which determines which key was pressed, it then tell the display adapter to show that
letter. Similarly when you delete a file, you are actually instructing the machine to
physically locate the area of disk where your file is located and then to send the
electrical signals that are written to the magnetic disk and which mark the file as
deleted.
top | back
What is Unix?
Unix is a commonly used operating system. Unix has
evolved since it was first created in the early 70s. This has lead to the
development of a large number of programs which, while strictly speaking, are not part of
"Unix", but come bundled with the operating system so frequently you would
expect to find them on all machines that are running Unix. It is this bundled software
that makes Unix so popular and powerful. This does not mean that the software was written
to be easy to use, but it does allow us to perform very complicated tasks. Unfortunately
as so many people have contributed, the look and feel of Unix may not always appear
consistent or logical.
top | back
What is a shell?
When Unix was first invented it was felt that
someone should invent a shell to protect the users from its raw edges. Shells listen for
your commands and then converts these into real Unix on your behalf, so when you curse Unix
you are being unfair, as it is almost always the shell that is being obtuse. The important
point is that there are many different shells, the borne shell (sh), the C-shell (csh),
the korne-shell (ksh), the t-shell (tcsh). We use the bash-shell as our standard shell on orac.
top | back
What are X-windows and X11 emulators?
A graphical user interface that is designed for UNIX systems.
This system allows programs to be used that have pull down menus, buttons, etc. Using X-windows
applications on a Unix server is akin to using Microsoft Windows applications (with a mouse)
on a PC, though with the greater resources and the ready-provided service of a large central computer.
The current version is X Window System, Version 11 (better known as X11). To use any X11 program
you only need to load one piece of software, called a X11 emulator, onto your local computer.
For further details, see: connecting using a PC or
connecting using a mac.
top | back
Why use Unix at all?
Although Unix has a reputation for being complex and unfriendly, it has a lot of advantages which is why it is
still in use so much today. It may take you a little while to become familiar with Unix
but it will be time well spent as the majority of bioinformatics resources run on Unix
systems.
So, what are the advantages? Why hasn't it been supereceded by an operating system that is more user-friendly?
- Unix is a multi-user system: This means that more than one user at any one time can access the facilities of
the host system (e.g. molbiol). It also means that there can be a large number of
resources and facilities (e.g. software and databases) on one shared machine that you could
not replicate on a PC or Mac.
- Unix is very flexible: Unix does not force you to work behind a defined interface of menus, windows and
a mouse. You can use Unix with windows and a mouse but Unix also gives you many more choices than a
software designer can build into a set of menus.
- Someone else does the "house-keeping": There is a lot of "house-keeping" involved
in ensuring a computer system runs "correctly".
With Unix you do not need to worry about backing up your files or making sure you have the
most recent version of embl to search. System administrators do all that for you. They look after the machine and keep
everything running smoothly (most of the time!). They install new software, check how
much space you are using, and in addition they are there to help you with specific
problems. If you would like to know about some software you can ask them; if you cannot
print, they will try and solve the problem; if you deleted some files by mistake, tell
them immediately and they will try and restore the files.
top | back
Unix Commands
Unix is a command line environment,
which means that primarily you have to enter commands on the keyboard instead of using
point-and-click mouse. (Having said that, these days, much Unix software has been
developed to have an X-windows interface so that
you do have windows with pull down menus and you can point-and-click instead of typing
commands).
Unix will only do something if you tell it to by giving it a command.
The basic structure of a Unix command is:
command [options...] [arguments...]
top | back
What are Unix options (flags)?
options (also called flags) are generally single
characters which in some way modify the action of the command. There may be no options or
there may be several acting on the same command.
Options are preceded by a hyphen character ( - ) but there is no consistent rule among
Unix commands as to how options should be grouped. Some commands allow a list of options
with just a single hyphen at the beginning of the list (e.g. -apfg). Other commands require
that each option is introduced by its own hyphen (e.g. -a -p -f -g)
Some options allow a value, often a filename, to be given following the option. Again,
there is no consistent manner in which this is allowed, with some options requiring the
value to be placed immediately following the option letter, while others expecting a space
between the option letter and the value.
Unix is case-sensitive throughout. The exact combination of upper and lower case letters used in a
command, option or filename is important. For example, the options -p and -P in
the same command will have different meanings.
top | back
How do I know what command to use?
There are a few core Unix commands that are used
routinely - after a while you find that these come as second nature and you no longer have
to think "Whats the command for that?". These common commands involve moving
around your account, creating, copying and deleting files and directories. It is a good
idea for the novice Unix user to keep a list of common commands at hand until you have
learnt them.
top | back
How do I find out what a command does?
There are man pages associated with (almost) every Unix command (man stands for manual)
To read a man page simply type man command e.g. to learn about the Unix command "ls", we could type:
man ls
This will bring up all sorts of information associated
with that command. Much of it may not be of any interest to you but it will tell you what
the command does, what flags are available and will give an example (ususally near the
bottom)
If you find that the man pages scroll up so you cannot
read them then remember to use the pipe symbol ("|") and "pipe through less" - this will allow
you to scroll with the up-down arrows keys e.g.
man ls | less
top | back
What happens if I dont know the name of the command?
Using the man pages is all very well when you know
the name of the Unix command and want to find out what it does. What happens when you know
what you want to do but dont know the name of the Unix command to use?
You can use:
man -k keyword
It is a good idea to pipe this command through less:
man -k keyword | less
If you cannot find the Unix command you
are after or do not know what flags to put on to make it do what you want then please
contact CBRG
top | back
Saving time on the command line
There are many tricks to saving time on
the command line and cutting down the number of keystrokes. Here are just a few.
Moving around:
cd | move to home directory |
cd .. | move up one directory |
cd ../.. | move up two directories |
cd - | move back to the directory I was just in |
cd ../another_dir | move up one directory and then down to another_dir |
cd ~/another_dir | move to home directory and the down to another_dir |
Use the Tab button to fill in filenames
When typing on the command line you can use the keyboard tab button to fill in the rest of a
filename for you. Examples:
-
If I had a file called humamph1.tfa and I had no other
file beginning with "hum" in the directory I am in presently, I can type:
less hum
and then press the tab button. As there are no other files beginning with
"hum" the machine knows the name of the rest of the filename and fills it in... giving me:
less humamph1.tfa
-
If I have two files called humamph1.tfa and humamph2.tfa. If I type:
less hum
and press the tab button, the machine will fill in up to the point that it knows e.g.
less humamph
It then stops because it does not know whether I want 1 or 2. If I then type 2 and press tab
again it will finish off the file name for me....
less humamph2.tfa
top | back
Files and Filenames
Unix does not understand spaces, dots or slashes in filenames! If
you have filenames with spaces in them, then you are advised to change the name of the
file to something without spaces. To do this, you need to use the mv command, and surround
your filename containing spaces with quotation marks. e.g.
mv "a filename with spaces" a_filename_without_spaces
top | back
Files that start with a dot
These files are usually special files and are hidden, i.e. they are not listed
when you use the ls command. To see hidden files in your directory use
the -a flag with the ls command (ls -a). These files
are usually important and it is a good idea to leave these files alone
unless you are sure of what you are doing. If you have any doubt please
contact CBRG before editing or deleting any of these
dot files. Examples of dot files include:
- .forward
- .profile
- .procmailrc
- .gaprc
top | back
Paths and Pathnames
You can imagine a Unix machine as a large file folder containing other folders and
documents. Analogous to real filing systems, these folders can contain both documents and other
folders. The Unix word for folder is "directory" and the term for document is
"file".
A diagram of they way files are stored on a Unix system looks like a tree.
The bottom of the tree is called root and is represented by a forward slash (/)
For the machine to be able to find different documents (files) or directories (file
folders), it sometimes has to be told explicitly where they are with reference to the bottom
of the tree. i.e. root.
So, for example, the full path to the directory called "sue" is
/ usr users user1
sue
That is, first you start at root (/), then go through the directory usr, then the
directory users, then the directory user1, and then you find the directory sue.
Unix doesn't like spaces though, so to describe this full path on a Unix machine, you
separate each term with a forward slash (/). So, the full path to "sue" becomes:
/usr/users/user1/sue
If you don't know the full path to where you are in your account, just type pwd
(Present Working Directory) on the command line. This returns the full path to the directory from
which you typed the command.
top | back
What's inside a file? How do I see it?
There are various ways to view a text file. To view the file contents page
by page, use the command less e.g.
less filename.txt
To view graphical files, except for postscript files, try
using the command display e.g.
display file.jpeg
To view a postscript file, try the command ghostview e.g.
ghostview filename.ps
top | back
Removing files
To remove a file, you need to use the rm (Remove) command. For example:
rm filename
You will then be prompted to see if you really want to delete this file.
To delete a number of files that all have something in common, you can employ "wildcards".
For example, to delete all files that end in the letters "seq", you could type:
rm *seq
You will then be prompted for each file individually to see if you really want to delete it.
If you have a large number of files to delete, and you are SURE you want to delete
them, you can use a backslash before the rm command. This removes the safety feature of
being prompted about each file to be deleted. Be careful using this option!! e.g.
\rm *seq
top | back
Removing directories
If you wish to remove a directory that contains no files in it, you can use the rmdir command e.g.
rmdir directoryname
If you wish to remove a directory containing files, and remove all files within that
directory, you must use the -rf flag with the rm command e.g.
rm -rf directoryname
You will then be presented with the name of each file inside the directory, and asked
to confirm you wish to delete it.
This can be quite tedious. So if you are really SURE you wish to delete this directory
and its contents, you can forgo this safetly mechanism by preceding the command with a
backslash. Be careful using this option!! e.g.
\rm -rf directoryname
top | back
Renaming files and directories
This is done using the command mv (Move):
mv old_filename new_filename
mv old_directoryname new_directoryname
If the file called "new_filename" already exists, you will be asked whether you really
want to overwrite it.
top | back
Editing text files
If you need to edit a text file, there are a number of text editors on our system. A user
friendly, GraphicalUserInterface-based editor is nedit. Type:
nedit
and type some text in the window that appears. You can cut and paste this text and you can
save it in whichever folder you like (under your account space) by using the save as option
from the file drop down menu. This editor also lets you open any other plain text files for editing. It
does not open word documents, as these are full of binary code. We also have other text editors,
such as pico (simple GUI with commands), vi (entirly command line driven),
and xemacs (probably best left to programmers).
top | back
|