1 / 52

Essential Programs in UNIX and Linux

Learn about the development of UNIX and Linux, how to execute utilities and communicate instructions to the shell, navigate the file system, examine and manage files, and access programmer's manual and internet resources.

bcharlotte
Download Presentation

Essential Programs in UNIX and Linux

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation 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 The UNIX operating system, developed in the 1970s at Bell Laboratories, consisted of the following features: • A main program, called kernel, to control the central processing unit (CPU) and other hardware. • A collection of user and system programs called utilities. • A structure, called file system, for keeping and locating data on the hard drive. • Unix was a multi-user and multi-tasking operating system.

  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. Development of UNIX and Linux • The fundamental programs in Linux employ the 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.

  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 • The shell is a program, which displays the prompt on the screen. • The shell reads the instructions of the user and interprets them to the remainder of the system. • Usually the $ sign is the prompt in many systems. • The shell processes and executes the command keyed in by a user.

  8. Issuing Commands to a Shell • Various utilities can be executed from the shell prompt. • The “whoami” utility displays a user’s login name or username on the screen. • The “date” utility displays the current date and time on the screen. • The “hostname” utility is used to display the name of the system the user is working on.

  9. Issuing Commands to a Shell • The “clear” utility is used to clear all the text on the screen and display the prompt at the top of the screen or window. • The Delete key or the Ctrl-H key can be used to correct errors that occur while entering commands. • The “who” utility is used to display a list of users who have currently logged on.

  10. Issuing Commands to a Shell Output of who Command

  11. Issuing Commands to a Shell • A port is a physical location at the back of the computer. • Each port has a designation that usually begins with the letters tty and a number. • A terminal connected through a network uses an electronic or pseudo port named pts.

  12. Issuing Commands to a Shell • The command/utility keyed in by a user is followed by the ENTER key. • The shell interprets the ENTER as the end of the command/utility. • The shell starts a child process to execute the command/utility.

  13. Issuing Commands to a Shell • The shell locates the path of the utility/command and executes it. • The output is, by default, connected to the screen, unless we redirect it. • After executing the command/utility, it returns the command prompt again.

  14. Issuing Commands to a Shell How the shell works

  15. Passing Information to a Utility • When any information is passed to a utility, the shell runs the utility, and passes the information that comes after the command to the utility. • Information passed to the utility is called an argument. • Arguments provide instructions to utilities. • Multiple arguments can also be passed to a utility.

  16. Passing Information to a Utility • The “cal” program provides the users with the current month’s calendar. • Multiple arguments can be passed to the cal utility. • When two arguments are passed to the cal program, the program interprets the first argument as the month and the second as the year.

  17. Passing Information to a Utility • The “look” command is used to locate words in the dictionary file that begin with that word, and output all the matching words. • The look command requires one argument – the word that needs to be located.

  18. Listing Processes • A process is an instance of a running program code. • The “ps” command can be used to obtain a list all the current processes, with some information about each process. • The output displays the process id, the port, CPU time, and the code that the process is running.

  19. Listing Processes • The “–aux” and “–ef” command options are used with the “ps” command to display the processes running on the entire system, including system processes, and a list of currently logged on users. • Arguments that begin with a minus (-) sign are options. • The ps option is useful for system administrators in trouble-shooting the system.

  20. Communicating Instructions to the Shell • Every user is given a place, called the home directory, to work with and save files. • The home directory is the default workspace of a user. • The home directory contains the 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 • The “ls” (list) command lists the contents of the current directory’s standard files. • The “more” command displays the contents of a file one part at a time. • The command requires one argument – the name of the file.

  23. Working with Files • The spacebar can be used to display additional text in a file displayed by more. • The “q” key can be used to quit the ‘more’ utility. • The “wc” (word count) utility is used to count the number of lines, words, and characters in a particular file. • The command requires one parameter – the name of the file.

  24. Working with Files • The “–l” option can be used with the wc command to only count the number of lines in a file. • The “-c” option is used to count the number of characters in the file. • The “-w” option is used to count the number of words in the file.

  25. Redirecting Output from a Utility • By default, the results provided by any utility are displayed on the user’s screen. • Instructions can be given to redirect the output of a utility to a file. • The command to redirect the output of a file is “utility > filename”. • The > is the instruction to redirect the output to a new file.

  26. Redirecting Output from a Utility • The double redirect (>>) can be used to append the output of a utility to the end of an existing file. • The | (pipe) command can be used to redirect the 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. • The shell is programmed to read the initial token as a utility program to run or some action to be taken. • The location on the command-line determines how the shell interprets each token.

  28. Starting a Child Shell List of Various Shells in UNIX/Linux

  29. Reissuing Commands • The “!!” command or the “r” command can be used to re-execute a previously entered command. • The “!!” command works only on a csh, a tch, or a bash shell. • The “r” command works only on a Korn shell. • The sh shell does not allow a user to re-execute previously entered commands.

  30. Reissuing Commands • The Up arrow key can be used to display previously entered commands one at a time. • The shell keeps track of the commands that we issue at the prompt. • The “history” command can be used to provide a list of all the 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 can be used for commands that are hard to remember. • The alias command can be used to provide a list of all the current aliases. • The command “unalias alias name” can be used to remove an alias.

  33. Command Shell alias alias name utility name Csh and tch alias alias name=utility name Bash and ksh Using Nicknames for Commands Nicknames for commands in UNIX/Linux

  34. Navigating the File System • The arrangement of files and folders in a system is called the file system. • The “pwd” (present working directory) command can be used to get the location of the user’s home directory. • The result displays the path from the root to the present working directory.

  35. Navigating the File System • The topmost directory is called the “root,” and is identified as /. • The “ls /” command can be used to obtain a list of all the files and directories in the root directory.

  36. Navigating the File System • The “mkdir” (make directory) command is used to create a new directory. • The command requires one argument – the name to be given to the directory. • The “–F” option can be used with the ‘ls’ command to include a / (slash) after all the directory names, and also to identify other kinds of files.

  37. Navigating the File System • The “cd” command can be used to make a directory the current directory. • The command requires one parameter – the name of the directory that needs to be made the current directory. • The cd command is used to return to the home directory. It does not require any parameters.

  38. Examining and Managing Files Finding matching text: • A particular word in a file can be located by giving the command “/word to be located”. • The “n” key can be used to locate the next instance of the same word in the file. • The “b” key can be used to move one screen backwards.

  39. Examining and Managing Files • The “head” utility can be used to read the first ten lines of a file. • The “tail” utility can be used to view the last ten lines of a file. • Both the utilities require one argument – the name of the file to be read. • The number of lines to be read can also be passed as an argument to the utilities.

  40. Examining and Managing Files • The cat utility can be used to view the entire contents of a file. • The utility requires one argument – the name of the file to be read. • This utility is preferable when a file is small.

  41. Examining and Managing Files Copying files: • The “cp” command can be used to make a copy of an existing file, as well as copy files to another subdirectory. • Two arguments are required to make a duplicate of a file – the name of the existing file and the name to be given to the duplicated file. • The arguments required to copy a file to another subdirectory are – the name of the file to be copied and the target directory.

  42. Examining and Managing Files Removing files: • The “rm” command can be used to delete a file. • The command requires one argument – the name of the file to be deleted.

  43. Examining and Managing Files Removing files (continued): • The rm command does its work and displays the prompt. It displays no message. • The “-i” option can be used with the command to ask for confirmation before deleting any filenames listed as an argument. • The command also accepts multiple file names as arguments.

  44. Examining and Managing Files Renaming files: • The “mv” command can be used to rename files, as well as to move files from one location to another. • Two arguments are required while renaming the files – the current name of the file and the new name to be given to the file. • The arguments required for moving the files are – the name of the files to be moved and the destination directory.

  45. Examining and Managing Files Deciphering utility error messages: • Error messages that occur due to the failure of a utility are shown in the screen by default. • Every process has an "output door", where it writes output, and an error door, where it writes error messages. • By default, the "error door" is connected to the screen, unless we redirect it.

  46. Examining and Managing Files Printing a file: • The “lp” or the “lpr” command can be used to print a file. • The command requires one argument – the name of the file to be printed. • The “–P” option with the “lpr” command, and the “-d” option with the lp command, can be used to specify the name of the printer to be used.

  47. Accessing the Programmer’s Manual • The UNIX and Linux systems include an extensive collection of powerful utility programs, system features, application languages, and support libraries. • The UNIX programmer’s manual provides the information needed to employ the exact syntax of a particular option or command format for a utility.

  48. Accessing the Programmer’s Manual • The manual contains a detailed documentation on the uses and functions of utility programs, application programs, and libraries. • The manual also contains information on UNIX system files and system programming libraries. • It also includes supplementary information on related special files and commands for each entry.

  49. Accessing the Programmer’s Manual • The man command can be used to provide an online manual entry for a utility or a command. • The command requires one argument – the name of the utility or the command. • The “man –k” command can be used to search the manual pages’ descriptions for keywords.

  50. Accessing Internet Resources The Internet includes many useful sites that provide information on: • Recent news in the Linux world (www.linux.org/www.linux.com). • Interactive Web tutorials. • Recent software updates and Linux code documentation.

More Related