Today a new user was asking for basic help in using Linux.  There doesn't
seem to be anything like that on the CD-rom, unless my copy is out-of-date.

I attach a document that might serve as a brief introduction, that could
be added to the files on the CD.  Would anyone like to suggest additions:


Quick quide for newcomers to Linux/Unix
=======================================

1. Getting into the system. 

You have to log in (as with Windows) by entering a username and password.
This gives you complete access to your own files, but not to other users'
files, unless they specifically allow it.   (See on permissions, below.)


2. Running commands

Type a command at the prompt and any necessary options and then press the
<Enter> key.  Most commands operate silently unless they are specifically
asked to say what they are doing.  If you don't see an error message, the
command should have worked.


3. Organisation of files

Unix filesystems are organised into directory trees, like DOS.  However
the separator character is `/', not `\'.  So a likely path might be
`/usr/bin/ls'.  The job that DOS does with `/' (command-line switches)
is done in Unix by `-': for example `ls -a -l -d' (which may be
shortened to `ls -ald').


4. Essential commands:

[something_in_square_brackets] represents some other word that you will
type in according to what you want to do.

man [command]:     shows the manual page on the command (use q or
                   ctrl-C to get out of it if it doesn't terminate
                   at the end of the text)

info:              read GNU documentation in a rather crude
                   hypertext format.

cd [directory]:    change directory (just like DOS!)

mv [source] [target]: moves [source] file to [target] and deletes
                   [source]. [source] can be a list of files, but
                   in that case [target] must be a directory.

cp [source] [target]: copies [source] to [target]

ln [source] [target]: links [source] to [target] (hard or symbolic
                   links according to options)

rm [filelist]:     deletes files

chmod [mode] [filelist]: changes the permissions of files

chown [owner] [filelist]: changes the ownership of files

chgrp [group] [filelist]: changes the group ownership of files

ls [directory]:    list contents of [directory] (like DOS dir, but the
                   output is sorted)

df:                lists mounted partitions (note: /proc is a special
                   'non-existent' partition, that contains information
                   about the current state of the OS)

cat [textfile]:    dumps [textfile] to screen without paging (like 
                   DOS type)

more [textfile]:   lists [textfile] to the screen in pages so that
                   you can read it
less [textfile]:   like `more' but with more features and somewhat
                   different behaviour

find [directory] -name [filename]:  tells you where [filename] is in the
                   tree starting at [directory]. This command has many
                   other useful options.

grep [pattern] [filelist]: list all lines in [filelist] that match 
                   [pattern]

