UNIX BASICS (Originally from Hamline) Created: 1991 NW; Modified 3/7/94 RDL
Modified by Luke Bullock (lucc@powertech.no) Fri Apr 18 18:10:15 1997
----------------------------------------------------------------------------

	Whenever you login to a Unix system you are placed in a program 
	called the shell. It is a utility program that enables the user 
	to interact with the UNIX operating system. Commands entered by
	the user are passed by the shell to the operating system which 
	carries them out. The results are then passed back by the shell
	and displayed on the user's display. You can see its prompt at 
	the bottom left of your screen. To get your work done, you enter
	commands at this prompt.

	Shell prompt:
      	a character at the start of the command line which indicates 
	that the shell is ready to receive your commands. The character
	is usually a '%' (percent sign) or a $ (dollar sign). It may be 
	different on your system.
	
	As in MS-DOS, Unix commands are typed out at the prompt, and
        followed by the "Enter" or Return) key. Commands can consist
        of a single word, such as ls, or a word followed by one or more
        "option" (or "switch"), such as ls -l (options in Unix are
        normally preceded by a - (minus) character. Here the "-l" option
        specifies that the listing be given in the "long" form.
        Commands may also have one or more parameters, such as
        "cp fileA.txt fileB.txt", which specifies that "fileA.txt" is to
        be copied to "fileB.txt" (note that parameters do not have the
        minus character). It is possible to have a combination of options
        and parameters in the same command, as in "ls -l *.txt", which
        gives the "long" listing of all files that end with ".txt".

	As with most computer systems, Unix will issue an error message
        if you enter a command incorrectly. If the syntax of the command
        is correct, but the result is something you did not expect, the
        computer will not issue an error message. The best way to learn
        Unix commands is to experiment with the various commands, options,
        and parameters.

Selected Unix Commands by Function:
	The following list of Unix commands are arranged by function.
        A one line description is given for each command. For further
        information on given commands, see the following section
        "Alphabetical List of Unix Commands", or see the online manual
        pages (see "Online Manual Pages" or type "man command" at the
        prompt).

Working with Files:
      ls      	list the files in a directory
      diff    	compare two files
      cp      	copy the contents of a file
      chmod   	change file permissions
      mv      	move (or rename) a file
      file    	identify the file type
      cat     	display the contents of a file
      lp      	print to a system printer
      more    	display the contents of a file a page at a time
      rm      	remove (delete) a file
      wc      	count the lines, words, and characters in a file
      grep    	search a file for text
      sort    	sort the contents of a file
      touch   	create an emty file with 0 bytes
      locate  	find a file matching pattern 
      whereis 	find a specified file
      
Working with Directories:
      pwd       display the current directory name
      mkdir     make a new directory
      cd        change into a new working directory
      rmdir     remove a directory

     Email/Internet Utilities:
      mutt      electronic mail program
      elm       electronic mail program
      pine      electronic mail program
      frm       list headers from local spool file
      tin       internet (usenet) news reader
      slrn      internet (usenet) news reader
      ftp       file transfer program
      ncftp     file transfer program
      archie    internet file search
      telnet    log on to internet computers
      gopher    old internet browser
      lynx      charachter based (text) internet browser
      talk      talk to another person in real time via keyboard
      irc       internet relay chat
     
Editors:
      pico	
      vi
      vim
      vile
      emacs
      jed

Other Commands:
      df        show free space on disk
      du        show disk usage
      free      show memory status
      who       show who is logged on
      ps        show information on running processes
      finger    show who is logged on
      man       online manual pages
      info      get information from GNU info pages
      alias     establish an "alias" for a command
      history   show numbered list of previous commands
      top       system monitor, shows running prossess with id/pid
      yamm      yet another micro monitor (not available on all systems)
      whoami    prints your login id
     
Change your settings 
      chfn      change finger information
      chsh      change login shell (not allowed on many systems)
      passwd    change password
      
Important dot files
      
  Shells: (configuration files for various shell types)
      .profile  bash (Bourne Again Shell) for login shell
      .bashrc   bash (as above)
      .login    tcsh (Enhanced Berkely Unix C shell)
      .cshrc    csh (Berkely Unix C shell)
      .zshrc    zsh (Enhanced ksh)
      .kshrc    ksh 

  Other:
      .signature  	your signature for email and news postings
      .project  	display a one line comment to show when fingered
      .plan     	display many lines of comment when fingered
      .forward  	forward all incoming mail to another address
      .bash_history 	records a list of your command history
      .mime.types  	application identification
     
     There are alot more dot files (files starting with a . ), but
     the above are most common. Many applications create dot files
     to record and store information about a selected configuration.
     
Alphabetical List of Unix Commands:
     The following is a list of some Unix commands. Each listing provides a
     short definition and one or more examples. See the online manual page
     for additional information on options and parameters.

      alias
      	established an "alias" (new name) for a Unix command.
      	Aliases may be put in your ".kshrc" file (or ".cshrc"
      	file for those using the C-Shell) to make them
      	permanent.

      alias dir ls
      	make the command "dir" an alternative for "ls"

      alias home "cd ~"
	make the command "home" an alternative for "cd ~"

      alias
      	show list of current aliases

      cat
      	display the contents of (concatenate) a file, or
        combine the contents of two or more files together.

      cat fileA
      	display the contents of file "fileA"

      cat fileA fileB
      	display the contents of file "fileA" and "fileB"

      cat *.txt > txt.out 
      	combine all files ending with ".txt" into a new file
        "txt.out"

      cat file.txt |more
      	display the contents of a file one screen at a time

      cd
      	change into a new working directory.

      cd /home/cla/1995/aanderso/programs
	change current directory to an absolute location

      cd programs
      	change current directory "down" from current into
        directory named "programs"

      cd ..
      	change current directory "up" one level

      cd ~
      	change directory to your "home" directory

      chmod
      	change file permissions. (Use ls -l to see what the
        current file permissions are).

      chmod a+r fileA 
	give "all" people - user, group, and others - read
        permission for file "fileA"

      chmod o-r fileB
      	deny "others" read permission for file "fileB"

      chmod og-rw fileC 
      	deny "others" and "group" - everyone but yourself -
        read and write permission for file "fileC"

      cp
      	copy the contents of a file.

      cp fileA fileB
      	make a copy of file "fileA" and store it in file
        "fileB"

      cp /home/cla/1995/bbrown/test .
      	make a copy of the file "test" in the directory
        "/home/cla/1995/bbrown" and put it in the current 
	working directory (dot)

      df /dev/hda
      	show free space on main file system

      df
      	show free space on all file systems

      df .
      	show free space on the current file system
      
      diff
      	display the difference between two files

      diff fileA fileB > diffs.txt
      	show the difference between file "fileA" and "fileB",
        and place the results in file "diffs.txt"
      
      file
      	identify the file type.

      file fileA
      	tell what kind of file "fileA" is (ie identify a file)
        
      finger
      	show names of users currently logged on.

      finger
      	show current users

      finger jsmith
      	show information about user "jsmith" - jsmith does
        not have to be logged on for this to work

      finger @where.com
      	show current users on the computer named "where.com"

      free
      	show memory status

      grep
      	display lines matching a given pattern.

      grep smith *.txt    
      	list all lines containing the pattern "smith" in all
        files ending with ".txt"

      finger | grep smith 
      	run the finger command and pipe the results to grep
        to see if "smith" is listed as being on the system

      history
      	show numbered list of previous commands

      locate
      	find a specified file, prints any matching pattern
	to the screen. Advice: pipe it through more!
		locate myfile |more
      
      lp
      	print to a system printer.

      lp fileA
      	print file "fileA" on the central - system -
        printer.

      ls
      	list the files in a directory.

      ls
      	display a list of files in the current directory.

      ls programs
      	display a list of files named "programs" or within
        the directory "programs"

      ls -l
      	display a "long" listing of files in the current
        directory - including permissions, owner, size, and
        name

      ls -a
      	display a list of files in the current directory
        including "hidden" files in the current directory
        which begin with . ("dot" files).

      man
      	display online manual pages (see the section below on
      	Online Manual Pages).

      mkdir
      	make a new directory.

      mkdir docs
      	create a new directory named "docs" as a
        sub-directory of the current directory

      more
      	display the contents of a file a page at a time.

      more fileA
      	display file "fileA" on the screen

      who | more
      	display who is logged on, but display a screen at a
        time. while in the more program, the following keystroke
        commands are useful:
      		SpaceBar - advance a full screen forward
      		Enter - advance one line forward
      		/pattern - search forward for "pattern"
      		q - quit the more program

      mv
      	move (or rename) a file (same as copy-and-delete).

      mv fileA fileB
      	rename file "fileA" to "fileB"

      mv john.c /home/cla/1995/aanderso/programs
      	move the file "john.c" into the directory
        "/home/cla/1995/aanderso/programs"

      ps
      	show your current process ID numbers and the names of
        your current processes

      ps -ef
      	show "everybodys" processes, including a "full" listing

      pwd
      	display the current directory name.

      rm
      	remove (delete) one or more files.

      rm fileA
      	remove file "fileA"

      rm -i *.c
      	remove all files ending with ".c", and ask for
        "interactive" confirmation for each file before deleting

      rmdir
      	remove a directory.

      rmdir programs
      	remove the directory "programs" - the directory must be empty

      sort
      	sort the contents of a file - the default is to sort lines
        alphabetically, but other patterns are possible (see the
        manual page on the sort command for additional options)

      sort fileA
      	sort the lines of file "fileA"

      finger | sort
      	display current users sorted alphabetically

      wc
      	count the lines, words, and characters in a file.

      wc fileA
      	display the number of lines, words, and characters in
        file "fileA"

      who
      	show who is logged on.

     -----------------------------------------------------------------------
