Files
Creating files
However, to put files in your directories, you will either have to edit and save them, or bring them in via ftp , or via cat. cat is a multipurpose utility, depending on the use of redirects. With a file argument and no redirect, it serves as a “type” command; with an input redirect, it is the equivalent of DOS “copy con”, taking terminal input and putting it in a file. Type

    cat >  whitman
    I hear america singing;
    its varied voices I hear.
    ^D
(where the ^D stands for Control-D: hold down the control key and type “D”. Case doesn’t matter with control characters .)

Now type

    more whitman
which will display the file. However, this is obviously awkward for long files, even with some primitive editing facilities on the current line (see control characters ).

To invoke the vi or emacs editors, type

    vi < filename>         or             emacs < filename> 
See vi for details on vi commands, and emacs for details on emacs. For an easy example session, see the Glass book, Chapter 2 (pages 60--68 for vi, and pages 69--76 for emacs).

Moving and Manipulating Files
         mv whitman voices
         mv voices test
             ls test
         mv test\voices whitman
    cat file1 file2 ... filen >  target
File Protection
There are four levels of access to any file in a UNIX environment:

The owner of a file can set and modify the permission bits of a file or directory. The individual bits grant permission to read, write, or execute a file (execute = list for directories) for the owner, the group, and others. (You might want to set important files which you have finished working with to be read-only, or read-and-execute-only, to make sure you don’t erase them.)

           chmod [-R] < change ...>  < filename ...> 
           < levels> < op> < permissions> 
              chmod u+x myfile otherfile
              chmod o-rwx secretfile
              chmod g=rx projectfile
  1. The second approach is to view the permissions for a level as an octal number specified by three bits, 1 if the level has the permission, and 0 if it does not. The permissions are always listed in order (read,write,execute), so read and execute but not write permission correspond to 101, or 5. Permissions now correspond (except for the sticky bits) to three octal numbers. Thus we can use
              chmod < number>  < filename ...> 
              chmod 744 myfile
Print
The print command in UNIX is lpr.

     lpr < filenames> 
Wildcards are legal, but some systems and some printer software have trouble handling multiple files.

The flags on lpr tend to be system-specific, but, if there are multiple printers available, you can usually count on lpr -P< printername> < filenames> . Other flags which may be available allow the printing of multiple copies, printing of single-sided versus double-sided output, printing in landscape mode, and so on. You should try man lpr if you need any of these effects.

Some applications, in particular TeX and LaTeX, produce output which cannot be printed directly by lpr. The output has to be processed through a filter, in this case called dvips or dvitps to produce printable text. Neither of these are (as far as I know) currently available on the RISC.

The current status of a print queue can be examined by lpq, using the -P< printername> flag if you have to use it for lpr.

A pending print request can be cancelled by using lpq to find the request number, and then using lprm -P< printername> < request_number> .