Unformatted text preview:

Appendix AMan PagesTypical Man Page SectionsMan Page LayoutExample 1: man whatisExercise A1Example A.1Example A.2Example A.3Example A.4Example A.5File Descriptor I/O, Example A.6Example A.6 (Cont)File Pointer I/O, Example A.7Uninitialized Ptr, Example A.8Garbage, Example A.9Exercise A.3Exercise A.4Exercise A.5Command-Line ArgumentsCommand-Line Arguments (Cont)Example A.10Example A.11Examples A.12-13Example A.14Appendix sections A.2-A.6UNIX ShellsStartup CommandsCommon Environment VariablesEnvironment Variable UsageExercise A.15env CommandPrinting Environment ListAppendix AMan Pagesman whatiswhatis(1)Typical Man Page SectionsSection Contents12345678User commandsSystem callsC library functionsDevices and network interfacesFile formatsGames and demosEnvironments, tables, and troff macrosSystem maintenanceMan Page LayoutHEADER: a title for the individual man pageNAME: a one-line summarySYNOPSIS: describes usageAVAILABILITY: indicates availability on the systemDESCRIPTION: discusses what the command or function doesRETURN VALUES: the return values if applicableERRORS: summarizes errno values and conditions for errorsFILES: lists the system files that the command or function usesSEE ALSO: lists related cmds/additional sects of the manualENVIRONMENT: lists relevant environment variablesNOTES: provides info on unusual usage/implementation featuresBUGS: lists known bugs and caveatsExample 1: man whatiswhatis(1) user commands whatis(1)NAME: whatis – display a one-line summary about a keywordSYNOPSIS: whatis command …DESCRIPTION: whatis looks up a given command and displays the header line from the manual section. You can then run the man(1) command to get more information…FILES: /usr/share/man/windex table of contents andkeyword databaseSEE ALSO:apropos(1), man(1), catman(1M)Exercise A1--More– (41%)Indicates percentage of man page yet to be displayed.To get next screenful, hit space barTo get next line, hit returnTo quit hit qExample A.1man intro displays man page for firstavailable section of a command (in this case the section 1 intro man page intro(1))Example A.2man –k intro displays information about all sections of the man pages:Intro Intro (1) - introduction to commands andapplication programsIntro Intro (1m) - introduction to maintenancecommands and application programsIntro Intro (2) - introduction to system calls anderror numbersIntro Intro (3) - introduction to functions andlibrariesExample A.3man –s 2 introdisplays only section 2 manpage of introExample A.4man –a introDisplays man pages for all introsectionsExample A.5The synopsis entry for system calls indicates the function prototype and library functions to include when using that command. For example, for write(2):SYNOPSIS#include <unistd.h>ssize_t write(int fildes, const void *buf, size_t nbyte);File Descriptor I/O, Example A.6#include <unistd.h>#include<string.h>#define MYMESG “hello world\n”int bytes;bytes=write(STDOUT_FILENO, MYMESG, strlen(MYMESG));Note that if unistd.h were left out of the above example, STDOUT_FILENO would be undefined.Example A.6 (Cont)Standard file descriptors:STDIN_FILENO standard input 0STDOUT_FILENO standard output 1STDERR_FILENO standard error 2File Pointer I/O, Example A.7#include <stdio.h>fprintf(stdout, “hello world”\n);Uninitialized Ptr, Example A.8#include <unistd.h>char *mybuf;size_t nbytes;write(STDOUT_FILENO, mybuf, nbytes);Code will likely produce uninitialized pointer error.Garbage, Example A.9#include <unistd.h>char mybuf[100];size_t nbytes;write(STDOUT_FILENO, mybuf, nbytes);Code would probably print out garbage. Note that write function returns value of type ssize_t. Always capture it and test for errors (i.e., returns –1 with errno set to error type).Exercise A.3write(1)write annieThe above command opens a write session to account annie. Everything typed subsequent appears on annie’s screen. Terminate with ctrl-d. Of course, annie must give permission.Exercise A.4who –HPrints out those who are logged on and on which terminal line.who is part of Spec 1170 but not Posix.2Exercise A.5Print out command definitions with:stty -aCommand-Line ArgumentsConsist of:•Options•Option Arguments•OperandsCommand-Line Arguments (Cont)•Option name consists of single alphanumeric number•All options are preceded by “-”•Options with no option-arguments may be grouped after a single “-”•First option-argument following an option is preceded by a tab or space character•Option-arguments cannot be optional•Groups of option-arguments following an option must either be separated by commas or by tab or space characters and quoted (-o xxx,z,yy or –o “xxx z yy”)•All options must precede operands on the command line•“--” may be used to indicate the end of options•Relative order of options is important•When preceded or followed by a space character, “-” should only be used to indicate standard inputExample A.10ls (1)SYNOPSISls [-abcCdfFgilLmnopqrRstux1] [names]Each letter is described either in the DESCRIPTION or OPTIONS section of the man page.Example A.11apropos cmdlists all man page entries where phrase “cmd” appearswhatis cmdgives a one line synopsis of the cmdwhich cmdgives a complete pathname of the file named “cmd”be careful that it is in the section you wantExamples A.12-13SYNOPSISfind path … [operand-expression …]The following command lists all files in the current directory that end in .c:find –name “*.c” –printExample A.14gcc –o myfile myfile.cCompiles myfile.c and gives executable name myfileWithout –o option, a.out is produced by defaultAppendix sections A.2-A.6Appendix sections A.2-A.6 cover compilation, makefiles, linking and libraries, and debugging aids. You should already be familiar with these concepts. If not, read the sections on your own.UNIX Shells•C shell (csh),•Bourne Shell (sh)•KornShell (ksh)Startup Commands•C shell takes startup commands from .cshrc•Bourn shell and KornShell take startup commands from .profileCommon Environment Variables•HOME=home directory•SHELL=shell of user•PATH=pathnames of directories to be searched when locating commands to be executed•LOGNAME=login name•USER=user name•MANPATH=pathnames of directories to be searched when locating man pages•DISPLAY=display to use for the X Window SystemEnvironment Variable UsageEnvironment variables are normally uppercase. Frequently used environment variables are initialized by the user in the


View Full Document

Chico CSCI 372 - Appendix A Man Pages

Download Appendix A Man Pages
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Appendix A Man Pages and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Appendix A Man Pages 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?