Learning Unix by Example

Getting Around, Manipulating Files & Directories, Basic Filesystem and Tools

(The examples are done on an SGI IRIX 6.5 system. Red is my input. Blue is the computers responce. Black is a comment)


username: pchem1

password: pchem#13

rotwang 2% ls

CRASH.log Model1.msi downloads ispell-3.1 temp
Desktop RUN.LOG dumpster nsmail yarger.outbox
Hatom.nb bin files public_html

rotwang 3% mkdir TEST

rotwang 4% ls

CRASH.log Model1.msi bin files public_html
Desktop RUN.LOG downloads ispell-3.1 temp
Hatom.nb TEST dumpster nsmail yarger.outbox

rotwang 5% ls -CF

CRASH.log Model1.msi bin/ files/ public_html/
Desktop/ RUN.LOG downloads/ ispell-3.1/ temp/
Hatom.nb TEST/ dumpster/ nsmail/ yarger.outbox

rotwang 6% ls -l

total 1584
-rw-r--r-- 1 yarger user 1112 May 12 1998 CRASH.log
drwxr-xr-x 2 yarger user 109 Mar 20 1999 Desktop
-rw-r--r-- 1 yarger user 652946 Sep 16 21:32 Hatom.nb
-rw-r--r-- 1 yarger user 1272 May 9 1998 Model1.msi
-rw-r--r-- 1 yarger user 127231 Apr 15 1999 RUN.LOG
drwxr-xr-x 2 yarger user 9 Feb 7 21:31 TEST
drwxr-xr-x 2 yarger user 20 Dec 17 1998 bin
drwxr-xr-x 2 yarger user 144 Apr 14 1999 downloads
drwxr-xr-x 3 yarger user 27 Dec 14 1998 dumpster
drwxr-xr-x 35 yarger user 4096 Jan 8 00:04 files
drwxr-xr-x 4 yarger user 4096 Dec 17 1998 ispell-3.1
drwx------ 2 yarger user 9 Mar 18 1999 nsmail
drwxr-xr-x 4 yarger user 105 Mar 20 1999 public_html
drwxr-xr-x 2 yarger user 4096 Feb 3 18:08 temp
-rw-r--r-- 1 yarger user 61 Mar 20 1999 yarger.outbox

So it seems that you can list (ls) the files in many different formats. I have show you a few

however, there are many many more ways. Just type "man ls" if you want to know more!!

We have created a directory named "TEST" using the make directory (mkdir) command

now lets go into the directory and make a file that we can edit.

First.... where the hell am I!!

rotwang 7% pwd

/usr2/people/yarger

Oh, my home directory must be /usr2/people/yarger.... How do I know where my

home directory is???

rotwang 8% setenv |grep HOME

HOME=/usr2/people/yarger
CSDHOME=/usr2/cambridge

Ok, the environmental variable HOME is /usr2/people/yarger. Setenv displays all

environmental variables under c-shell and I piped this to grep which matches lines

with the string "HOME" in them.

So, now that I know where I am lets changed directory (cd) to the new directory we

created above.

rotwang 9% cd TEST

rotwang 10% ls

rotwang 11% pwd

/usr2/people/yarger/TEST

So, we did a list command and nothing showed up...why??

Well, we just created the directory and have not put anything into it yet. So lets make

a file!! First lets create a file that has our name in it (ok boys and girls...go)

rotwang 12% vi myname

Oh no.... what the hell happened??? Well, you are now in the standard text editor

on Unix systems. vi is short for visual editor. Hit 'i' to get into input mode. Now

type your name. Once you are finished, hit the Esc key to exit input mode. Now type

'ZZ' to save and exit.

rotwang 13% more myname

Jeff Yarger

Now, I want to add all my environmental variables to the end of this file.

rotwang 14% setenv >> myname

rotwang 15% more myname

Jeff Yarger
HOME=/usr2/people/yarger
PATH=/usr2/people/yarger/bin:/usr/sbin:/usr/bsd:/sbin:/usr/openwin/bin/xview:/bin:/usr/bin:/usr/etc:
.:/usr/bin/X11:/usr/local/bin:/usr/openwin/bin:/usr/freeware/bin
LOGNAME=yarger
HZ=100
TZ=MST7MDT
TERM=xterm
USER=yarger
LANG=C
SHELL=/bin/tcsh
REMOTEHOST=yarger.uwyo.edu
REMOTEUSER=UNKNOWN
MAIL=/usr/mail/yarger
DISPLAY=bloch.uwyo.edu:0.0
SHLVL=1
PWD=/usr2/people/yarger/TEST
HOST=rotwang
HOSTTYPE=iris4d
MSGVERB=text:action
NOMSGLABEL=1
NOMSGSEVERITY=1
CSDHOME=/usr2/cambridge
g98root=/gaussian/g98a7
GAUSS_SCRDIR=/gaussian/scratch
GAUSS_EXEDIR=/gaussian/g98a7/g98/bsd:/gaussian/g98a7/g98/local:/gaussian/g98a7/g98/extras:/gaussian/
g98a7/g98
GAUSS_ARCHDIR=/gaussian/g98a7/g98/arch
GV_DIR=/gaussian/gv
_RLD_ARGS=-log /dev/null
LD_LIBRARY_PATH=/gaussian/g98a7/g98/bsd:/gaussian/g98a7/g98/local:/gaussian/g98a7/g98/extras:/gaussi
an/g98a7/g98:/gaussian/g98a7/gv/lib
G98BASIS=/gaussian/g98a7/g98/basis
F_ERROPT1=271,271,2,1,2,2,2,2
TRAP_FPE=OVERFL=ABORT;DIVZERO=ABORT;INT_OVERFL=ABORT
MP_STACK_OVERFLOW=OFF

