Tutorial

Working with Unix

This document describes how to navigate around and use commands in the FreeBSD Unix system that is installed on the Technology WWW server from your local PC.

This tutorial assumes that your PC is running Microsoft Windows 95 and is connected to the College Internet backbone network or to the Internet via an Internet Service Provider (ISP).  With other operating systems, the procedure will be similar.

Required Software:

Optional Software:

Step 1 - Obtain a Unix Account

User accounts on the server have been created by the Webmaster for all full-time ICT faculty and staff.  To activate your account, contact the Webmaster to obtain a username and password.

Typically, usernames are all lower-case, begin with your first initial, followed by up to seven letters of your surname.  (Unix being what it is, usernames are limited to 8 characters.)  For example, Mike Boldin's username is mboldin; Arnold Schwarzenegger's would be aschwarz.

Your username and password are also used to transfer files to the server via FTP.  Consult the FTP tutorial for more information.

Step 2 - Connect to the WWW Server

This step requires the Telnet application.  On the Windows 95 desktop, we can create a shortcut icon to TELNET.EXE, using the following procedure:
  1. Open the "My Computer" icon by double-clicking on it.
  2. Double-click on drive C: icon and then on the Windows folder.
  3. Find TELNET.EXE and drag its icon to the desktop by holding down the left mouse button.
  4. Open (double-click) the "Shortcut to Telnet" icon; it will start in a window.
  5. From the menu bar, click on "Connect" and select "Remote System ..."; a dialog box will appear.
  6. In the "Host Name" field, enter www.technology.niagarac.on.ca.
  7. The "Port" field should read "Telnet"; if not, select Telnet.
  8. The "Term Type" field should read "vt100"; if not, select vt100.
  9. Click on the "Connect" button; the dialog box will close.

Aside - Command-line Telnet

If you are running a command-line version of Telnet [such as with OS/2], it should run in a DOS full-screen session.  At the telnet> prompt, enter the following command to connect to the server:

telnet> open www.technology.niagarac.on.ca


On success, the server will respond with the following output in the main Telnet window.  Enter your assigned username and password when prompted.   (For security reasons, your password will not be displayed on the screen; in this example, we use  "jrperson" [J. Random Person] as the username).

FreeBSD (www.technology.niagarac.on.ca) (ttyp0)

login: jrperson
Password:
Last login: Wed Aug 27 12:57:21 from 192.197.62.10
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California.  All rights reserved.

FreeBSD 2.2.2-RELEASE (GENERIC) #0: Tue May 20 10:45:24 GMT 1997

Welcome to the Niagara College Technology WWW Server, now powered by FreeBSD!

The FreeBSD Handbook is in /usr/share/doc/handbook and the FAQ in
/usr/share/doc/FAQ.

/home/jrperson>

The "greater-than" sign (>) is called the prompt; it means that the server is waiting for you to enter Unix commands.  The prompt also displays the current working directory.  (This is equivalent to the the pwd ["print working directory"] command, which tells you in which directory you are currently working.)

When you first log in, you are placed in your home directory (which matches your username).  To return to your home directory at any time, enter the cd command without any parameters.  Under DOS, this command is equivalent to pwd.  Otherwise, cd is equivalent to its DOS counterpart, with two exceptions:

  1. Unix pathnames are separated by forward slashes (/, as opposed to \), and
  2. Unix does not support the concept of drive letters -- it has a flat filesystem, and all directories branch out from the root (just /).
Your home directory can also be abbreviated with a tilde (~).


Aside - Changing Your Password

The first time that you Telnet to the server, please change your password from the one assigned to you.  This is done via the passwd command.

/home/jrperson> passwd
Changing local password for jrperson.
Old password:
New password:
Retype new password:
passwd: rebuilding the database...
passwd: done
/home/jrperson>

As with logging in, your passwords are not displayed as you type them (for obvious security reasons).  To further enhance security, FreeBSD insists that you use mixed case or digits in your passwords.  If you enter all lower-case letters, the following message is displayed, and you are re-prompted for a password:

