Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!star.cs.vu.nl!ast@cs.vu.nl From: ast@cs.vu.nl (Andy Tanenbaum) Newsgroups: comp.os.minix Subject: 1.5.0 #12 Revised /usr/man/man1 part 1 of 2 Message-ID: <4819@ast.cs.vu.nl> Date: 17 Dec 89 22:12:34 GMT Sender: ast@cs.vu.nl Reply-To: ast@cs.vu.nl (Andy Tanenbaum) Organization: VU Informatica, Amsterdam Lines: 1217 It has been pointed out to me that I nroffed the /usr/man/man1 file 80 columns wide, which is a disaster if you have LINEWRAP on. I have it off, so I didn't notice. Here is a revised version, 79 columns wide. Cat this and the next file together and install in /usr/man/man1. Andy Tanenbaum (ast@cs.vu.nl) ----------------- cut here for first part of /usr/man/man1 -------------- #animals Command: animals - twenty questions type guessing game about animals Syntax: animals [database] Flags: (none) Example: animals # Start the game Animals is a guessing game. The user picks an animal and the computer tries to guess it by posing questions that should be answered by typing ``y'' for yes and ``n'' for no. Whenever the computer loses, it asks some questions that allow it to improve its data base, so as time goes on, it learns. The default data base should be in /usr/lib/animals. #ar Command: ar - archiver Syntax: ar [qrxdpmt][abivulc] [posname] archive file ... Flags: (none) Examples: ar r libc.a sort.s # Replace sort.s in libc.a ar rb a.s libc.a b.s # Insert b.s before a.s in libc.a Ar allows groups of files to be put together into a single archive. It is normally used for libraries of compiled procedures. The following keys are allowed: q: quickly append to the end of the archive file. m: move named files. Ar expects a, b, or i to be specified. r: replace (append when not in archive). d: delete. Ar will delete the named members. t: print the archive's table of contents. p: print the named files (list them on stdout) x: extract The keys may optionally concatencated with one or more of the following: l: local temporary file for work instead of /tmp/ar.$$$$$ v: verbose a: after posname b: before posname i: before posname c: create (suppresses creation message) u: replace only if dated later than member in archive #ascii Command: ascii - strip all the pure ASCII lines from a file Syntax: ascii [-n] [file] Flags: -n Extract the lines containing nonASCII characters Examples: ascii file >outf # Write all the ASCII lines on outf ascii -n outf # Write all thenonASCII lines on outf Sometimes a file contains some nonASCII characters that are in the way. This program allows the lines containing only ASCII characters to be grepped from the file. With the -n flag, the nonASCII lines are grepped. No matter whether the flag is used or not, the program returns an exit status of true if the file is pure ASCII, and false otherwise. #asld Command: asld - assembler-loader Syntax: asld [-d] [-s] [-o name] file... Flags: -L A listing is produced on stdout -T Used to specify a directory for the temporary file -o Output goes to file named by next argument -i Use separate I & D space (64K + 64K) -s A symbol table is produced on stdout Examples: asld -s file.s # Assemble file.s and list symbols asld -o output file.s # Assemble file.s, put binary on output asld -T. file1.s file2.s # Use current directory for temporary file Asld is the MINIX assembler and loader combined. It accepts a language similar to that accepted by the PC-IX assembler. Symbols are made up of letters, digits and underscores. The machine instructions and addressing modes are the same as those used by PC-IX, except that modes using multiple registers are written like this example: mov ax,(bx_si). Constant operands are denoted by a number sign. Local labels are permitted in the usual UNIX style: the instruction jmp 1f jumps forward to the closest label 1: The pseudoinstructions accepted by the assembler are listed below: .align n Align to a multiple of n bytes .ascii strAssemble a string .asciz strAssemble a zero-terminated string .bss What follows goes in the bss segment .byte n Assemble one or more bytes .data What follows goes in the data segment .define symExport sym from the file .errnz n Force error if n is nonzero .even Align to an even address .extern symDeclare sym external .globl symSame as extern .long n Assemble n as a long .org adr Set address within current segment .short n Assemble n as a short .space n Skip n bytes .text What follows goes in the text segment .word n Assemble n as a word .zerow n Assemble n words of zeros In the above pseudoinstructions, adr is an expression yielding a machine address, n is a numeric expression, str is a quoted string, and sym is a sym- bol. The library /usr/lib/libc.a is a packed archive of assembly code. To see some examples of it, extract some files from the archive with ar and then use the filter libupack to convert them to readable ASCII. MINIX does not use .o files. Compiler output is packed assembly language, as are the modules in an archive. This scheme requires reassembling archive modules all the time, but it saves precious diskette space. #ast Command: ast - add symbol table to executable file Syntax: ast [-xX] [file] [symbol_file] Flags: -x Do not preserve local symbols -X preserve Example: ast -X a.out # Add symbols from symbol.out to a.out Ast adds the symbol table produced by the -s option of asld to the execut- able file. If no symbol table file is listed, the default name symbol.out is used. The symbol table can be generated by the command cc -s file.c >symbol.out. #at Command: at - execute commands at a later time at time [month day] [file] Flags: (none) Examples: at 2315 Jan 31 myfile # Myfile executed Jan 31 at 11:15 pm at 0900 # Job input read from stdin at 0711 4 29 # Read from stdin, exec on April 29 At prepares a file to be executed later at the specified time by creating a special entry in /usr/spool/at. The program atrun should be started periodi- cally, for example, every minute by cron. Atrun checks to see if any files in /usr/spool/at should now be run, and if so, it runs them and then puts them in /usr/spool/at/past. The name of the file created in /usr/spool/at by at is YY.DDD.HHMM.UU (where YY, DDD, HH, and MM give the time to execute and UU is a unique number). Note that when the command runs, it will not be able to use stdin or stdout unless specifically redirected. In the first example above, it might be necessary to put >/dev/tty0 on some lines in the shell script myfile. The same holds for the commands typed directly to at. #backup Command: backup - backup files Syntax: backup [-dmnvz] Flags: -d At top level, only directories are backed up -j Do not copy junk: *.o, *.Z, *.bak, a.out, core, etc -m If device full, prompt for new diskette -n Do not backup top-level directories -s Do not copy *.s files -t Preserve creation times -v Verbose; list files being backed up -z Compress the files on the backup medium Examples: backup -mz . /f0 # Backup current directory compressed backup /bin /usr/bin # Backup bin from RAM disk to hard disk Backup (recursively) backs up the contents of a given directory and its sub- directories to another part of the file system. It has two typical uses. First, some portion of the file system can be backed up onto 1 or more diskettes. When a diskette fills up, the user is prompted for a new one. The backups are in the form of mountable file systems. Second, a directory on RAM disk can be backed up onto hard disk. If the target directory is empty, the entire source directory is copied there, optionally compressed to save space. If the target directory is an old backup, only those files changed since the backup was made are copied. Backup uses times for this purpose, like make. #badblocks Command: badblocks - put a list of bad blocks in a file Syntax: badblocks block_special Flags: (none) Example: badblocks /dev/fd1 # Handle bad blocks on /dev/fd1 If a device develops bad sectors, it is important to not have them allocated to important files. This program makes it possible to collect up to 7 bad blocks into a file, so they will not be allocated for a ``real'' file. When the program starts up, it asks for a list of bad blocks. Then it creates a file whose name is of the form .Bad_xxxxx, where xxxxx is a pid. #banner Command: banner - print a banner Syntax: banner arg ... Flags: (none) Example: banner happy birthday # Print a banner saying happy birthday Banner prints its arguments on stdout using a matrix of 6 x 6 pixels per character. The @ sign is used for the pixels. #basename Command: basename - strip off file prefixes and suffixes Syntax: basename file [suffix] Flags: (none) Examples: basename /user/ast/file # Strips path to yield file basename /user/file.c .c # Strips path and .c to yield file The initial directory names (if any) are removed yielding the name of the file itself. If a second argument is present, it is interpreted as a suffix and is also stripped, if present. This program is primarily used in shell scripts. #bawk Command: bawk - pattern matching language Syntax: bawk rules [file] ... Flags: (none) Examples: bawk rules input # Process input according to rules bawk rules - >out # Input from terminal, output to out Awk is a pattern matching language. Bawk is Basic Awk, a subset of the ori- ginal. The language is described in /usr/doc/bawk.doc. The file name - can be used to designate stdin. #btoa Command: btoa - binary to ascii conversion Syntax: btoa [-adhor] [infile] [outfile] Flags: -a Decode, rather than encode, the file -d Extracts repair file from diagnosis file -h Help menu is displayed giving the options -o The obsolete algorithm is used for backward compatibility -r Repair a damaged file Examples: btoa a.btoa # Convert a.out to ASCII btoa -a a.out # Reverse the above Btoa is a filter that converts a binary file to ascii for transmission over a telephone line. If two file names are provided, the first in used for input and the second for output. If only one is provided, it is used as the input file. The program is a functionally similar alternative to uue/uud, but the encoding is completely different. Since both of these are widely used, both have been provided with MINIX. The file is expanded about 25 percent in the process. #cal Command: cal - print a calendar Syntax: cal [month] year Flags: (none) Example: cal 3 1992 # Print March 1992 Cal prints a calendar for a month or year. The year can be between 1 and 9999. Note that the year 91 is not a synonym for 1991, but is itself a valid year about 19 centuries ago. The calendar produced is the one used by England and her colonies. Try Sept. 1752, Feb 1900, and Feb 2000. If you don't under- stand what is going on, look up Calendar, Gregorian in a good encyclopedia. #cat Command: cat - concatenate files and write them to stdout Syntax: cat [-u] file... Flags: -u Unbuffered output Examples: cat file # Display file on the terminal cat file1 file2 | lpr # Concatenate 2 files and print result Cat concatenates its input files and copies the result to stdout. If no input file is named, or - is encountered as a file name, standard input is used. Output is buffered in 512 byte blocks unless the -u flag is given. #cc Command: cc - C compiler Syntax: cc [-FRSTUciosuw] [-Dname]... [-Idir]... [-LIB] file ... Flags: -D The flag -Dx=y defines a macro x with value y -F Use a file instead of a pipe for preprocessor output -I -Idir searches dir for include files -LIB Produce a library module -R Complain about all non Kernighan & Ritchie code -S Produce an assembly code file, then stop -T The flag -Tdir tells cem to use dir for temporary files -U Undefine a macro -c Compile only. Do not link. (Same as -S) -i Use separate I & D space (64K + 64K) -o Put output on file named by next arg -s Include symbol table in executable file -v Verbose. Print pass names -w Suppress warning messages Examples: cc -c file.c # Compile file.c cc -D_MINIX file.c # Treat the symbol _MINIX as defined cc -c -LIB file.c # Make a module for the library cc -R -o out file.c # Check for K & R; output to out This is the C compiler. It has five passes, as follows: Program Input Output Operation performed /lib/cpp prog.c prog.i C preprocessor: #include, #define, #ifdef /lib/cem prog.i prog.k Parsing and semantic analysis /usr/lib/opt prog.k prog.mOptimization of the intermediate code /usr/lib/cg prog.m prog.sCode generation /usr/lib/asld prog.s a.outAssembly and linking The main program, cc, forks appropriately to call the passes, transmitting flags and arguments. The -v flag causes the passes to be listed as they are called. The -c or -S flags stop compilation when cg has produced an assembly code file (in packed format) because the current assembler-loader expects that (see under File Formats later in this appendix). The libraries are also archives of packed assembly code files, except that defined symbols must be declared by .define statements at the beginning. To make modules for inclusion in the library, use the -c and -LIB options. There is no way to get .o files; the packed assembly language files are used as a substitute. They can be unpacked with the filter libupack. The -R flag gives warnings about all constructions not permitted by official Kernighan and Ritchie C. The average garden-variety C program that has been flawlessly acceptedly by most C compilers contains surprisingly many illegal constructions. Try it. The compiler normally keeps cpp and cem in memory at the same time, transferring the output of cpp to cem using a pipe. However, if there is insufficient memory available to hold both at once, the -F flag can be given to cause these two passes to be run strictly sequentially, with the preprocessor output being stored on a file in /tmp (unless -T is used). When available memory is very limited (e.g., a 512K machine), it may be necessary to run chmem to reduce the sizes of the compiler passes that do not fit, typically cem. The other passes, especially asld, can create large temporary files in /tmp. To compile very large programs, first type cc -c *.c to get .s files. Then remove /lib/cpp and /lib/cem and possibly other files from the RAM disk to make more space for /tmp. Finally, type cc *.s which results in asld /usr/lib/crtso.s *.s /usr/lib/libc.a /usr/lib/end.s to produce the a.out file. The files removed from the RAM disk can be restored by mounting the root file system and copying them from there, or the system can be shut down and rebooted. If the compiler (or, in fact, almost any program) begins acting strange, it is almost always due to its running out of space, either stack space or scratch file space. The relevant pass can be given more stack space using chmem. More space for scratch files can be obtained by removing other files on the device. The compiler is derived from the ACK system (Tanenbaum et al., 1983), not from the AT&T portable C compiler. It has been shoehorned onto the PC with some loss of performance. #cdiff Command: cdiff - context diff Syntax: cdiff [-c] old new Flags: -cn How much context to provide Examples: cdiff old new >f # Write context diff on f cdiff -c1 old new >f # Use only 1 line of context Cdiff produces a context diff by first running diff and then adding context. Some update programs, like patch, can use context diffs to update files, even in the presence of other, independent changes. #cgrep Command: cgrep - grep and display context Syntax: cgrep [-a n] [-b n] [-l n] [-w n] pattern [file] ... Flags: -a How many lines to display after the matching line -b How many lines to display before the matching line -f Suppress file name in the output -l Lines are truncated to this length before comparison -n Suppress line numbers in the output -w Sets window size (same as -a n -b n) Example: cgrep -w 3 hello file1 # Print 3 lines of context each way Cgrep is a program like grep, except that it also can print a few lines above and/or below the matching lines. It also prints the line numbers of the output. #chgrp Command: chgrp - change group Syntax: chgrp group file ... Flags: (none) Example: chgrp system file1 file2 # Make system the group of the files The group field of the named files is changed to group. Alternatively, a decimal gid may be specified instead of a user name. Only the super-user may execute this command. #chmem Command: chmem - change memory allocation Syntax: chmem [+] [-] [=] amount file Flags: (none) Examples: chmem =50000 a.out # Give a.out 50K of stack space chmem -4000 a.out # Reduce the stack space by 4000 bytes chmem +1000 file1 # Increase each stack by 1000 bytes When a program is loaded into memory, it is allocated enough memory for the text and data+bss segments, plus an area for the stack. Data segment growth using malloc, brk, or sbrk eats up stack space from the low end. The amount of stack space to allocate is derived from a field in the executable program's file header. If the combined stack and data segment growth exceeds the stack space allocated, the program will be terminated. It is therefore important to set the amount of stack space carefully. If too little is provided, the program may crash. If too much is provided, memory will be wasted, and fewer programs will be able to fit in memory and run simul- taneously. MINIX does not swap, so that when memory is full, subsequent attempts to fork will fail. The compiler sets the stack space to the largest possible value (for the Intel CPUs, 64K - text - data). For many programs, this value is far too large. Nonrecursive programs that do not call brk, sbrk, or malloc, and do not have any local arrays usually do not need more than 8K of stack space. The chmem command changes the value of the header field that determines the stack allocation, and thus indirectly the total memory required to run the pro- gram. The = option sets the stack size to a specific value; the + and - options increment and decrement the current value by the indicated amount. The old and new stack sizes are printed. #chmod Command: chmod - change access mode for files Syntax: chmod octal-number file ... chmod [augo][+-=][rwxst] file ... Flags: (none) Examples: chmod 755 file # Owner: rwx Group: r-x Others: r-x chmod +x file1 file2 # Make file1 and file2 executable chmod a-w file # Make file read only chmod u+s file # Turn on SETUID for file chmod g=u # Group perms set to same as user perms. The given mode is applied to each file in the file list. The mode can be either absolute or symbolic. Absolute modes are given as an octal number that represents the new file mode. The mode bits are defined as follows: 4000 Set effective user id on execution to file's owner id 2000 Set effective group id on execution to file's group id 0400 file is readable by the owner of the file 0200 writeable by owner 0100 executable by owner 0070 same as above, for other users in the same group 0007 same as above, for all other users Symbolic modes modify the current file mode in a specified way. They take the form: [who] op permissions { op permissions } The possibilities for [who] are u, g, o, and a, standing for user, group, other and all, respectively. If [who] is omitted, a is assumed, but the current umask is used. The op can be +, -, or =; + turns on the given permissions, - turns them off; = sets the permissions exclusively for the given who. For example g=x sets the group permissions to --x. The possible permissions are r, w, x; which stand for read, write, and exe- cute; s turns on the set effective user/group id bits. u, g and o in the per- missions field stand for the current user, group, or other permission bits, respectively. Only one of these may be used at a time. s only makes sense with u and g; o+s is harmless and does nothing. Multiple symbolic modes may be specified, separated by commas. #chown Command: chown - change owner Syntax: chown user file ... Flags: (none) Example: chown ast file1 file2 # Make ast the owner of the files The owner field of the named files is changed to user (i.e., login name specified). Alternatively, a decimal uid may be specified instead of a user name. Only the super-user may execute this command. #clr Command: clr - clear the screen Syntax: clr Flags: (none) Example: clr # Clear the screen All text is removed from the screen, resulting in an empty screen with the cursor positioned in the upper left-hand corner. #cmp Command: cmp - compare two files cmp [-ls] file1 file2 Flags: -l Loud mode. Print bytes that differ (in octal) -s Silent mode. Print nothing, just return exit status Examples: cmp file1 file2 # Tell whether the files are the same cmp -l file1 file2 # Print all corresponding bytes that differ Two files are compared. If they are identical, exit status 0 is returned. If they differ, exit status 1 is returned. If the files cannot be opened, exit status 2 is returned. If file1 is - , stdin is compared to file2. #comm Command: comm - print lines common to two sorted files Syntax: comm [-123] file1 file2 Flags: -1 Suppress column 1 (lines only in file1) -2 Suppress column 2 (lines only in file2) -3 Suppress column 3 (lines in both files) Examples: comm file1 file2 # Print all three columns comm -12 file1 file2 # Print only lines common to both files Two sorted files are read and compared. A three column listing is produced. Files only in file1 are in column 1; files only in file2 are in column 2; files common to both files are in column 3. The file name - means stdin. #compress Command: compress - compress a file using modified Lempel-Ziv coding Syntax: compress [-cdfv] [file] ... Flags: -c Put output on stdout instead of on file.Z -d Decompress instead of compress -f Force output even if there is no saving -v Verbose mode Examples: compress outfile # Compress 1 file compress x y z # Compress 3 files to x.Z, y.Z, and z.Z compress -d file.Z # Decompress file.Z to file The listed files (or stdin, if none are given) are compressed using the Ziv-Lempel algorithm. If the output is smaller than the input, the output is put on file.Z or stdout if no files are listed. If compress is linked to uncompress, the latter is the same as giving the -d flag. Similarly, a link to zcat decompresses to stdout. #cp Command: cp - copy file Syntax: cp file1 file2 cp file ... directory Flags: (none) Examples: cp oldfile newfile # Copy oldfile to newfile cp file1 file2 /usr/ast # Copy two files to a directory Cp copies one file to another, or copies one or more files to a directory. A file cannot be copied to itself. #cpdir Command: cpdir - copy a directory and its subdirectories Syntax: cpdir [-v] srcdir destdir Flags: -v Verbose; cpdir tells what it is doing Example: cpdir dir1 dir2 # Creat dir2 and copy dir1's files into it Cpdir creates the target directory, goes into it, and copies all the files in the source directory to it. When it is done, the target directory contains the same files as the source directory. Subdirectories are copied recursively. Links and special files are ignored. #crc Command: crc - print the checksum of the file data Syntax: crc file ... Flags: (none) Example: crc *.c # Print checksums of all the C programs The checksum of each argument is computed and printed, along with the file length and its name, one file per lie. This program is useful for seeing if a file transmitted to another machine has arrived correctly. It is conceptually similar to sum, except that it uses a stronger checksum algorithm and also prints the length. #cron Command: cron - clock daemon Syntax: cron Flags: (none) Example: /usr/bin/cron # Use absolute path in /etc/rc Cron is clock daemon. It is typically started up by including the command /usr/bin/cron in the /etc/rc file. Once started, cron puts itself in the back- ground, so no & is needed. It runs forever, sleeping most of the time. Once a minute it wakes up and examines /usr/lib/crontab to see if there is any work to do. If there is, the work is done. The entries of /usr/lib/crontab contain 6 elements each. Some examples follow: min hr dat mo daycommand * * * * * /usr/bin/date >/dev/tty0 #print date every minute 0 * * * * /usr/bin/date >/dev/tty0 #print date on the hour 30 4 * * 1-5 /bin/backup /dev/fd1 #do backup Mon-Fri at 0430 30 19 * * 1,3,5 /etc/backup /dev/fd1 #Mon, Wed, Fri at 1930 0 9 25 12 * /usr/bin/sing >/dev/tty0 #Xmas morning at 0900 only #cut Command: cut - select out columns of a file Syntax: cut [-i] [-dc] [-farg] cut [-carg] Flags: -dc Change the column delimiter to c -i Runs of delimiters count as one Examples: cut -f2 file # Extract field 2 cut -c1-2,5 file # Extract character columns 1, 2, and 5 cut -c1-5,7- file # Extract all columns except 6 Cut extracts one or more fields or columns from a file and writes them on standard output. If the -f flag is used, the fields are separated by a delim- iter character, normally a tab, but can be changed using the -d flag. If the -c flag is used, specific columns can be specified. The -f and -c flags are mutually exclusive. #date Command: date - print or set the date and time Syntax: date [[MMDDYY]hhmm[ss]] Flags: -q Read the date from stdin Examples: date # Print the date and time date 0221921610 # Set date to Feb 21, 1992 at 4:10 p.m. Without an argument, date prints the current date and time. With an argu- ment, it sets the date and time. MMDDYY refers to the month, day, and year; hhmmss refers to the hour, minute and second. Each of the six fields must be exactly two digits. #dd Command: dd - disk dumper Syntax: dd [option = value] ... Flags: (none) Examples: dd if=/dev/fd0 of=/dev/fd1 # Copy disk 0 to disk 1 dd if=x of=y bs=1w skip=4 # Copy x to y, skipping 4 words dd if=x of=y count=3 # Copy three 512-byte blocks This command is intended for copying partial files. The block size, skip count, and number of blocks to copy can be specified. The options are: if = file - Input file (default is stdin) of = file - Output file (default is standard output) ibs = n - Input block size (default 512 bytes) obs = n - Output block size (default is 512 bytes) bs = n - Block size; sets ibs and obs (default is 512 bytes) skip = n - Skip n input blocks before reading seek = n - Skip n output blocks before writing count = n - Copy only n input blocks conv = lcase - Convert upper case letters to lower case conv = ucase - Convert lower case letters to upper case conv = swab - Swap every pair of bytes conv = noerror- Ignore errors and just keep going Where sizes are expected, they are in bytes. However, the letters w, b, or k may be appended to the number to indicate words (2 bytes), blocks (512 bytes), or K (1024 bytes), respectively. When dd is finished, it reports the number of full and partial blocks read and written. #de Command: de - disk editor Syntax: de [-w] block_device de -r file Flags: -r Recover a file that has been removed -w Enable writing, so device can be modified Examples: de -r /usr/ast/prog.c # Undo the effects of: rm /usr/ast/prog.c de -w /dev/fd0 # Edit /dev/fd0 for writing De is a program for system administrators that allows disks to be inspected block by block. A variety of display options and commands are available, as described in /usr/doc/de.doc. For a summary, start the program and type h for help. The program can also restore files that have just been removed by rm, provided that the i-node and blocks are still intact. Another feature is searching disks for ASCII strings, to help locate things after a crash. Finally, individual disk words can be changed, for example, the sizes of block special files. #df Command: df - report on free disk space and i-nodes Syntax: df special ... Flags: (none) Examples: df /dev/ram # Report on free RAM disk space df /dev/fd0 /dev/fd1 # Report on floppy disk space df # Report on all mounted devices The amount of disk space and number of i-nodes, both free and used is reported. #dhrystone Command: dhrystone - integer benchmark Syntax: dhrystone Flags: (none) Example: dhrystone # Run the dhrystone benchmark Many years ago, a floating-point benchmark called whetstone was popular for benchmarking FORTRAN programs. Nowadays, an integer benchmark called dhrystone is widely used for benchmarking UNIX systems. This is it. Be warned, however, that dhrystone is entirely CPU bound, and goes blindingly fast on machines with high-speed caches. Although this is a good measure for programs that spend most of their time in some inner loop, it is a poor benchmark for I/O bound applications. #diff Command: diff - print differences between two files Syntax: diff file1 file2 Flags: (none) Example: diff file1 file2 # Print differences between 2 files Diff compares two files and generates a list of lines telling how the two files differ. Lines may not be longer than 128 characters. #dis88 Command: dis88 - disassembler Syntax: dis88 [-o] infile [outfile] Flags: -o List the object code along with the assembly code Examples: dis88 a.out >listing # Disassemble a.out dis88 -o a.out listing # Ditto, but with object code Dis88 is an 8088 disassembler. It takes an executable file and prints the symbolic assembly code that corresponds to it. If the executable file contains a symbol table (added by the program ast), the symbol table information is used to give a more readable asembly listing. #diskcheck Command: diskcheck - check a disk for bad sectors Syntax: diskcheck device start count Flags: (none) Examples: diskcheck /dev/at0 0 1200 # Check 1.2 MB floppy diskcheck /dev/at0 100 50 # Check blocks 100 to 149 Diskcheck checks a disk for bad sectors by reading in each sector, writing a known bit pattern onto it, reading it back in and comparing with what was writ- ten. This check is then done a second time. Bad sectors are reported. After each sector is tested, the original sector is restored. #dosdir Command: dosdir - list an MS-DOS directory Syntax: dosdir [-lr] drive Flags: -l Long listing -r Recursively descend and print subdirectories Examples: dosdir -l A # List root directory on drive A dosdir -r C x/y # Recursively list directory x/y Dosdir reads standard IBM PC diskettes or hard disk partitions in MS-DOS format and lists their contents on standard output. Directory names should contain slashes to separate components, even though MS-DOS uses backslashes. The names dosdir, dosread, and doswrite are all links to the same program. The program sees which function to perform by seeing how it was called. A drive code of A causes the program to use /dev/dosA, typically a link to /dev/fd0. Similarly, to have hard disk partition 1 be DOS drive C, /dev/dosC should be a link to /dev/hd1, and so on for other drive codes. #dosread Command: dosread - read a file from an MS-DOS diskette Syntax: dosread Flags: -a ASCII file Examples: dosread C g/adv >adv # Read file g/adv from hard disk dosread -a A prog.c >x # Read ASCII file prog.c from drive A Dosread reads one MS-DOS file and writes it on standard output. The file name must use slash, not backslash as a separator. ASCII files have the final CTRL-Z stripped, and carriage return plus line feed are mapped to line feed only, the usual MINIX convention. A drive code of A causes the program to use /dev/dosA, typically a link to /dev/fd0. Similarly, to have hard disk parti- tion 1 be DOS drive C, /dev/dosC should be a link to /dev/hd1, and so on for other drive codes. #doswrite Command: doswrite - write a file onto an MS-DOS diskette Syntax: doswrite [-a] drive file Flags: -a ASCII file Examples: doswrite A x/y =, >}, {+, -}, *. Note that the V7 ":" operator is missing. Parentheses are permitted. #factor Command: factor - factor an integer less than 2**31 Syntax: factor number Flags: (none) Example: factor 450180 # Print the prime factors of 450180 Factor prints the prime factors of its argument in increasing order. Each factor is printed as many times as it appears in the number. #fdisk Command: fdisk - partition a hard disk Syntax: fdisk [-heads] [file] Flags: -n Number of disk heads Example: fdisk /dev/hd1 # Examine disk partitions When fdisk starts up, it reads in the partition table and displays it. It then presents a menu to allow the user to modify partitions, store the parti- tion table on a file, or load it from a file. Partitions can be marked as MINIX, DOS or other, as well as active or not. Using fdisk is self- explanatory. However, be aware that repartitioning a disk may cause information on it to be lost. Rebooting the system is mandatory after changing partition sizes. MINIX, XENIX, PC-IX, and MS-DOS all have different ideas about how par- titions are numbered. Be careful. Furthermore, MINIX expects all partitions to begin on an even sector. The m command, which marks a partition as MINIX, automatically rounds odd partitions upward. #fgrep Command: fgrep - fast grep Syntax: fgrep [-cfhlnsv] [file] [string] [file] ... Flags: -c Count matching lines and only print count, not the lines -f Take strings from file named in following argument -h Omit file headers from printout -l List file names once only -n Each line is preceded by its line number -s Status only, no output -v Print only lines not matching Examples: fgrep % prog.c # Print lines containing % sign fgrep -f pattern prog.c # Take strings from pattern Fgrep is essentially the same as grep, except that it only searches for lines containing literal strings (no wildcard characters), and it is much fas- ter. #file Command: file - make a guess as to a file's type based on contents Syntax: file name ... Flags: (none) Example: file a.out ar.h # Guess at types File reads the first block of a file and tries to make an intelligent guess about what kind of file it is. It understands about archives, C source pro- grams, executable binaries, shell scripts, and English text. #find Command: find - find files meeting a given condition Syntax: find directory expression Flags: (none) Examples: find / -name a.out -print # Print all a.out paths find /usr/ast ! -newer f -ok rm {} ;# Ask before removing find /usr -size +20 -exec mv {} /big ;# move files > 20 blks find / -name a.out -o -name `*.o` ) -exec rm {};# 2 conds Find descends the file tree starting at the given directory checking each file in that directory and its subdirectories against a predicate. If the predicate is true, an action is taken. The predicates may be connected by -a (Boolean and), -o (Boolean or) and ! (Boolean negation). Each predicate is true under the conditions specified below. The integer n may also be +n to mean any value greater than n, -n to mean any value less than n, or just n for exactly n. -name s true if current filename is s (include shell wild cards) -size n true if file size is n blocks -inum n true if the current file's i-node number is n -mtime ntrue if modification time relative to today (in days) is n -links ntrue if the number of links to the file is n -newer ftrue if the file is newer than f -perm n true if the file's permission bits = n (n is in octal) -user u true if the uid = u (a numerical value, not a login name) -grogp gtrue if the gid = g (a numerical value, not a group name) -type x where x is bcdfug (block, char, dir, regular, setuid, setgid) -xdev do not cross devices to search mounted file systems Following the expression can be one of the following, telling what to do when a file is found: -print print the file name on standard output -exec execute a MINIX command, {} stands for the file name -ok prompts before executing the command #fix Command: fix - generate new file from old one and diff listing Syntax: fix oldfile difflist >newfile Flags: (none) Example: fix old difflist >new # Generate new from old and diffs Fix accepts a diff listing produced by diff and reconstructs the new file. It is common for people to take a file, modify it, and then send the diff list- ing between the old and new files to other people. Using fix, the old file, and the diff listing, it is possible to creat the new file. For example: diff oldfile newfile >difflist fix oldfile difflist >new2 will generate a file new2 that is identical to newfile. A more sophisticated alternative to fix is patch. #fold Command: fold - fold long lines Syntax: fold [-n] [file] ... Flags: -n How long should the output lines be Examples: fold -60 # Fold stdin to 60 characters fold -1 file # Fold file to 80 characters Fold takes copies its input from the named file (or stdin, if none is speci- fied) to standard output. However, lines longer than the given maximum length (default 80) are broken into multiple lines of the maximum length by inserting new line characters. #fortune Command: fortune - print a fortune Syntax: fortune Flags: (none) Example: fortune # Print a fortune Fortune picks a fortune at random from the fortunes file, /usr/lib/fortune.dat, and prints it. This file consists of pieces of text separated by a line containing only %%. #from Command: from - input half of a connection Syntax: from port Flags: (none) Examples: from port | sort >x # Fetch and sort an incoming file from abc | sh # Primitive sherver To and from are used together to provide connection-oriented service. On the sending machine, the last member of a pipeline is to port. On the receiving machine, the first member of a pipe line is from port. The net result is that the output of the sending pipeline goes into the input of the receiving pipe- line, making pipelines work across the network. #fsck Command: fsck - perform file system consistency check Syntax: fsck [-aclmrs] [device] ... Flags: -a Automatically repair inconsistencies -c Check and list only the specified i-nodes -l List the files and directories in the filesytem -m Make a new file system -r Prompt user for repairs if inconsistencies are found -s List the superblock of the file system Examples: fsck /dev/hd4 # Check file system on /dev/hd4 fsck -a /dev/at0 # Automatically fix errors on /dev/at0 fsck -l /dev/fd0 # List the contents of /dev/fd0 fsck -c 2 3 /dev/hd3 # Check and list /dev/hd3 i-nodes 2 & 3 Fsck performs consistency checks on the file systems which reside on the specified devices. It may also be used to list the contents of a file system or to make a new file system. Fsck can be run from the initial menu and during normal production. The default number of heads and sectors/track are built in to the program (4 and 17, respectively). To change these, use ???. If they are set wrong, fsck will give absurd errors. #gather Command: gather - gather up the files in a directory for transmission Syntax: gather [-s] source_dir [-d] dest_dir [-b] bytes [-f] file Flags: -b Desired number of bytes per output file -d Destination directory -f Base name of output files -s Source directory Examples: gather # Collect files in current dir into 60K archives gather -d dir # Put the archives in dir gather -b 90000 # Try to produce 90K archives gather -s .. -d targ -b 90000# Try to produce 90K archives It is often useful to collect all the files in a directory into one or more archives for transmission by mail. This program collects all the files in the source directory (default: current directory) and puts them into a shar archive. The shar archive is then compressed and uuencoded. An attempt is made to have the final .uue file be about the given size (default: 60K), but since gather cannot really predict how much shar will add to the file, how much compress will reduce the file, and how much uue will add again, the sizes can fluctuate. If the -f file flag is given, the archives will be given the names file_00.uue, file_01.uue etc. If -f is not given, the name of the source directory is used as the base name. #getlf Command: getlf - wait until a line has been typed Syntax: getlf [argument] Flags: (none) Example: getlf # Wait for a line In shell scripts it is sometimes necessary to pause to give the user a chance to perform some action, such as inserting a diskette. This command prints its argument, if any, and then waits until a carriage return has been typed, at which time it terminates. It is used in /etc/rc. #grep Command: grep - search a file for lines containing a given pattern Syntax: grep [-ensv] pattern [file] ... Flags: -e -e pattern is the same as pattern -n Print line numbers -s Status only, no printed output -v Select lines that do not match Examples: grep mouse file # Find lines in file containing mouse grep [0-9] file # Print lines containing a digit Grep searches one or more files (by default, stdin) and selects out all the lines that match the pattern. All the regular expressions accepted by mined are allowed. In addition, + can be used instead of * to mean 1 or more occurrences, ? can be used to mean 0 or 1 occurrences, and | can be used between two regular expressions to mean either one of them. Parentheses can be used for grouping. If a match is found, exit status 0 is returned. If no match is found, exit status 1 is returned. If an error is detected, exit status 2 is returned. #gres Command: gres - grep and substitute Syntax: gres [-g] pattern string [file] ... Flags: -g Only change the first occurrence per line Examples: gres bug insect # Replace bug with insect gres ''^[A-Z]+$'' CAPS # Replace capital-only lines with CAPS Gres is a poor man's sed. It looks for the same patterns as grep, and replaces each one by the given string. #head Command: head - print the first few lines of a file Syntax: head [-n] [file] ... Flags: -n How many lines to print Examples: head -6 # Print first 6 lines of stdin head -1 file1 file2 # Print first line of two files The first few lines of one or more files are printed. The default count is 10 lines. The default file is stdin. #ic Command: ic - integer calculator Syntax: ic [expression] Flags: (none) Examples: ic # Start the calculator ic 250 300+ # Start calculator with 550 on the stack Ic is a reverse Polish notation calculator that works on 32-bit integers. It starts out by computing the expression given as an argument, if any, and then expects keyboard input. As an example, to compute ``23+5'' one first con- verts this to reverse Polish, ``23 5+''. After the calculator starts, type ``23'' followed by a carriage return. Then type ``5'' and another carriage return. Finally type ``+'' to see the result, 28 displayed on the stack. Other operations work the same way. The calculator can use other radices for input and output, and has registers that can be stored and loaded. The h com- mand gives the help menu. See also /usr/doc/ic.doc. #id Command: id - print the uid and gid Syntax: id Flags: (none) Example: id # Print the uid and gid Id prints the current uid and gid, both numerically and symbolically. If the effective uid and gid are different from the real ones, all of them are printed. #inodes Command: inodes - print i-node information Syntax: inodes Flags: (none) Example: inodes # Print information about inodes Inodes expects a list of file names on stdin, one file name per line. For each file named, the file type, mode, uid, gid, length, checksum, and and name is printed. The checksum algorithm is the same as used by crc. #kermit Command: kermit - transfer a file using the kermit protocol Syntax: kermit Flags: (many) Example: kermit # Start kermit Kermit is a file transfer program, remote connection program, and much more. Even summarizing it here would be out of the question. For a description of it, see the 379 page book Kermit: A File Transfer Protocol by Frank da Cruz, Digital Press, 1987, ISBN 0-932376-88-6, and also /usr/doc/kermit.doc. #kill Command: kill - send a signal to a process Syntax: kill [-sig] process Flags: -s Signal number to send Examples: kill 35 # Send signal 15 to process 35 kill -9 40 # Send signal 9 to process 40 kill -2 0 # Send signal 2 to whole process group A signal is sent to a given process. By default signal 15 (SIGTERM) is sent. Process 0 means all the processes in the sender's process group. #last Command: last - display recent on-line session records Syntax: last [-f file] [-r] [-n] [name] [tty] ... Flags: -f Use file instead of /usr/adm/wtmp -r Search backwards only to last reboot -n Print a maximum of n lines Examples: last reboot # When was the system last rebooted? last ast # When was the last login for ast? last -10 tty0 tty1 # Display last 10 logins on tty0 or tty1 Last Searches backward through the login administration file (default is /usr/adm/wtmp), printing information about previous logins and reboots. During a long search, the SIGQUIT signal (CTRL-\) causes last to display how far back it has gone; it then continues. #leave Command: leave - warn when it is time to go home Syntax: leave [ [+] hh[:]mm] Flags: (none) Examples: leave 1500 # Issue a warning at 2:55 p.m.: leave 10:00 # Issue a warning at 9:55 a.m. leave + 30 # Issue a warning in 25 minutes Leave sets an alarm clock to a specified time and issues a warning 5 minutes before, 1 minute before, and at the time to leave. It then keeps issuing warn- ings every minute for 10 minutes, then quits. If no time is provided, the pro- gram prompts for one. #libpack Command: libpack - pack an ASCII assembly code file Syntax: libpack Flags: (none) Example: libpack y.s # Pack x.s This program is a filter that reads an ASCII assembly code file from stan- dard input and writes the corresponding packed file on standard output. The compiler libraries are archives of packed assembly code files. #libupack Command: libupack - convert a packed assembly code file to ASCII Syntax: libupack Flags: (none) Example: libupack x.s # Unpack y.s This program is a filter that reads a packed assembly code file from stdin and writes the corresponding ASCII file on standard output. #ln Command: ln - create a link to a file Syntax: ln file [name] Flags: (none) Examples: ln file newname # Make newname a synonym for file ln /usr/games/chess # Create a link called chess A directory entry is created for name. The entry points to file. Hen- ceforth, name and file can be used interchangeably. If name is not supplied, the last component of file is used as the link name. #login Command: login - log into the computer Syntax: login [user] Flags: (none) Example: login ast # Login as ast Login allows a logged in user to login as someone else without first logging out. If a password is needed, login will prompt for it. #look Command: look - look up words in dictionary Syntax: look [-f] prefix[/suffix] [dictionary] Flags: -f Fold upper case letters to lower case Examples: look ard # Print words starting with ard look /bing # Print words ending with bing look -f f/ar # Print words starting with f, ending with ar Look takes a prefix and/or suffix and searches /usr/lib/dictionary or the specified dictionary for all words with that match. The words are printed. The -f flag causes all upper case letters to be treated as lower case. #lorder Command: lorder - compute the order for library modules Syntax: lorder file ... Flags: (none) Example: lorder proc1.s proc2.s # Give lorder information Lorder accepts a series of packed or unpacked .s files and libraries, and produces a partial ordering suitable for processing by tsort. #lpr Command: lpr - copy a file to the line printer Syntax: lpr [file ... Flags: (none) Examples: lpr file & # Print file on the line printer pr file | lpr & # Print stdin (pr's output) Each argument is interpreted as a file to be printed. Lpr copies each file to /dev/lp, without spooling. It inserts carriage returns and expands tabs. Only one lpr at a time may be running. #ls Command: ls - list the contents of a directory Syntax: ls [-ACFRadfgilrstuwx] name ... Flags: -A All entries are listed, except . and .. -C Multicolumn listing -F Put / after directory names -R Recursively list subdirectories -a All entries are listed, even . and .. -c Like -c except i-node change time used -d Do not list contents of directories -f List argument as unsorted directory -g Group id given instead of user id -i I-node number printed in first column -l Long listing: mode, links, owner, size and time -r Reverse the sort order -s Give size in blocks (including indirect blocks) -t Sort by time, latest first -u Use last usage time instead of modification time Examples: ls -l # List files in working directory ls -lis # List with i-nodes and sizes For each file argument, list it. For each directory argument, list its con- tents, unless -d is present. When no argument is present, the working direc- tory is listed. #m4 Command: m4 - macro processor Syntax: m4 [-D name = value] [-U name] Flags: -D name = value Define a symbol -U name Undefine a symbol Example: m4 Go to the next message - Print the previous message !command Fork off a shell and execute command CTRL-D Update the mailbox and quit (same as q) d Delete the current message and go to the next one q Update the mailbox and quit (same as CTRL-D) p Print the current message again s [file] Save message in the named file x Exit without updating the mailbox To send mail, the program is called with the name of the recipient as an argument. The mail is sent, along with a postmark line containing the date. For local delivery, a file named after the recipient in the directory /usr/spool/mail must be writable. #make Command: make - a program for maintaining large programs Syntax: make [-f file] [-ikns] [option] ... [target] Flags: -f Use file as the makefile -i Ignore status returned by commands -n Report, but do not execute -p Print macros and targets -q Question up-to-dateness of target -r Rule inhibit; do not use default rules -s Silent mode -t Touch files instead of making them Examples: make kernel # Make kernel up to date make -n -f file # Tell what needs to be done Make is a program that is normally used for developing large programs con- sisting of multiple files. It keeps track of which object files depend on which source and header files. When called, it does the minimum amount of recompilation to bring the target file up to date. The file dependencies are expected in makefile or Makefile, unless another file is specified with -f. Make has some default rules built in, for example, it knows how to make .s files from .c files. Here is a sample makefile. d=/user/ast # d is a macro program: head.s tail.s# program depends on these cc -o program head.s tail.s# tells how to make program echo Program done. # announce completion head.s: $d/def.h head.c # head.s depends on these tail.s: $d/var.h tail.c # tail.s depends on these A complete description of make would require too much space here. For more information, see Feldman (1979). Many books on UNIX also discuss make. #man Command: man - display manual page Syntax: man [man_directory] [digit] [name] ... Flags: (none) Examples: man # Display main index man cdiff # Display man page for cdiff(1) man 2 fork # Display man page for fork(2) man 3 # Display the part 3 man pages Man is a program that displays manual pages. When called with a program name, it displays the manual page for that program. When the digit k is given as an argument, the file /usr/man/mank is used instead of the default, /usr/man/man1. When no name is given (or just a digit), the list of valid entries is displayed. The arrows can be used to select an entry, and can be used to display the selected entry. Q or q leaves the program. A directory name can be given to override the use of /usr/man.