rotwang 16% vi myname

Now, lets go down to line 8 and move it to the end of the file.
(1) '8G' will take you to line 8 (to show line numbers type ':set number' to remove type 'set nonumber')
(2) dd will delete (or cut the line.
(3) use the down arrow or ctrl-f to move forward to the last line.
(4) type 'p' to paste the deleted line back in.
Now, lets search for 'HOME' and replace it with 'CRAP'
(1) :1,%s/HOME/CRAP
This searches lines 1 - end for "HOME" and replaces it with "CRAP"

Ok, enough with random files!! Let's make a web page.

rotwang 17% cd

rotwang 18% cd public_html

rotwang 20% ls

Miscellaneous Public default.gif index.html index.shtml

rotwang 21% rm -r ./*

rotwang 22% ls

rotwang 23% vi index.html

So we have started to edit a file named "index.html". Nothing is in it currently,
lets make a simple html document.
(1) "i" to enter insert mode
(2) type in the following:

<html>
<BODY BGCOLOR="#ffffff">
<H1><CENTER>Your Name's <BR>
<EM>Web Page</EM></CENTER></H1>

<P>&nbsp;</P>

<UL>
<LI><A HREF="test.html">Outline or List Item</A>
<UL>
<LI><A HREF="test.html">Sub-List Item</A>
<UL>
<LI><A HREF="test.html">Sub-Sub-List Item</A>
<LI><A HREF="node3.html">Sub-Sub-List Item</A>
</UL>
</UL>
</UL>
<UL>
<LI><A HREF="test.html">Outline or List Item</A>
</UL>

<P>&nbsp;</P>

Created by J.L. Yarger
</BODY>
</HTML>

(3) Now type "Esc" to exit input mode and type "ZZ" to save and exit

rotwang 24% netscape index.html

This will show you your new web page.
Now lets put in two or three common items that we see in most web pages:

(i) Pictures, (ii) tables, (iii) and scripts.

rotwang 31% netscape&

See the 4 round buttons at the top of the page?? These are
pictures, lets steal them and use them on our web page!!
So, move your mouse to one of the buttons, click the right
mouse button and then click the "save image as" option.
You can give it your own name or keep the one that it has now.
I do recommend that you leave the .gif extention.

rotwang 32% ls
index.html nc_blue1_navi.gif nc_blue2_navi.gif nc_blue3_navi.gif nc_blue4_navi.gif

rotwang 34% vi index.html
<html>
<BODY BGCOLOR="#ffffff">
<H1><CENTER>Your Name's <BR>
<EM>Web Page</EM></CENTER></H1>

<P>&nbsp;</P>

<UL>
<LI><A HREF="test.html">Outline or List Item</A>
<UL>
<LI><A HREF="test.html">Sub-List Item</A>
<UL>
<LI><A HREF="test.html">Sub-Sub-List Item</A>
<LI><A HREF="node3.html">Sub-Sub-List Item</A>
</UL>
</UL>
</UL>
<UL>
<LI><A HREF="test.html">Outline or List Item</A>
</UL>

<P>&nbsp;</P>

Created by J.L. Yarger
</BODY>
</HTML>

~
~
~

Now lets add a table that puts each of these images in a separate column.
type "5G" then "i" then add "<P>&nbsp;</P>" to leave some space for the image table.
Now add:
<TABLE COLS="4" WIDTH="90%" BORDER="0" CELLSPACING="2" CELLPADDING="0">
<TR>
<TD>
<IMG SRC="nc_blue1_navi.gif">
<TD>
<IMG SRC="nc_blue2_navi.gif">
<TD>
<IMG SRC="nc_blue3_navi.gif">
<TD>
<IMG SRC="nc_blue4_navi.gif">
<TR>
<TD>
button 1
<TD>
button 2
<TD>
button 3
<TD>
button 4
</TABLE>

This adds a table of 4 columns and 2 rows that contain a row of 4 images and a row of four
text statements (button 1, button 2, ....)
Now exit input mode, save, and exit vi.

rotwang 41% netscape index.html

This will show you your new web page. What is the going on with these images?? I expected
that the images would just be each of the individual buttons.
What netscape has done it to create a graphic that uses javascripting mouseovers to change images
and an imagemap to select links.
We can continue this next time or skip onto something else.