Please don't use an all-lower case password.
Unusual capitalization, control characters or digits are suggested.



 

Unix Equivalents for Common DOS Commands

DOS Command Unix Equivalent Description
dir ls -lF List files
copy cp Copy a file or files
move mv Move files or directories
ren mv Rename a file or directory
del rm Delete (remove) files
type cat Display (concatenate) a file or files
md mkdir Create (make) a directory or directories
rd rmdir Remove an empty directory or directories
help man Obtain help (read manual pages) on commands
deltree rm -r Remove a subdirectory and its contents
find grep Find a string (or regular expression) in a file
qbasic perl Interpreted general-purpose programming language
xcopy cp -r Copy a subdirectory and its contents
cls clear Clear the screen (terminal window).
 
Several aliases for DOS commands have been already created for you when you log in.  To view these, use the alias command:

/home/jrperson>alias
copy    (cp -i -p)
del     (/bin/rm -i)
deltree (/bin/rm -r -i)
dir     (/bin/ls -lF)
la      (/bin/ls -a)
lf      (/bin/ls -FA)
list    more
ll      (/bin/ls -lA)
lm      /bin/ls -lA !* | more
ls      (/bin/ls -F)
md      mkdir
move    (mv -i)
path    echo $path
rd      rmdir
type    cat
up      (cd ..)
/home/jrperson>

Note that the ls command is widely-represented.  By itself, The ls command lists only filenames.

/home/jrperson> ls
public_html
/home/jrperson>

When you log in for the first time, only public_html is shown.  This file is actually a link to your personal World Wide Web directory, and behaves like a directory.  Your WWW directory is in the /usr/wwwhome/people directory, and is spelled with your full last name.  If you type cd public_html, you will go there, and can manage your HTML pages.

Output from the dir alias (actually ls -lF) displays the following information,

/home/jrperson>dir
total 0
lrwxrwxrwx  1 root  wwwusers  27 Aug 22 16:25 public_html@ -> /usr/wwwhome/people/jrperson
/home/jrperson>

The "total" line displays the number of blocks (1 block = 512 bytes) used by files in the directory, and for each file, from left to right:

Furthermore, the -F flag in the alias causes the ls command to append an at-sign (@) to link names, a forward slash (/) to directory names, and an asterisk (*) to executable filenames.

CAUTION:

Some Unix commands, cp, mv, and rm to be specific, will normally not prompt you to confirm deletion or replacement of files.  Fortunately, the DOS aliases will display prompts in such a situation.  There is no undelete under Unix -- however, the Webmaster makes weekly backups of your WWW files.


Step 3 - Getting Help

Perhaps the most useful Unix command is man (for "manual").  It is the interface to the online manual pages.  You can find out about any Unix command with man.  The manual pages are divided into sections, each with an introduction, called intro.  Take for example, the following man commands:

/home/jrperson>man man

MAN(1)                  FreeBSD General Commands Manual                 MAN(1)

NAME
     man - format and display the on-line manual pages

SYNOPSIS
     man [-adfhktw] [-m system] [-p string] [-M path] [-P pager] [-S list]
         [section] name ...

