By
Dr. David Roster
and Dr. Lydia Ayers
Unix
Unix
is a popular operating system
used worldwide
ITSC uses Unix to store your files and
your email
Even after you graduate from UST, the
company you work for will probably
use Unix for something
Unix
This
presentation introduces some
Unix commands and techniques:
Directories
Files
How to use the man command
Several other useful commands
Directories
When
you first log in to a CCST
machine, you are in your home directory
Directories
are stored in a
tree-like structure
Directories
The
pwd command shows you which
directory you are in
it
lists the exact location of your current
directory within the system
For example, if you log in and type pwd,
you will get a response like this:
/tmp_mnt/homes/layers/
Directories
If
you then go into a subdirectory, such as
one called vinaweb, and then type pwd
again, you will get a response like this:
/tmp_mnt/homes/layers/vinaweb
Directories
The
cd command lets you Change from
one Directory to another
For
example, to change to a directory
called vinaweb, type:
cdvinaweb
If you have gone down into a directory but
now you want to go up out of that
directory, type:
cd..
Directories
For
example:
pwd
/tmp_mnt/homes/layers/vinaweb
cd..
pwd
/tmp_mnt/homes/layers/
Directory Structure
du is
one way to show the directory
structure at any point in a Unix system
du stands
for disk usage
The du command lists all directories at
lower levels than the current directory
It also provides an indication of how much
data is in each of the listed directories
Directory Structure
Type:du
Output:
592labs/lab1
912labs/lab2
939labs/lab3
1261labs/lab4
505labs/lab5
140labs/lab6
213labs/lab7
911lectures/fireworks
70079lectures
Directory Structure
By default the numbers listed for the size of
the data in each directory (the first column
on the previous page) are usually for 512
byte blocks
But most computer users dont measure
things in blocks of 512 bytes
It is more useful to have the numbers
expressed in KB (kilobytes).
use the -k option to do this
Directory Structure
Type:duk
Output:
1184labs/lab1
1824labs/lab2
1878labs/lab3
2521labs/lab4
1009labs/lab5
279labs/lab6
425labs/lab7
1822lectures/fireworks
140158lectures
File Information
Use
ls to list the files in the current
directory
For example:
cdvinaweb
ls
index.htmlvina.jpg
File Information
Type
ls -l to get more useful
information
The
-l (the letter L and not a digit)
command shows the output in Long format
This command displays lots of extra
information, including the size of the files
and their creation times
File Information
For
example:
cdvinaweb
lsl
rwrr1layers3682Mar1315:18index.html
rwrr1layers2542Nov2111:14vina.jpg
File Content
To
have a quick look at the contents of
a file, type: more filename
The
screen will display the contents of the
file called filename
If the contents of the file are bigger than
one screen, you will need to press the
spacebar to see each successive screen
File Content
NOTE:
this technique only works for
ASCII text files
It
doesnt work for other file types, such as
image files and sound files
It works for html files as well, but in this
case you will see all the html codes, just
as you do when you view the source or
when you edit it in a text editor
File
Sometimes
you dont know what type of
information is in a file
The file command looks at the files and
tries to guess what type of information
is in them
However, it doesnt know how to
recognise several types of file, so it is
of limited use
File
For
example, to see what kind of files
are in your current directory:
Type: file*
Output: (the exact output depends on what you
have in your directory)
101:directory
comp342:symboliclinkto342
dump.txt:empty
index.html:asciitext
student.c:cprogramtext
Manual
There
are hundreds of Unix commands
Often their name does not give much
information about what the command
does
Another problem is finding out how to
use the command
The Unix man command can help with
these problems
Manual
The
man command lets you find out lots
of information about a Unix command
man stands for manual
To use it type:
man commandname
This means show me the manual pages
which describe commandname
Manual
For
example, to find out about date:
Type: mandate
Output:
DATE(1V)USERCOMMANDSDATE(1V)
NAME
datedisplayorsetthedate
SYNOPSIS
date[u][a[]sss.fff][yymmddhhmm[.ss]][+format]
(it shows more information ...)
Manual
For
example, to find out about man:
Type: manman
Output:
MAN(1)USERCOMMANDSMAN(1)
NAME
mandisplayreferencemanualpages;findreferencepages
bykeyword
DESCRIPTION
mandisplaysinformationfromthereferencemanuals.Itcan
displaycompletemanualpagesthatyouselectbytitle,or
onelinesummariesselectedeitherbykeyword(k),orby
thenameofanassociatedfile(f).
(it shows more information ...)
Finger
The
finger program provides useful
information about someone who has an
account on a Unix system
It can (sometimes) tell you
the real name of the person, as well as their
computer account name
when the person last read their email
extra information provided by the person (if the
person put some information in their .plan file)
Finger
Type: fingerhorner
Output:
loginname:horner
Inreallife:AndrewHorner
Office:FACULTY
Directory:/homes/horner
Shell:/bin/tcsh
OnsinceNov1310:34:23onttyp21day1hourIdleTime
Plan:
officephone:(852)etc.
CurrentlyIamworkingonsynthesizingtraditional
Chineseinstruments
Finger
finger provides another useful function:
If you dont know the account name of a person,
you can enter their name
finger then tries to find a match
For example, finger chan gives a list of all the
people with the name chan as part of their real
name or part of their account name
Finger
For
example,
Type:fingeralbert
Output:
Loginname:juergenInreallife:Prof.JuergenAlbert
Office:guestofdw,expire31/03/98Homephone:no_dialin
Directory:/homes/juergenShell:/bin/tcsh
Neverloggedin.
NoPlan.
Date
The date command shows the current time
and date using the local time system.
Type: date
Output: MonMar2311:09:44HKT1998
The -u option shows the time and date using
Greenwich Mean Time (GMT) format instead of local
time.
Type:dateu
Output: MonMar2303:11:42GMT1998
Cal
The
cal program shows a calendar
It can show a calendar for the future,
the past or the present
The easiest way to use it is to just type
cal (with no parameters)
It
will show you the current month
Alternatively,
type cal month year with
appropriate numbers for month and
year
Cal
Other
ways to use cal:
Enter
just a year, with no month (cal year).
Cal then shows you all the months of that
year.
Enter just a month, with no year (cal
month). Cal then assumes you mean the
current year.
Cal
For
example, to find out what day of the
week Vina was born on:
Type: cal61995
Output:
June1995
SMTuWThFS
123
45678910
11121314151617
18192021222324
252627282930
Banner
This program creates a banner using
ASCII. You could import the resulting text
into an email or fax message. For
example, a message from Snoopy to Vina:
Type: bannerwoof
Output:
################
#######
###########
#########
#########
###########
Banner
Vina's Answer:
Type:bannermiaow!
Output:
###
##############
##############
############
###############
##############
##############
Have
filled in the course evaluation?
YES?
NO?
THANK YOU!
IT'S NOT
TOO LATE!
CLICK HERE!
###
##############
##############
############
###############
##############
##############