intro unix/linux 02
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,855
On Slideshare
5,826
From Embeds
29
Number of Embeds
4

Actions

Shares
Downloads
527
Comments
0
Likes
1

Embeds 29

http://milbits.blogspot.com 15
http://www.slideshare.net 9
http://profiles.friendster.com 4
http://sol.at.nsu.ru 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Lesson 2-Touring Essential Programs
  • 2. Overview
    • Development of UNIX and Linux.
    • Commands to execute utilities.
    • Communicating instructions to the shell.
    • Navigating the file system.
    • Examining and managing files.
    • Accessing the programmer’s manual.
    • Accessing Internet resources.
  • 3. Development of UNIX and Linux
    • UNIX os, developed in 1970s at Bell Laboratories, features:
        • main program, called kernel , to control CPU and other hardware.
        • collection of user and system programs called utilities .
        • structure, called file system , for keeping and locating data on hard drive.
        • Unix was a multi-user and multi-tasking os
  • 4. Development of UNIX and Linux
    • Linus Torvalds wrote a UNIX look-alike operating system called Linux .
    • The operating system is available for free in its basic form for download, or at a low cost from several distributors.
  • 5.
    • fundamental programs in Linux employ same code , but different distributors add special features and installation programs.
    • Some of different flavors of Linux operating system are RedHat, Lindows, SuSe, Mandrake, etc.
    Development of UNIX and Linux
  • 6. Commands to Execute Utilities
    • Introduction to the shell.
    • Issuing commands to a shell.
    • Passing information to a utility.
    • Listing processes.
  • 7. Introduction to the Shell
    • shell: program which displays prompt on screen.
    • shell reads instructions of user and interprets them to the remainder of the system.
    • Usually $ sign is the prompt in many systems.
    • shell processes and executes command keyed in by user.
  • 8. Issuing Commands to a Shell
    • Various utilities can be executed from the shell prompt.
    • “ whoami ” utility displays user’s login name or username on screen.
    • “ date ” utility displays current date and time on screen.
    • “ hostname ” utility display name of system user working on.
  • 9. Issuing Commands to a Shell
    • “ clear ” utility to clear all text on screen and display the prompt at top of screen or window.
    • Delete or Ctrl-H to correct errors that occur while entering commands.
    • “ who ” utility to display list of users currently logged on.
  • 10. Issuing Commands to a Shell Output of who Command
  • 11. Issuing Commands to a Shell
    • port: physical location at back of computer.
    • Each port has designation- usually begins with tty and number
    • terminal connected through network uses electronic or pseudo port named pts .
  • 12. Issuing Commands to a Shell
    • command/utility keyed in by a user is followed by the ENTER key.
    • shell interprets ENTER as end of command/utility.
    • shell starts child process to execute command/utility.
  • 13. Issuing Commands to a Shell
    • shell locates path of utility/command and executes it.
    • output, by default, connected to screen, unless redirect it.
    • After executing command/utility, it returns command prompt again.
  • 14. Issuing Commands to a Shell How the shell works
  • 15. Passing Information to a Utility
    • When information passed to a utility, shell runs utility, and passes information that comes after the command to utility.
    • Information passed to utility called argument .
    • Arguments provide instructions to utilities.
    • Multiple arguments can also be passed to a utility.
  • 16. Passing Information to a Utility
    • “ cal ” program provides users current month’s calendar.
    • Multiple arguments can be passed to cal utility.
    • When two arguments are passed to cal program, the program interprets first argument as month and second as year.
  • 17. Passing Information to a Utility
    • “ look ” command to locate words in dictionary file that begin with that word, and output all matching words.
    • look command requires one argument – word to locate.
  • 18. Listing Processes
    • A process is an instance of a running program code.
    • “ ps ” command to list all current processes, with some info about each process.
    • output displays process id , port , CPU time , and code process is running.
  • 19. Listing Processes
    • “ – aux ” and “ –ef ” options used with “ ps ” command to display processes running on entire system, including system processes, and list of currently logged on users.
    • Arguments that begin with minus (-) sign are options .
    • ps option useful for sys-admin trouble-shooting system.
  • 20. Communicating Instructions to the Shell
    • Every user is given a place, called home directory , to work with and save files.
    • home directory: default workspace of user.
    • home directory contains names of files and subdirectories created by and owned by a user.
  • 21. Communicating Instructions to the Shell
    • Working with files.
    • Redirecting output from a utility.
    • Determining the role of tokens on command-lines.
    • Starting a child shell.
    • Reissuing commands.
    • Using nicknames for commands.
  • 22. Working with Files
    • “ ls ” (list) command lists contents of current directory’s standard files.
    • “ more ” command displays contents of file one part at a time.
    • command requires one argument – name of the file.
  • 23.
    • spacebar: display additional text in file displayed by more.
    • “ q ” key can to quit ‘ more ’ utility.
    • “ wc ” ( word count ) utility: count number of lines, words, and characters in file.
    • command requires one parameter – name of the file.
    Working with Files
  • 24. Working with Files
    • “– l” option used with wc command to only count number of lines in file.
    • “ -c” option: count characters in file.
    • “ -w” option : count number of words in file.
  • 25. Redirecting Output from a Utility
    • By default, results provided by any utility are displayed on user’s screen.
    • Instructions can be given to redirect output of utility to file.
    • command- redirect output of file: “utility > filename” .
    • > is instruction to redirect output to new file
  • 26. Redirecting Output from a Utility
    • double redirect (>>): append output of utility to end of existing file
    • | (pipe) command: redirect output of one utility to another utility.
    • The argument following the pipeline must be a utility.
  • 27. Determining the Role of Tokens on Command-Lines
    • Each word or object on a command-line is called a token .
    • shell is programmed to read initial token as utility program to run or some action to take
    • location on command-line determines how shell interprets each token.
  • 28. Starting a Child Shell List of Various Shells in UNIX/Linux
  • 29. Reissuing Commands
    • “ !!” command or “r” command: re-execute previously entered command.
    • “ !!” command works only on csh , tch , or bash shell.
    • The “r” command works only on a Korn shell.
    • The sh shell does not allow user to re-execute previously entered commands.
  • 30. Reissuing Commands
    • Up arrow key: display previously entered commands one at a time.
    • shell keeps track of commands we issue at prompt.
    • “ history ” command: list all commands entered previously, and every command has a number associated with it.
  • 31. Reissuing Commands Various Options to Execute Previous Commands
  • 32. Using Nicknames for Commands
    • An “ alias ” or alternate name used for commands hard to remember.
    • alias command can list all current aliases.
    • command “ unalias alias name ” can remove an alias.
  • 33. Using Nicknames for Commands Nicknames for commands in UNIX/Linux Command Shell alias alias name utility name Csh and tch alias alias name=utility name Bash and ksh
  • 34. Navigating the File System
    • arrangement of files and folders in system: file system
    • “ pwd ” ( present working directory ) command can get location of user’s home directory
    • result displays path from root to present working directory
  • 35.
    • topmost directory: “ root ” (identified as / )
    • “ ls / ” command can obtain a list of all files and directories in root directory
    Navigating the File System
  • 36. Navigating the File System
    • “ mkdir ” ( make directory ) command: create new directory
    • command requires 1 argument – name to give to directory
    • “– F” option used with ‘ ls ’ command to include a / (slash) after all directory names and also to identify other kinds of files.
  • 37. Navigating the File System
    • “ cd ” command can make directory the current directory.
    • command requires 1 parameter – name of directory to become current directory
    • cd command: return to home directory. no required parameters
  • 38. Examining and Managing Files
    • Find matching text:
      • A particular word in a file can be located by giving the command “ /word to be located ” .
      • “ n ” key can locate next instance of same word in file.
      • “ b ” key can be used to move one screen backwards.
  • 39. Examining and Managing Files
    • “ head ” utility: read first 10 lines of file
    • “ tail ” utility”: view last 10 lines of file
    • Both utilities require 1 argument – name of file to read
    • number of lines to read can be passed as argument to utilities.
  • 40. Examining and Managing Files
    • cat utility: view entire contents of file
    • utility requires 1 argument – name of file to read.
    • utility is preferable when file small
  • 41. Examining and Managing Files
    • Copy files:
      • “ cp ” command: make copy of existing file, as well as copy files to another subdirectory.
      • 2 arguments are required to duplicate file – name of existing file and name to give duplicated file.
      • arguments required to copy file to another subdirectory are – name of file to copy and target directory
  • 42. Examining and Managing Files
    • Removing files:
      • “ rm ” command: delete file
      • command requires 1 argument – name of file to delete
  • 43. Examining and Managing Files
    • Removing files (cont):
      • rm command does its work and displays prompt. It displays no message.
      • “ -i” option: ask for confirmation before deleting any filenames listed as an argument.
      • command also accepts multiple file names as arguments.
  • 44. Examining and Managing Files
    • Renaming files:
      • “mv” command: rename files, as well as move files from one location to another.
      • 2 arguments are required while renaming files – current name of file and new name to give file
      • arguments required for moving files – name of files to move and destination directory
  • 45. Examining and Managing Files
    • Deciphering utility error messages:
      • Error messages due to failure of utility are shown in screen by default.
      • Every process has " output door ", where it writes output, and an error door, where it writes error messages.
      • By default, " error door " connected to screen unless we redirect it.
  • 46. Examining and Managing Files
    • Printing file:
      • “ lp ” or “ lpr ” command: print file
      • command requires 1 argument – name of file to print.
      • “– P” option with “ lpr ” command, and “-d” option with the lp command, can specify name of printer to use
  • 47. Accessing the Programmer’s Manual
    • UNIX and Linux systems include extensive collection of powerful utility programs, system features, application languages, and support libraries.
    • The UNIX programmer’s manual provides info needed to employ exact syntax of a particular option or command format for a utility.
  • 48. Accessing the Programmer’s Manual
    • manual contains detailed documentation on use and function of utility programs, application programs, and libraries.
    • manual also contains info on UNIX system files and system programming libraries.
    • includes supplementary info on related special files and commands for each entry.
  • 49. Accessing the Programmer’s Manual
    • man command: provide online manual entry for utility or command
    • command requires 1 argument – name of utility or command
    • “ man –k” command: search manual pages’ descriptions for keywords.
  • 50. Accessing Internet Resources
    • Internet includes many useful sites that provide info on:
        • Recent news in Linux world (www.linux.org/www.linux.com).
        • Interactive Web tutorials
        • Recent software updates and Linux code documentation.
  • 51. Summary
    • shell: process that interprets commands entered by user
    • Each word or object on command-line: token
    • All shells, except for sh, allow users to create alias names for commands
    • file system: collection of files and folders
  • 52. Summary
    • We can work on many utilities, print files, and access system folders from a shell.
    • Files can be printed from shell prompt.
    • Online manual pages provide detailed description of system utilities, files, and functionalities.
    • Internet includes useful sites that provide info on various aspects of UNIX and Linux.