Reference: A Practical Guide to UNIX System V, by Mark G. Sobell
(Some UNIX systems will initially require the user to establish a password for a new account.)
The password should be changed by execution of the passwd utility program.
Absolute pathname: the complete pathname of a file starting with the root '/'.
eg. /usr/users/smith/courses/cs/1705/prog1.pas
Relative pathname: pathname that implicitly starts at the working dir.
eg. courses/cs/1705/prog1.pas
Special Files
Every dir contains at least 2 files . & ..
. abbreviation for the current working dir; stores location of current dir
.. abbreviation for the dir containing the current working dir (i.e. its parent); stores location of parent dir
[2]% pwd
/usr/users/dave
print working dir: displays current working dir path
[3]% cd class
change dir: alters working dir: used to traverse UNIX hierarchical tree file structure
Pathname can be absolute or relative. cd with no args returns to home dir. cd .. moves up to parent dir.
[4]% rmdir p2
remove dir: deletes a subdir which must be empty
[5]% mkdir pascal
make dir: creates a dir in the working dir.
[6]% cat notes
concatenate: displays one or more files on the screen
[7]% more notes
more: displays file(s) one screenful at a time, spacebar is used to 'scroll' through the file.
[8]% lpr notes
line printer: prints one or more files on the printer
[9]% ls -aFl
list: displays files (hidden), following dirs with a slash & executable files with asterisks in long form. example follows:
total 6
drwxrwxr-x 6 smith cs1705 480 Dec 6 17:42 .
drwxrwx--- 26 root system 816 Dec 6 14:45 ..
-rw-rw-r-- 1 smith cs1705 161 Dec 6 17:15 .profile
drwxrwxr-x 2 smith cs1705 80 Oct 25 08:33 bin/
drwxrwxr-x 2 smith cs1705 144 Nov 30 14:25 pascal/
-rw-rw-r-- 1 smith cs1705 104 Sep 12 19:54 notes
-rwxrw-r-- 1 smith cs1705 85 Jan 4 20:06 run*
drwxrwxr-x 2 smith cs1705 32 Mar 23 13:45 memos/
drwxrwxr-x 16 smith cs1705 1296 Dec 6 17:33 shell/
ls without a dir argument following the options defaults to current dir as do most UNIX commands.
ls with file args lists info about only those files. Hidden files ('.filename') are not displayed w/o the -a option.
char meaning
* match any characters
? match any single character
[ begin a character group
] end a character group
- denotes a character range
examples:
ls p*.c
lists all files that start with p & end in .c
ls prog?.pas
lists all files that start with prog followed by any one char & end in .pas
ls prog[0-5].pas
lists all 5 char files that start with prog, end in .pas & have a 0, 1, 2, 3, 4 or 5 as the fifth char
[11]% ln ../dir2/proga .
same effect as above command, 2nd argument can be a dir. Changes to one affects the other. Both refer to the same physical file on the disk.
[12]% cp ../dir2/proga prog1
copy command creates a separate file 'prog1'. Changes made to one do not affect the other.
[13]% cp ../dir2/* .
copies all files from parent/dir2 to the current dir.
[14]% rm ../dir2/proga
remove command erases the file. rm does not notify user of the action that has occurred. rm accepts a list of files to erase.
rm *.p?? erases all of the pascal files, whereas rm * .p?? erases all of the files in the working dir.
rm -i proga forces rm to query before erasing files the same as the del command.
rm does not actually erase the file. rm removes the link to the file. When the last link to a file is removed UNIX then reclaims the file space.
[15]% mv prog? ../dir2
move relocates the file(s) into the specified dir.
[16]% mv prog1 progb
move is also used to rename a file leaving the location unaltered.
mv is implemented as ln & rm. A new link is established and then the old link removed.
[17]% df
Filesystem Total kbytes kbytes % node kbytes used free used Mounted on /dev/rz2a 19743 10387 7382 58% / /dev/rz2g 294518 248466 16601 94% /usr
disk free: displays amount of free space on all disks.
[18]% du -a /usr/users/guest
1058 ./eps 11 ./cursed.p 3 ./permsrec.p 76 ./printscreen.ps 93 ./menu.ps 1 ./.Xdefaults 1247 .
disk usage: displays the amount of space (1K blocks) occupied by a dir plus all of its files & subdirs.
Online help is available on any command through the UNIX man (manual) utility.
man command-name
At this point, for example, the following situation could be present:
The file system that was created during formatting is a separate file system with initially only a root dir.
Inserting the disk & mounting it would lead to the following state:
The floppy file system is attached to /sony & is now considered part of the hard disk file system. The /sony dir can be used with any UNIX commands the same as any other dir.
Files from mounted floppies, transported between machines, will not be accessible if the owner and group are not the same as on the machine on which they were created. The file access permissions should be set to allow all other users access in this case.
File access permissions, (modes), can be changed with the command:
chmod a=rw file-list
The owner and group of files can be changed with the chown and chgrp commands respectively.
Unmounting the disk now yields:
A softcopy of the sash documentation resides in the /usr/local/doc dir and can be viewed with more.
To execute emacs:
emacs filename if file does not exist emacs creates the file
GNU Emacs Novice Reference Sheet
Note that ``C-x" means ``hold down the Control key, and type the x key". ``M-x" means "type the ESC key, then type the x key". Alternatively, if your terminal has a Meta-key, then ``M-x" means "hold down the Meta key, and type the x key".
Description Command Code Exit Emacs C-x C-c Suspend Emacs C-z Get help C-h Save a file C-x C-s Visit a new file C-x C-v Visit another buffer C-x b Abort a command C-g Down one screen-full C-v Up one screen-full M-v Forward one character C-f Forward one word M-f Back one character C-b Back one word M-b Down to next line C-n Up to previous line C-p Go to beginning of line C-a Go to end of line C-e Go to begining of file M-< Go to end of file M-> Set mark (begin region) C-@ or C-SPACE Go to mark C-x C-x
Description Command Code Delete previous character (back) DEL Delete current character (forward) C-d Delete previous word (back) M-DEL Delete next work (forward) M-d Kill rest of line (send to kill buffer) C-k Delete region (from mark) (send to kill buffer) C-w Yank back kill buffer C-y Incremental search forward C-s Incremental search backward C-r Exit incremental search ESC Abort incremental search C-g Get rid of extra windows C-x 1 Split window in two C-x 2 Move cursor to other window C-x o Start a shell window M-x shell Run the compiler M-x compile Move to next compiler error C-x `
vi : Visual EditingTo execute vi: vi filename if file does not exist vi creates the file
vi +n filename editing starts at line nOperation Modes:
Input accepts text & inserts into the file escape key exits to command mode Command cursor control, text modification ... does not require return key entry Last Line colon moves cursor to screen bottom requires ret key for commandsDiscuss in detail the local vi handout command mode commands:
repeat factor most vi commands can be preceded by an integer that denotes the number of times the command is to be repeated or the size of text to which the command is to be applied.
To use pc, type:
pc (options) (file) (options) (file) ...
(Note that options must *precede* the file they apply to!!)
Each of the (file)s should end in '.p', or '.o'.
Files ending in '.p' will be compiled and included in
the link, files ending in '.o' will be included in the link.
The base name of the *last* file specified will be used as
the name of the executable program.
Options for pc are:
-c Suppress the loading phase of the compilation and force
an object file to be produced even if only one program is
compiled.
-g0 Have the compiler produce no symbol table information for
symbolic debugging. This is the default.
-g Have the compiler produce additional symbol table
information for full symbolic debugging and not do
optimizations that limit full symbolic debugging.
-p0 Do not permit any profiling. This is the default. If
loading happens, the standard runtime startup routine
(crt0.o) is used, no profiling library is searched.
-p Set up for profiling by periodically sampling the value of
the program counter.
-O0 Turn off all optimizations.
-O1 Turn on all optimizations that can be done quickly. This
is the default.
-edit[0-9]
Invoke the editor of choice (as defined by the environment
variable EDITOR), or vi(1) (if EDITOR is not defined) when
syntax or semantic errors are detected by the compiler's
frontend....The editor is invoked with two files: the error
message file and the source file. First use the error message
file to locate the line numbers of all the errors, then switch
to the source file to make corrections. Once you exit out of
the editor, the compile job is restarted. This process can be
repeated up to 9 times, depending on the single digit number
specified in the option. If no number is specified in the
option, this compile-edit-compile process repeats indefinitely
until all errors are corrected. -edit0 turns off this edit
feature.
-C Generate code for runtime range checking. The default
suppresses range checking.
-casesense
Assert case sensitivity on variable names. The default is case
insensitive, that is, variable names ABC and abc are considered
to be the same identifier.
-apc Enable the following popular Pascal language extensions:
built-in function in_range(), built-in procedures discard(),
(TYPE-ID) pseudo function, variable attributes: define and
extern, type coercion: (TYPE-ID)(var), implicit null OTHERWISE
clause for CASE statement, infix bit operators: `&' (bitand),
`!' (bitor) and `~' (bitnot), MOD operator returns negative when
the dividend is negative, constant strings maybe assigned to
non-packed arrays of char, well-aligned objects within a packed
array are allowed to be passed as VAR parameters, row and
wildcard array initializations, INTEGER is equivalent to INTEGER16
(and therefore MAXINT = 32767), real constants are permitted to
have the form "123.".
See man pc for more information.
Devices in UNIX are represented as files: ex. /dev/console. UNIX commands receive their input from the standard input (stdin) and send their output to the standard output (stdout), by default these files are the console or terminal. Shells allow input/output (I/O) to be redirected from/to other devices, thus UNIX commands are unaware from what device their input may originate or to what device their output may be sent. command name [args] > filename The output redirection symbol, > , sends the command`s output to the specified file instead of the console/terminal screen. ls -al > ls.out The file ls.out is created if it does not exist (or destroyed & recreated if it exists prior to command execution) and sent the dir listing. Programs that send their output to the console/terminal may also be redirected. progxcs1706 > px.out This allows execution results of a program to be captured in a file. command name [args] < filename The input redirection symbol, < , sends the command input from the specified file instead of the console/terminal keyboard.progxcs1706 < px.inp > px.log This allows program execution with several data sets very easily. Pipes | are the logical extension of I/O redirection. Pipes allow the stdout of one program to become the stdin of another program. ls -al | more The above command allows the viewing of the long listing of a large dir one screen at a time. ls -al > ls.out more < ls.out rm ls.out The above I/O redirection is an equivalent set of commands, but requires the ls.out temporary file.