Page 411 - DCAP103_Principle of operating system
P. 411

Principles of Operating Systems



                   Notes         written in shell language. The Berkeley C shell is an alternative shell that has been designed
                                 to make shell scripts (and the command language in general) look like C programs in many
                                 respects. Since the shell is just another user program, various other people have written and
                                 distributed a variety of other shells.
                                 14.1.4 Linux Utility Programs

                                 The command-line (shell) user interface to Linux consists of a large number of standard utility
                                 programs. These programs can be divided into six categories as follows:

                                    1.  File and directory manipulation commands.
                                    2.  Filters.
                                    3.  Program development tools such as editors and compilers.

                                    4.  Text processing.
                                    5.  System administration.

                                    6.  Miscellaneous.
                                 The POSIX 1003.2 standard specifies the syntax and semantics of just under 100 of these, primarily
                                 in the first three categories. The idea of standardizing them is to make it possible for anyone to
                                 write shell scripts that use these programs and work on all Linux systems.

                                 In addition to these standard utilities, there are many application programs as well, such as
                                 Web browsers, image viewers, etc. Let us consider some examples of these programs, starting
                                 with file and directory manipulation. cp a b copies file a to b, leaving the original file intact.
                                 In contrast, mv a b copies a to b but removes the original. In fact, it moves the file rather than
                                 really making a copy in the usual sense. Several files can be concatenated using cat, which reads
                                 each of its input files and copies them all to standard output, one after another. Files can be
                                 removed by the rm command. The chmod command allows the owner to change the rights bits
                                 to modify access permissions. Directories can be created with mkdir and removed with rmdir.
                                 To see a list of the files in a directory, it can be used. It has a vast number of flags to control
                                 how much detail about each file is shown (e.g., size, owner, group, creation date), to determine
                                 the sort order (e.g., alphabetical, by time of last modification, reversed), to specify the layout on
                                 the screen, and much more. We have already seen several filters: grep extracts lines containing
                                 a given pattern from standard input or one or more input files; sort sorts its input and writes
                                 it on standard output; head extracts the initial lines of its input; tail extracts the final lines of
                                 its input. Other filters defined by 1003.2 are cut and paste, which allow columns of text to be
                                 cut and pasted into files; od which converts its (usually binary) input to ASCII text, in octal,
                                 decimal, or hexadecimal; tr, which does character translation (e.g., lower case to upper case),
                                 and pr which formats output for the printer, including options to include running heads, page
                                 numbers, and so on.
                                 Compilers  and  programming  tools  include  gcc,  which  calls  the  C  compiler,  and  ar,  which
                                 collects library procedures into archive files. Another important tool is make, which is used to
                                 maintain large programs whose source code consists of multiple files. Typically, some of these
                                 are header files, which contain type, variable, macro, and other declarations. Source files often
                                 include these using a special include directive. This way, two or more source files can share the
                                 same declarations. However, if a header file is modified, it is necessary to find all the source
                                 files that depend on it, and recompile them. The function of make is to keep track of which file
                                 depends on which header, and similar things, and arrange for all the necessary compilations
                                 to occur automatically. Nearly all Linux programs, except the smallest ones, are set up to be




        404                               LOVELY PROFESSIONAL UNIVERSITY
   406   407   408   409   410   411   412   413   414   415   416