ast@cs.vu.nl (Andy Tanenbaum) (01/23/89)
#animals Command: animals - twenty questions type guessing game about animals Syntax: animals [database] Flags: (none) Example: _A_n_i_m_a_l_s 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 /_u_s_r/_l_i_b/_a_n_i_m_a_l_s. #ar Command: ar - archiver Syntax: ar [qrxdpmt][abivulc] [posname] archive file ... Flags: (none) Examples: _A_r 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 name members. t: print the archive's table of contents. p: print the named files (list them on standard output) 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: 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. 1 2 #asld Command: asld - assembler-loader Syntax: asld [-d] [-s] [-o name] file ... Flags: -L A listing is produced on standard output -T Used to specify a directory for the tem- porary file -o Output goes to file named by next argu- ment -i Use separate I & D space (64K + 64K) -s A symbol table is produced on standard output Examples: _A_s_l_d is the MINIX assembler and loader combined. It accepts a language simi- lar 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: _m_o_v _a_x,(_b_x__s_i). Constant operands are denoted by a number sign. Local labels are permitted in the usual UNIX style: the instruc- tion _j_m_p _1_f 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 _s_y_m from the file .errnz n Force error if _n is nonzero .even Align to an even address .extern symDeclare _s_y_m 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, _a_d_r is an expression yielding a machine address, _n is a numeric expression, _s_t_r is a quoted string, and _s_y_m is a symbol. The library /_u_s_r/_l_i_b/_l_i_b_c._a is a packed archive of assembly code. To see some examples of it, extract some files from the archive with _a_r and then use the filter _l_i_b_u_p_a_c_k 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 3 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: _A_s_t adds the symbol table produced by the -s option of asld to the executable 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 Syntax: at time [month day] [file] Flags: (none) Examples: _A_t prepares a file to be executed later at the specified time by creating a special entry in /_u_s_r/_s_p_o_o_l/_a_t. The program _a_t_r_u_n should be started periodi- cally, for example, every minute by cron. _A_t_r_u_n 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 standard input or standard output unless specifically redirected. In the first example above, it might be necessary to put >/_d_e_v/_t_t_y_0 on some lines in the shell script myfile. The same holds for the commands typed directly to _a_t. #badblocks Command: badblocks - put a list of bad blocks in a file Syntax: badblocks block_special Flags: (none) Example: 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. 4 #banner Command: banner - print a banner Syntax: banner arg ... Flags: (none) Example: _B_a_n_n_e_r prints its arguments on standard output 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: 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. #cal Command: cal - print a calendar Syntax: cal [month] year Flags: (none) Example: _C_a_l prints a calendar for a month or year. The year can be between 1 and 9999. Note that the year 87 is not a synonym for 1987, 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 standard output Syntax: cat [-u] file ... Flags: -u Unbuffered output Examples: _C_a_t concatenates its input files and copies the result to standard output. 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. 5 #cc Command: cc - C compiler Syntax: cc [option] ... file ... Flags: -D The flag -D_x=_y defines a macro _x with value _y -F Use a file instead of a pipe for prepro- cessor output -I -I_d_i_r searches _d_i_r 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 -T_d_i_r tells _c_e_m to use _d_i_r 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 -v Verbose. Print pass names -w Suppress warning messages Examples: This is the C compiler. It has five passes, as follows: _P_r_o_g_r_a_m _I_n_p_u_t _O_u_t_p_u_t _O_p_e_r_a_t_i_o_n _p_e_r_f_o_r_m_e_d /lib/cpp /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.s Code generation /usr/lib/asld prog.s a.outAssembly and linking The main program, _c_c, 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 _c_g 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 ._d_e_f_i_n_e 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 _l_i_b_u_p_a_c_k. 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 _c_p_p and _c_e_m in memory at the same time, 6 transferring the output of _c_p_p to _c_e_m using a pipe. However, if there is insuf- ficient 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 /_t_m_p (unless -T is used). When available memory is very limited (e.g., a 512K machine), it may be necessary to run _c_h_m_e_m to reduce the sizes of the compiler passes that do not fit, typically _c_e_m. The other passes, especially _a_s_l_d, can create large temporary files in /_t_m_p. To compile very large programs, first type cc -c *.c to get ._s files. Then remove /_l_i_b/_c_p_p and /_l_i_b/_c_e_m and possibly other files from the RAM disk to make more space for /_t_m_p. 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._o_u_t 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 _c_h_m_e_m. 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 Example: Cdiff\fIfR 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] ... 7 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: _C_g_r_e_p _i_s _a _p_r_o_g_r_a_m _l_i_k_e _g_r_e_p, _e_x_c_e_p_t _t_h_a_t _i_t _a_l_s_o _c_a_n _p_r_i_n_t _a _f_e_w _l_i_n_e_s _a_b_o_v_e _a_n_d/_o_r _b_e_l_o_w _t_h_e _m_a_t_c_h_i_n_g _l_i_n_e_s. _I_t _a_l_s_o _p_r_i_n_t_s _t_h_e _l_i_n_e _n_u_m_b_e_r_s _o_f _t_h_e _o_u_t_p_u_t. #_c_h_g_r_p Command: chgrp - change group Syntax: chgrp group file ... Flags: (none) Example: The group field of the named files is changed to _g_r_o_u_p. 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: 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 _m_a_l_l_o_c, _b_r_k, or _s_b_r_k 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 simultane- ously. 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 (64K - text - data). For many programs, this value is far too large. Nonrecur- sive programs that do not call _b_r_k, _s_b_r_k, or _m_a_l_l_o_c, and do not have any local arrays usually do not need more than 1K of stack space. 8 The _c_h_m_e_m 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 files chmod [augo][+-=][rwxst] files Flags: (none) Examples: 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 execute; 's' turns on the set effective user/group id bits. 'u', other permis- sion bits, respectively. Only one of these may be used at a time. Multiple symbolic modes may be specified, separated by commas. #chown Command: chown - change owner Syntax: chown user file ... Flags: (none) Example: The owner field of the named files is changed to _u_s_e_r (i.e., login name specified). Alternatively, a decimal uid may be specified instead of a user 9 name. Only the super-user may execute this command. #clr Command: clr - clear the screen Syntax: clr Flags: (none) Example: The screen is cleared to blanks. #cmp Command: cmp - compare two files Syntax: cmp [-ls] file1 file2 Flags: -l Loud mode. Print bytes that differ (in octal) -s Silent mode. Print nothing, just return exit status Examples: 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 _f_i_l_e_1 is - , standard input is compared to _f_i_l_e_2. #comm Command: comm - print lines common to two sorted files Syntax: comm [-123] file1 file2 Flags: -1 Suppress column 1 (lines only in _f_i_l_e_1) -2 Suppress column 2 (lines only in _f_i_l_e_2) -3 Suppress column 3 (lines in both files) Examples: Two sorted files are read and compared. A three column listing is produced. Files only in _f_i_l_e_1 are in column 1; files only in _f_i_l_e_2 are in column 2; files common to both files are in column 3. The file name - means standard input. #compress Command: compress - compress a file using modified Lempel-Ziv coding Syntax: compress [-cdfv] [file] ... Flags: -c Put output on standard output instead of on file.Z -d Decompress instead of compress 10 -f Force output even if there is no saving -v Verbose mode Examples: The listed files (or standard input, if none are given) are compressed using the Ziv-Lempel algorithm. If the output is smaller than the input, the output is put on _f_i_l_e._Z or standard output if no files are listed. If _c_o_m_p_r_e_s_s is linked to _u_n_c_o_m_p_r_e_s_s, the latter is the same as giving the -d flag. Similarly, a link to _z_c_a_t decompresses to standard output. #cp Command: cp - copy file Syntax: cp file1 file2 cp file ... directory Flags: (none) Examples: _C_p 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: _C_p_d_i_r 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 Flags: (none) Example: 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 _s_u_m, except that it uses a strong checksum algorithm and also prints the length. 11 #cron Command: cron - clock daemon Syntax: cron Flags: (none) Example: _C_r_o_n 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 Mon-Fri at 0430 30 19 * * 1,3,5 /etc/backup /dev/fd1 #Mon, >/dev/tty0 #date Command: date - print or set the date and time Syntax: date [[MMDDYY]hhmm[ss]] Flags: -q Read the date from standard input Examples: Without an argument, _d_a_t_e prints the current date and time. With an argu- ment, it sets the date and time. _M_M_D_D_Y_Y refers to the month, day, and year; _h_h_m_m_s_s refers to the hour, minute and second. Each of the six fields must be two digits. #dd Command: dd - disk dumper Syntax: dd [option = value] ... Flags: (none) Examples: 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 standard input) 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 _i_b_s and _o_b_s (default is 512 bytes) skip = n - Skip _n input blocks before reading 12 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 _d_d is finished, it reports the number of full and partial blocks read and written. #df Command: df - report on free disk space and i-nodes Syntax: df special ... Flags: (none) Examples: The amount of disk space and number of i-nodes, both free and used is reported. #diff Command: diff - print differences between two files Syntax: diff file1 file2 Flags: (none) Example: _D_i_f_f 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: _D_i_s_8_8 is a 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. 13 #diskcheck Command: diskcheck - check a disk for bad sectors Syntax: diskcheck device start count Flags: (none) Examples: _D_i_s_k_c_h_e_c_k 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 diskette directory Syntax: dosdir [-lr] drive Flags: -l Long listing -r Recursively descend and print subdirec- tories Examples: _D_o_s_d_i_r reads standard IBM PC diskettes or hard disk partitions in MS-DOS for- mat and lists their contents on standard output. Directory names should contain slashes to separate components, even though MS-DOS uses backslashes. The names _d_o_s_d_i_r, _d_o_s_r_e_a_d, and _d_o_s_w_r_i_t_e are all links to the same program. The program sees which function to perform by seeing how it was called. The letters _a, and _b can be used as synonyms for 0 and 1 for floppies. The letters _c through _f are for hard disk partitions. #dosread Command: dosread - read a file from an MS-DOS diskette Syntax: dosread Flags: -a ASCII file Examples: _D_o_s_r_e_a_d reads one file from an MS-DOS diskette and writes it on standard out- put. The file name should 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. #doswrite Command: doswrite - write a file onto an MS-DOS diskette Syntax: doswrite [-a] drive file Flags: -a ASCII file Examples: 14 _D_o_s_w_r_i_t_e writes its standard input to an MS-DOS diskette. The diskette must be formatted and have an MS-DOS file system already in place, including all the directories leading up to the file. #du Command: du - print disk usage Syntax: du [-s] dir Flags: -s Summary only Example: _D_u examines a directory and prints the amount of space occupied by the files in that directory and its subdirectories. #echo Command: echo - print the arguments Syntax: echo [-n] argument ... Flags: -n No line feed is output when done Examples: _E_c_h_o writes its arguments to standard output. They are separated by blanks and terminated with a line feed unless -n is present. This command is used mostly in shell scripts. #ed Command: ed - editor Syntax: ed file Flags: (none) Example: _E_d is functionally equivalent to the standard V7 editor, ed. It supports the following commands: (.) a: append (.,.)c: change (.,.)d: delete e: edit new file" f: print name of edited file" (1,$)g: global command (.) i: insert (.,.+1)j: join lines together (.) k: mark (.) l: print with special characters in octal (.,.)m: move (.,.)p: print q: quit editor" (.) r: read in new file (.,.)s: substitute (1,$)v: like g, except select lines that do not match (1,$)w: write out edited file Many of the commands can take one or two addresses, as indicated above. The defaults are shown in parentheses. Thus 'a' appends to the current line, and g works on the whole file as default. The dot refers to the current line. Below 15 is through Replace #elle Command: elle - ELLE Looks Like Emacs Syntax: elle file [file2] Flags: (none) Example: _E_l_l_e is a screen-oriented editor that is patterned after Emacs. It can edit multiple files, regardless of their length, can support 1 or 2 windows, and has many other powerful features. An _e_l_l_e manual is present in the _d_o_c directory. #expr Command: expr - evaluate experession Syntax: expr arg ... Flags: (none) Example: _E_x_p_r computes the value of its argument and writes the result on standard output. The valid operators, in order of increasing precedence, are listed below. Operators grouped by {...} have the same precedence. Operators: |, &, {<, <=, ==, !=, >=, >}, {+, -}, *. 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: _F_a_c_t_o_r 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 file Flags: (none) Example: 16 When _f_d_i_s_k 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 partition table on a file, or load it from a file. Partitions can be marked as DOS or non-DOS, and active or not. MINIX doesn't care what kind of a partition it uses. Using _f_d_i_s_k 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 dif- ferent ideas about how partitions are numbered. #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 follow- ing 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: _F_g_r_e_p is essentially the same as grep, except that it only searches for lines containing literal strings (no wildcard characters), and it is much faster. #file Command: file - make a guess as to a file's type based on contents Syntax: file name ... Flags: (none) Example: _F_i_l_e 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 programs, executable binaries, shell scripts, and English text. #find Command: find - find files meeting a given condition Syntax: find directory expression Flags: (none) Examples: 17 _F_i_n_d 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) 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: _F_i_x 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 _f_i_x, 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[TGive will generate a file _n_e_w_2 that is identical to _n_e_w_f_i_l_e. A more sophisticated alternative to _f_i_x is _p_a_t_c_h. #fortune Command: fortune - print a fortune Syntax: fortune Flags: (none) Example: _F_o_r_t_u_n_e picks a fortune at random from the fortunes file, /_u_s_r/_l_i_b/_f_o_r_t_u_n_e._d_a_t, and prints it. This file consists of pieces of text separated by a line containing only %%. 18 #from Command: from - input half of a connection Syntax: from port Flags: (none) Examples: To and from are used together to provide connection-oriented service. On the sending machine, the last member of a pipeline is '_t_o port'. On the receiving machine, the first member of a pipe line is '_f_r_o_m 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 inconsisten- cies are found -s List the superblock of the file system Examples: _F_s_c_k 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. _F_s_c_k can be run from the initial menu and during nor- mal production. The number of heads and sectors/track are built in to the pro- gram (4 and 17, respectively). To change these, modify the code and recompile. If they are set wrong, _f_s_c_k will give absurd errors. #getlf Command: getlf - wait until a line has been typed Syntax: getlf [argument] Flags: (none) Example: 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 /_e_t_c/_r_c. 19 #grep Command: grep - search a file for lines containing a given pattern Syntax: grep [-ensv] pattern [file] ... Flags: -e -e _p_a_t_t_e_r_n is the same as _p_a_t_t_e_r_n -n Print line numbers -s Status only, no printed output -v Select lines that do not match Examples: _G_r_e_p searches one or more files (by default, standard input) and selects out all the lines that match the pattern. All the regular expressions accepted by _m_i_n_e_d 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: _G_r_e_s is a poor man's _s_e_d. It looks for the same patterns as _g_r_e_p, 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: The first few lines of one or more files are printed. The default count is 10 lines. The default file is standard input. #help Command: help - give help about a command Syntax: help [name] Flags: (none) Example: 20 _H_e_l_p gives help about a given command name (or help itself, if none is speci- fied). It gets its information from /_u_s_r/_l_i_b/_h_e_l_p_f_i_l_e, which should be linked to _d_o_c/_m_a_n__p_a_g_e_s. To improve performance, it builds an index file, /_u_s_r/_l_i_b/_h_e_l_p_f_i_l_e._i_d_x, which is updated when it is observed to be older than /_u_s_r/_l_i_b/_h_e_l_p_f_i_l_e. helpfile contains all the manual pages not present in the book. #id Command: id - print user's identity Syntax: id Flags: (none) Example: _I_d prints the current user's uid and gid, both numerically and symbolically using the information from /_e_t_c/_p_a_s_s_w_d and _e_t_c/_g_r_o_u_p. #inodes Command: inodes - print i-node information Syntax: inodes Flags: (none) Example: _I_n_o_d_e_s expects a list of file names on _s_t_d_i_n, 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 _c_r_c. #kill Command: kill - send a signal to a process Syntax: kill [-signal] process Flags: (none) Examples: 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. #leave Command: leave - warn when it is time to go home Syntax: leave [ [+] hh[:]mm] Flags: (none) Examples: 21 _L_e_a_v_e 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: This program is a filter that reads an ASCII assembly code file from standard 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: This program is a filter that reads a packed assembly code file from standard input 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: A directory entry is created for _n_a_m_e. The entry points to _f_i_l_e. Hen- ceforth, _n_a_m_e and _f_i_l_e can be used interchangeably. If _n_a_m_e is not supplied, the last component of _f_i_l_e is used as the link name. #login Command: login - log into the computer Syntax: login [user] Flags: (none) Example: 22 _L_o_g_i_n allows a logged in user to login as someone else without first logging out. If a password is needed, _l_o_g_i_n 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: _L_o_o_k takes a prefix and/or suffix and searches /_u_s_r/_l_i_b/_d_i_c_t_i_o_n_a_r_y 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: _L_o_r_d_e_r accepts a series of packed or unpacked .s files and libraries, and produces a partial ordering suitable for processing by _t_s_o_r_t. #lpr Command: lpr - copy a file to the line printer Syntax: lpr [file] ... Flags: (none) Examples: Each argument is interpreted as a file to be printed. _L_p_r copies each file to /_d_e_v/_l_p, without spooling. It inserts carriage returns and expands tabs. Only one _l_p_r at a time may be running. #ls Command: ls - list the contents of a directory Syntax: ls [-adfgilrst] name ... Flags: -a All entries are listed, even . and .. -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 23 -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 Examples: 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 directory is listed. #make Command: make - a program for maintaining large programs Syntax: make [-f file] [-ikns] [option] ... [target] Flags: -f Use _f_i_l_e as the makefile -i Ignore status returned by commands -k Kill branch on error -n Report, but do not execute -s Silent mode Examples: _M_a_k_e 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 recompila- tion to bring the target file up to date. The file dependencies are expected in _m_a_k_e_f_i_l_e or _M_a_k_e_f_i_l_e, unless another file is specified with -f. _M_a_k_e has some default rules built in, for example, it knows how to make ._s files from ._c files. Here is a sample _m_a_k_e_f_i_l_e. A complete description of _m_a_k_e would require too much space here. For more information, see Feldman (1979). Many books on UNIX also discuss _m_a_k_e. #master Command: master - control the creation of shervers Syntax: master count uid gid command Flags: (none) Example: 24 If a machine is intended to be used as a server, its /_e_t_c/_r_c file should have a command similar to the example above. When the system is booted, _m_a_s_t_e_r runs and forks off the required number of shervers (shell servers), up to a maximum of four. They run with the indicated uid and gid, and listen to the indicated port. When an _r_s_h is done on a client machine, the command is given to one of the shervers for execution. When the sherver is done, it exits, _m_a_s_t_e_r, which is always running, sees this, and creates a new sherver. Thus _m_a_s_t_e_r is very similar to _i_n_i_t, only it makes new shervers (usually) instead of new _l_o_g_i_n pro- grams. _M_a_s_t_e_r must run as root to be able to do setuid and setgid. #mined Command: mined - MINIX editor Syntax: mined [file] Flags: (none) Examples: _M_i_n_e_d (pronounced min-ed) is a simple full-screen editor. When editing a file, it holds the file in memory, thus speeding up editing, but limiting the editor to files of up to about 43K. Larger files must first be cut into pieces by _s_p_l_i_t. Lines may be arbitrarily long. Output from a command may be piped into _m_i_n_e_d so it can be viewed without scrolling off the screen. At any instant, a window of 24 lines is visible on the screen. The current position in the file is shown by the cursor. Ordinary characters typed in are inserted at the cursor. Control characters and keys on the numeric keypad (at the right-hand side of the keyboard) are used to move the cursor and perform other functions. Commands exist to move forward and backward a word, and delete words. A word in this context is a sequence of characters delimited on both ends by white space (space, tab, line feed, start of file, or end of file). The commands for deleting characters and words also work on line feeds, making it possible to join two consecutive lines by deleting the line feed between them. The editor maintains one save buffer (not displayed). Commands are present to move text from the file to the buffer, from the buffer to the file, and to write the buffer onto a new file. If the edited text cannot be written out due to a full disk, it may still be possible to copy the whole text to the save buffer and then write it to a different file on a different disk with CTRL-Q. It may also be possible to escape from the editor with CTRL-S and remove some files. Some of the commands prompt for arguments (file names, search patterns, etc.). All commands that might result in loss of the file being edited prompt to ask for confirmation. A key (command or ordinary character) can be repeated _n times by typing _E_S_C _n _k_e_y where _E_S_C is the ``escape'' key. 25 Forward and backward searching requires a regular expression as the search pattern. Regular expressions follow the same rules as in the UNIX editor, _e_d: 1. Any displayable character matches itself. 2. . (period) matches any character except line feed. 3. ^ (circumflex) matches the start of the line. 4. $ (dollar sign) matches the end of the line. 5. \c matches the character _c (including period, circumflex, etc). 6. [string] matches any of the characters in the string. 7. [^string] matches any of the characters except those in the string. 8. [x-y] matches any characters between _x and _y (e.g., [a-z]). 9. Pattern* matches any number of occurrences of _p_a_t_t_e_r_n. Some examples of regular expressions are: The boy matches the string ``The boy'' ^$ matches any empty line. ^A.*\.$ matches any line starting with an _A, ending with a period. ^[A-Z]*$matches any line containing only capital letters (or empty). [A-Z0-9]matches any line containing either a capital letter or a digit. Control characters cannot be entered into a file simply by typing them because all of them are editor commands. To enter a control character, depress the ALT key, and then while holding it down, hit the ESC key. Release both ALT and ESC and type the control character. Control characters are displayed in reverse video. The _m_i_n_e_d commands are as follows. CURSOR MOTION arrows Move the cursor in the indicated direction CTRL-A Move cursor to start of current line CTRL-Z Move cursor to end of current line CTRL-^ Move cursor to top of screen CTRL-_ Move cursor to end of screen CTRL-F Move cursor forward to start of next word