Summary: This module provides a description of UNIX for biologists who are not familiar with the UNIX environment.
UNIX is an operating system which like all other operating systems act as a master of ceremonies since their jobs are to accept and dispatch user commands and directing the system response to the appropriate place. UNIX is referred to as a multi-user, multitasking operating system, since multi users may each execute multiple commands simultaneously.
Note: There is an operating system called Linux. It is a free open-source operating system within the UNIX family. The difference between UNIX and Linux are almost invisible on a user-level. There are lots of commands transparent between the two systems. So you can learn about Linux from this session.
There are three main parts of the UNIX operating systems:
![]() |
The UNIX operating system is built around the concept of a filesystem which is used to store all of the information at constitutes the long term state of the system.
Every item stored in a filesystem belongs to one of four types:
The UNIX filesystem is laid out as a hierarchical tree structure which is anchored at a special top level directory know as the rood.
![]() |
Directory Typical Contents
/ The “root” directory
/bin Essential low-level system utilities
/usr/bin Higher level system
/bin and /sbin Hold system binaries. These are different
from the program in /usr/bin in that they
are design as the basic program to run the
the system.
/etc hold system-wide configuration files.
/var hold log file, cache, and spool directories
/tmp is meant for temporary storage by users.
/home is a typical location of users.
SSH or text-based (TTY) terminal:
When you connect to a UNIX computer remotely (client computer) or when you login locally using terminal, you will see the prompt:
login:
At this prompt, type in your username and hit enter or return key. You should be prompted for password:
login: bobcat
password: your password won’t display on the screen as you type it in
If your username or password is incorrect, you will get an appropriate message from the computer and you will be presented with the login prompt again. Otherwise, you should be presented with a shell prompt which looks something like this:
either $ or % or bobcat@computer’s name:
e.g bobcat@go:/>
![]() |
![]() |
When you are ready to leave, you can log out by typing one of many commands:
bobcat@go:>exit
bobcat@go:>logout
Basic form is
command name option(s) argument(s)
date - find out the date and time
ls –l - list a directory with more information
mv old_data new_data - Moving a file and renaming it
Typical UNIX Key commands
ls List file – list files and sub directories in
the current directory
mkdir Make directory
e.g :/>mkdir music
cd Change directory
pwd Print working directory
rm Remove (delete) a file
rmdir Remove (delete) a directory
chmod Change the permission of a file or dir.
man Manual the help files
cat Concatenate files or display them
more/less Display files by screen
mv Move or rename files or directories
head Show the first few lines of a file
tail Show the last few lines of a file
cmp Compare two files, byte by byte.
diff Compare to file, line by line.
grep Matching a pattern
e.g :>grep ‘txt’ hello.txt
gzip Reduces the size of one or more files
gunzip Decompress file. It is equivalent gzip –d.
tar Archive utility
e.g :> tar cvf /home/bill <-- Creating
e.g :> tar xvf /home/jack <--Extracting
ssh Remort login program
![]() |
Useful Shortcuts
The UNIX shell provides very nice shortcuts. These make your life easier when working in the terminal.
History: The shell remembers all the commands you typed. You can scroll through your last commands with the arrow keys (Up and Down). Additionally, you can type history to list all commands you have been used.
bobcat@go:> history |grep -i keywordPipes: it let you use the output of one command as the input of another one.
bobcat@go:> ls –l | sort
bobcat@go:> history | more
Every file or directory in a UNIX file system has three types of permission that define whether certain actions can be carried out.
read(r): A user who has read permission for a file may look at its contents or make a copy of it. For directory, read permission enables a users to find out what file are in that directory.write(w): A user who has write permission for a file can alter or remove the contents of that file. For directory, the user can create and delete file in that directory.execute(x): A user who has execute permission for a file can execute the contents of that file to be executed. For directory, execute permission allows a user to change to that directory.For each file and directory, the read, write, and execute permission may be set separately for each of the following classes of users:
User(u): The user who owns the file or directory.Group(g): Several users purposely lumped together so that they can share access to each other’s files.Other(o): The remainder of the authorized users of the systemsAlternatively, specify permission by three-digit sequence. The first digit designates owner permission; the second, group permission; and the third, other permission. Permissions are calculated by adding the following octal values:
4 Read2 Write1 ExecuteDisplay information about files and directories by using ls command with –l option.
bobcat@go> ls –l myfile.java
-rw-r--r-- 1 bobcat users 198 2006-01-25 18:27 myfile.java
bobcat@go:> ls –l
-rw-rw-rw 1 bobcat users 198 2006-01-25 18:27 myfile.java
(to allow read and write permission for all users
Change group(chgrp): can be used to change the group that a file or directory belong to.
bobcat@go:> chgrp admin myfile.java
bobcat@go:> ls –l myfile.java
-rw-rw-rw 1 bobcat admin 198 2006-01-25 19:27 myfile.java
Vi - Text Editor
bobcat@go:> vi filename <-- vi myfile.java
It will put filename into a buffer, and display the file on the screen. It the file is larger than the screen can display, the screen will act as a window into the file. At the beginning of a session, the screen will display the first part of the file.
If filename does not exist, vi will create it.
bobcat@go:> vi filename <-- start the editorGet in and out of vi
vi [filename] <-- Enter vi
[esc]:wq <-- leave the editor and save the file
[esc]:q! <-- leave the editor without save the file
![]() |
Insert text mode
Hit [esc] key to return to common mode
i <-- for insert text to the left cursora <-- use to insert(append) text to the right cursorA <-- insert(append) text to the end of current lineo <-- open new line for inserting text below cursor lineO <-- open a new line for inserting text above cursor lineDeleting and changing text mode
Hit [esc] key to return to common mode
x <-- deletes one character under cursor5x <-- another way to repeat the deletion command. dw <-- deletes word under and to right of cursor. dd <-- deletes the cursor line.D <-- deletes from cursor to the end of line. cw <-- changes word under and to right cursor to new text. cc <-- changes current line to new text you enter. s <-- substitutes character under cursor with new text. S <-- substitutes current line with new text you enter. r <-- replace character under cursor with new character.. Command to join two lines search keyword
Hit [esc] key to return to common mode
J <-- joins next line to the end of the cursor./keyword or /string <-- searches forward through text.Write a UNIX command line to do each of the following:
Show the full pathname of the current directory:
...
Show the online documentation for the “sort” command:
...
Show how to allow the following access to the existing file ‘BIS141.txt’: all permissions for you, only read and write permissions for members of your group, and only read permission for other users:
...
Rename the existing file, “UCMerced.txt”, to the new name, “UCM.text”:
...
Copy the file ‘genome’ from your current directory to /usr/local/access:
...
Delete all files in the directory /home/ucmerced/backup:
soon
Delete the directory /home/ucm/backup:
...
Show to change a working directory to /home/ucmerced/genome:
...
Show the name, sizes, dates of all files in the current directory:
...
Show the content of a zipped file, ‘ucmerced.zip’:
...
Show the current date and time:
...
Show how to logout from the current Unix/Linux session:
...
Answer the next questions about the text editor, vi.
Write ONE command to initiate an insert mode:
i
Write command(s) to delete a word:
...
Write ONE command to save modifications and leave from the vi session:
...