DESCRIPTION
     Man formats and displays the on-line manual pages.  This version knows
     about the MANPATH and PAGER environment variables, so you can have your
     own set(s) of personal man pages and choose whatever program you like to
     display the formatted pages.  If section is specified, man only looks in
     that section of the manual.  You may also specify the order to search the
     sections for entries and which preprocessors to run on the source files
     via command line options or environment variables.  If enabled by the
     system administrator, formatted man pages will also be compressed with
     the `/usr/bin/gzip -c' command to save space.

etc.

/home/jrperson> man intro

INTRO(1)                FreeBSD General Commands Manual               INTRO(1)

NAME
     intro - introduction to general commands (tools and utilities)

DESCRIPTION
     Section one of the manual contains most of the commands which comprise
     the BSD UNIX user environment.  Some of the commands included in section
     one are text editors, command shell interpreters, searching and sorting
     tools, file manipulation commands system status commands, remote file
     copy commands, mail commands, compilers and compiler tools, formatted
     output tools, and line printer commands.

     All commands set a status value upon exit which may be tested to see if
     the command completed normally.  The exit values and their meanings are
     explained in the individual manuals.  Traditionally, the value 0 signi-
     fies successful completion of the command.

SEE ALSO
     apropos(1),  man(1),  intro(2),  intro(3),  intro(4),  intro(5),
     intro(6),  intro(7),  intro(8),  intro(9)

etc.

Also useful are the three keyword search commands (which are essentially equivalent),  apropos, man -k and whatis:

/home/jrperson> whatis ls
ls(1) - list directory contents
/home/jrperson> apropos directory
Tcl_TranslateFileName(3) - convert file name to native form and replace tilde with home directory
VOP_ABORTOP(9)           - abort a directory operation
VOP_CREATE(9), VOP_MKNOD(9), VOP_MKDIR(9), VOP_SYMLINK(9) - create a file, socket, fifo, device, directory or symlink
VOP_GETATTR(9), VOP_SETATTR(9) - get and set attributes on a file or directory
VOP_READDIR(9)           - read contents of a directory
VOP_REMOVE(9), VOP_RMDIR(9) - remove a file or directory
basename(1), dirname(1)  - return filename or directory portion of pathname
cd(1)                    - change working directory
cd(n)                    - Change working directory
chdir(2), fchdir(2)      - change current working directory
chroot(2)                - change root directory
chroot(8)                - change root directory
dir(5), dirent(5)        - directory file format
getcwd(3), getwd(3)      - get working directory pathname
getdirentries(2)         - get directory entries in a filesystem independent format
ls(1)                    - list directory contents
mkdir(2)                 - make a directory file
mtree(8)                 - map a directory hierarchy
opendir(3), readdir(3), telldir(3), seekdir(3), rewinddir(3), closedir(3), dirfd(3) - directory operations

etc.

The number is parentheses after each manual entry is its section number.  Sections are numbered from 1 to 9.  Most useful commands are in section 1.  If you need to look at another section, enter the section number followed by the topic (for example, man 2 mkdir).


Step 4 - Using an editor

There are currently several text editors installed on the web server.  Using the help commands from above, we can identify them:

/home/jrperson>apropos editor
ed(1) - text editor
ee(1)                    - easy editor
ex(1), vi(1), view(1)    - text editors
[non-text editor entries deleted]
joe(1)                   - Joe's Own Editor
jove(1)                  - an interactive display-oriented text editor
teachjove(1)             - learn how to use the JOVE editor
/home/jrperson>whatis emacs
xemacs(1)                - Emacs: The Next Generation
/home/jrperson>


Aside - Using vi to edit your HTML pages

If you edit an HTML document that you FTP'ed to the server and find a "^M" (carriage return) character at the end of each line, it probably means that you didn't transfer that file in ASCII mode.  (For more on the FTP process, refer to the FTP Tutorial).

The reason is that MS-DOS-derived operating systems (MS-DOS, OS/2, Windows) use both a carriage return (ASCII 13) and a line feed (ASCII 10) character at the end of a text line.  Unix only uses line feeds.

Fear not, for you can use vi to remove those pesky carriage returns with its global search-and-replace feature.

  1. Start the editor using vi filename, where filename is the name of your HTML file.
  2. Type : to get the command prompt.
  3. Start to the command s/
  4. Hold down the Ctrl key, type v and then m, release Ctrl^M is now displayed.
  5. Complete the command with //g and press Enter.  The carriage returns magically disappear.
  6. Write the file and exit by holding the Shift key and typing ZZ.

 

Always Building This is a "living" document. Additions and updates will be made from time to time, when the author has a chance. Thanks for your patience.



GoBack to the Unix Tutorial page