Comp 2673, Spring 2002
March 27, lecture notes
Review of Unix commands from last time, and from lab:
cd [filename] (changes to home directory if filename is omitted)
pwd
ls [-al] [filename] (if no arguments, lists the files in the
working directory, if filename is a directory,
it lists the files in that directory. -a shows all
files including hidden files, -l gives a long listing
mkdir dirname (creates a directory)
mv source destination (moves file "source" to "destination". If
destination is an existing directory, it moves
source to that directory, else it renames source)
cp source destination (copies file "source" to "destination". If
destination is an existing directory, it copies
the file to that folder, keeping the same file name.
Otherwise, it copies the file to the current
directory and gives it the name "destination")
rm filename (removes the file "filename")
man name (displays the manual page for the command "name")
apropos keyword (displays a synopsis for commands relating to "keyword")
finger [name] (with no argument, display information of all users
currently on the system. With the argument, it returns
more detailed information about the user "name" or
any user whose real name is "name")
w (displays a list of users on the system and what they
are doing)
Note that some of the above commands have additional flags not described
here. See the man pages for more information.
A couple of useful hidden files:
Each directory has two special hidden files called "." and ".."
The . directory refers to the current directory, and .. refers to the
directory one level above this one. For example, if my present
directory is ~ftl/mystuff, then:
cp ../foo .
copies the file ~ftl/foo to ~ftl/mystuff/foo
Review of vi, and some new vi commands:
Movement commands (in command mode) (grouped according to function):
h, j, k, l - moves you left, down , up, right
arrow keys - move you in file
w, b - forward or Backward a Word
W, B - moves you forward or Backword a space-delimited Word
0, $ - moves you to the beginning or end of a line
Ctrl-U, Ctrl-D - moves you Up or Down a half a page
Ctrl-f, Ctrl-b - moves you Forward or Back one screenful
/foo - moves to the first forward occurrence of the word "foo"
?foo - moves to the first backwards occurrence of the word "foo"
n - moves to the Next occurrence of what you just searched for
G - move to the end of the file
#G - move to line number #
Inserting text
i - enters insert mode
a - enters insert mode, appending (just past cursor position)
I - enters insert mode at the beginning of line (same as 0i)
A - enters insert mode at the end of a line (same as $a)
*** Type to exit insert mode ***
Deleting text - combine "d" with movement commands, for example
dd - delete a line
d$ - delete to the end of line
dw - delete one word
db - delete to beginning of word
dl - delete a characters (note: x works as well)
Using numbers with commands
Many vi commands can be preceded with a number, for example:
10h moves 10 characters to the left
10dd deletes 10 lines
File commands (use in command mode)
:w - saves file
:w filename - saves file to "filename"
:r filename - read file "filename" into the file you're editing
:q - quits vi
:q! - quits vi even if you haven't saved your changes
Miscellaneous useful commands (use in command mode):
u - undo the last change you made
. - re-do the last change you made
Reading email
There are lots of options!
1. Use the UNIX program "pine". (Just type "pine" at the prompt)
It has a good visual interface, follow the menus.
2. Messages can be saved and organized in folders - please do this
rather than leaving messages in your inbox, which is stored in
a shared location with limited space.
3. You can forward your mail from another UNIX system to this one.
(or from this system to another machine). Create a file called
".forward" in your home directory. In this file, put the email
address you want to forward to.
4. You can use DU Webmail - Go to http://webmail.du.edu and select
"imap.cs.du.edu" as the mail server, and enter your Math&CS Unix username
and password. While logged in to Webmail, do not access your
inbox via other mail software - you could corrupt your inbox.
5. For more options on reading email, consult http://www.cs.du.edu/support/email/