UNIX Overview

Document Sample
UNIX Overview Powered By Docstoc
					UNIX Overview
                    UNIX
• UNIX is a multi-user and multi-tasking
  operating system.
• Multi-tasking: Multiple processes can run
  concurrently.
• Example: different users can read mails, copy
  files, and print all at once.



                                                  2
Basic Command Suite
Command                        Meaning
     ls                list files and directories
   ls -a              list all files and directories
  mkdir                    make a directory
cd directory         change to named directory
    cd                change to home-directory
   cd ~               change to home-directory
   cd ..             change to parent directory

   pwd         display the path of the current directory
                            Man Pages
•   Manual pages are on-line manuals which give information about most
    commands
     – Tells you which options a particular command can take
     – How each option modifies the behavior of the command

•   Type man command at the UNIX command line to read the manual for a
    command

•   What does the wc (word count) command do? … Type
    % man wc

•   Alternatively,
    % whatis wc
     – A one-line description of the command, but omits information about options,
       etc.
More Useful Commands
   Command                         Meaning
   cp file1 file2         copy file1 and call it file2
  mv file1 file2        move or rename file1 to file2
      rm file                    remove a file
 rmdir directory             remove a directory
      cat file                   display a file
     less file          display a file a page at a time

     head file        display the first few lines of a file


      tail file       display the last few lines of a file

grep 'keyword' file       search a file for keywords
                             count number of
      wc file
                       lines/words/characters in file
     Command                            Meaning

   command > file          redirect standard output to a file

  command >> file           append standard output to a file

                             redirect standard input from a
   command < file
                                           file
                           pipe the output of command1 to
command1 | command2
                               the input of command2
                             concatenate file1 and file2 to
 cat file1 file2 > file0
                                         file0
          sort                          sort data
         who                  list users currently logged in
         *                 match any number of characters
         ?                        match one character
                           read the online manual page for a
 man command
                                       command
whatis command             brief description of a command
                           match commands with keyword
apropos keyword
                                 in their man pages
   Quick Commands
    Command                           Meaning
      ls -lag               list access rights for all files

chmod [options] file    change access rights for named file

    command &              run command in background

        ^C             kill the job running in the foreground

                          suspend the job running in the
        ^Z
                                   foreground

        bg                background the suspended job
       jobs                       list current jobs
      fg %1                  foreground job number 1
      kill %1                    kill job number 1
        ps                     list current processes
    kill 26152              kill process number 26152
          How to stop a process?
• Foreground processes can generally be stopped by pressing
  CONTROL C (^C).
• Background processes can be stopped using the kill command.
• Usage: kill SIGNAL <process id list>
• kill -9 <process id list> (-9 means no blocked)
   Or kill <process id list>.
• If a foreground process is not stopping by ^C, you can open
  another session and use the kill command.




                                                            8
                  Text editors
•   Different editors: emacs, pico, vi
•   emacs <filename>
•   pico <filename>
•   vi <filename>




                                         9
    The simplest editor: pico or nano
•   pico <filename>
•   Full screen editor
•   Help on the bottom of the screen
•   nano is an extension to pico




                                        10
           Basic operations in pico
•   Ctrl + v : to move page down
•   Ctrl + y : to move page up
•   Ctrl + o : to save the current buffer
•   Ctrl + x : to exit with or without saving
•   Ctrl + g : to get help
•   Ctrl + r : to open a file
•   Ctrl + w : to find a string in the current buffer
•   Ctrl + c : to get the current position in the buffer

                                                           11
       UNIX Tutorial Resources
• http://www.ee.surrey.ac.uk/Teaching/Unix

• http://www.math.utah.edu/lab/unix/unix-
  tutorial.html

• http://www2.ocean.washington.edu/unix.tut
  orial.html
              Get Your Feet Wet
• Read man pages to learn other commands such
  as:
  – gzip, cat, zcat, diff, find, history, diff, more, less,
    source
• Learn about the Bash shell
  – http://www.gnu.org/software/bash/manual/bashref.
    html#Bourne-Shell-Variables

• Debugger
  – Debugging a multi-process program is difficult with a
    debugger such as gdb
  – It is recommended that you use lots of printf
    statements during development

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:2
posted:3/27/2014
language:English
pages:13