gunzip [file]:     uncompresses [file] (which is probably called
                   `something.gz' or perhaps `something.Z'), deletes it
                   and writes an uncompressed file called `something'.
zcat [compressed_file]
zless [compressed_file]
zgrep [compressed_file]: run cat, less or grep on a compressed file
                   without your having to uncompress it first

file [file]:       reports what kind of thing [file] is

type [file]:       says where to find [file] in your search path
whereis [file]:    like type, but gives more information

ps:                list your processes

tar
cpio
afio
dump:              various processes for making archives of different
                   kinds

awk
perl
sed:               various text processing commands (and more)

lpr [file]:        print [file] to the default printer

ed [file]:         the original line editor (not friendly)

vi [file]:         full-screen editor (find a book about it)

emacs:             another editor, that would like to be an Operating
                   System when it grows up

exit
logout
ctrl-D (sometimes): use any of these to log out

passwd:            change your password

id:                tells you what user you are and what group you are in

su:                become superuser; this gives you the authority to alter
                   system files AND ENABLES YOU TO WRECK YOUR WHOLE SYSTEM,
                   so watch it! (see below.)  Use`exit' or ctrl-D to stop
                   being superuser.  When you are superuser, your prompt
                   will probably end with # instead of $.

                   The password you are prompted for is the root password.
                   If there isn't a root password, set it now!!

                   DON'T BE SUPERUSER EXCEPT WHEN NECESSARY!!!!!

                   Logging in as root gives you the same power.

who -u:            reports everyone who is logged on

shutdown:          shuts the computer down safely.  You can also
                   use ctrl-alt-del if your system is set up for
                   that.  Never turn off a Unix machine without
                   doing a safe shutdown: otherwise you will
                   damage your filesystems.

script [file]:     Records everything on the screen (until the next
                   exit) in [file].  This is useful if you need to 
                   record what's going on in order to include it in
                   your message when you ask for help.  Use `exit'
                   or ctrl-D to stop the recording session.

Most of these commands have many options.  Use man to find out what
they are and how to use them.

Some commands (such as shutdown) can only be run by the superuser.

The command search path is held in PATH: type 'echo $PATH' to see
what it is.  Commands must be in the path to be executed, unless you
give a pathname.  If . (the current directory) is not in your path,
a command in the current directory will not be executed unless
the directory is otherwise named in the search path or unless you
type `./command' instead of `command'.


5. Special characters in commands (see `man bash' for details): 

\    escapes itself and other specials
[]   encloses patterns for matching a single character
*    stands for anything (including nothing)
?    stands for any single character
()   runs the contents of the parentheses in a subshell
;    terminates a command pipeline - use it to separate commands
     on a single line
&    runs the preceding pipeline in the background
$word
${word} interprets word as a shell variable (use {word} if there
     is danger of ambiguity).
``   runs the contents of the backquotes as a command and uses the
     output as part of this command
""   treats the contents of the quotes as one argument, without
     interpreting specials except $ and ``
''   as for "" but does not interpret any specials
|    pipe (as for DOS) sends output of left side to input of
     the right side
>
<    redirection (see below)
||
&&   conditional execution

For example, `ls -d /[uv]*' will list  the names of all entries in
the root directory that start with u or v.  Unlike DOS, you can use
patterns like `g*.gz' (with the wildcard bit in the middle).


6. Permissions

File permissions govern access. Type `ls -l' to see permissions:

   -rwxr-xr-x   1 root     root        37760 Aug 14  1996 vdir
   -rwsr-xr-x   1 root     root         7768 Sep 30  1996 vlock
   -rwxr-xr-x   4 root     root        45280 Nov 28 18:49 zcat
   ^   ^^^
   |^^^ | ^^^
   | |  |  |
   | |  |  --- Permissions for others
   | |  ------ Permissions for group
   | --------- Permissions for owner
   ----------- Type

The permissions are the first field in the listing.  They should be
treated as 1 character followed by three groups of three characters.
The first character describes the type of file:

  - ordinary file
  d directory
  l symbolic link
  c character device
  b block device
  p FIFO (named pipe)
  s socket

The next three groups are the permissions for file owner, file group
and other users respectively. The first character of each group may
show (or not) r for read permission, w is for write permission and x
is for execute or search permission.  Instead of x, you might see
s, S, t or T - run `man chmod' for details.

If you have write permission for a file, you can change it. If you
have write permission on a directory, you can delete files in it,
even if you don't have write permission for the files.

If you do not have search permission (x) for a directory, you cannot
include it in any pathname. If you do not have read permission for
a directory, you cannot list its contents, but you may still be able
to access files in it - if you have search permission.


7. Devices

Hardware devices are addressed through entries that look like file
in the directory /dev.  The fact that there is an entry in /dev
does NOT mean that there is necessarily a corresponding bit of
hardware.  For example, the standard printer is usually /dev/lp1
but you will find /dev/lp0 and /dev/lp2 which correspond to different
points where the parallel port may be placed in the hardware.


8. Filters

Many commands are filters, so you can pass the output of one command to
the input of another:

        awk -F: '{print $1 " " $6}' /etc/passwd | sort 


9. Redirection

You can also use redirection of input, output and error output by adding
these sequences after a command:
   < [file]         means take input from [file]
   > [file]         means send output to [file] (overwriting)
   >> [file]        means append output to [file]
   2> [file]        means send error messages to [file] (overwriting)


10. Shell programs

Redirection is a simple part of shell programming, for which see the
manual pages of bash, zsh, tcsh, or whatever shell you have chosen.
A shell program is a set of commands in a file or typed in.  E.g.

        for f in `grep -l widgets`
        do
                sed -e 's/widgets/gadgets/g' <$f >${f}gadget
                echo $f
        done

Once you have stored a shell program in a program file, you have to make it
executable by running chmod:

        chmod a+x my_program_file


11. Errors

Unix commands normally execute silently unless asked to be verbose
or unless there is an error. An error means something that does not
make sense to Linux; it doesn't mean something you don't want to
happen!  For example, I once had a client who had some unwanted files
in his root directory which were named &TEMP& and so on.  As superuser
in the root directory he typed

        rm -rf /&*

when he should have typed

        rm -rf \&*

What he actually asked for was to delete his entire file system, as a
background job.  It did too.


12. Finding more information

Look in /usr/doc for the various HOWTO files. Read the man pages. Get a 
book on Unix.  If these don't answer your questions, subscribe to 
debian-user@lists.debian.org and ask there.  (To subscribe, mail
[EMAIL PROTECTED] with the word subscribe in the body
of your message.)

Oliver Elphick                                [EMAIL PROTECTED]
Isle of Wight                              http://www.lfix.co.uk/oliver

PGP key from public servers; key ID 32B8FAA1

Reply via email to