ast@cs.vu.nl (Andy Tanenbaum) (12/18/89)
#master Command: master - control the creation of shervers Syntax: master count uid gid command Flags: (none) Example: master 2 1 1 /bin/sherver port# Start 2 shervers If a machine is intended to be used as a server, its /etc/rc file should have a command similar to the example above. When the system is booted, master 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 rsh is done on a client machine, the command is given to one of the shervers for execution. When the sherver is done, it exits, mas- ter, which is always running, sees this, and creates a new sherver. Thus master is very similar to init, only it makes new shervers (usually) instead of new login programs. Master must run as root to be able to do setuid and setgid. #mined Command: mined - MINIX editor Syntax: mined [file] Flags: (none) Examples: mined /user/ast/book.3 # Edit an existing file mined # Call editor to create a new file ls -l | mined # Use mined as a pager to inspect listing Mined (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 split. Lines may be arbitrarily long. Output from a command may be piped into mined 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 com- mands for deleting characters and words also work on line feeds, making it pos- sible 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 ESC n key where ESC is the ``escape'' key. Forward and backward searching requires a regular expression as the search pattern. Regular expressions follow the same rules as in the UNIX editor, ed: 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 pattern. 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 mined 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 CTRL-B Move cursor backward to start of previous word SCREEN MOTION Home key Move to first character of the file End key Move to last character of the file PgUp key Scroll window up 23 lines (closer to start of the file) PgDn key Scroll window down 23 lines (closer to end of the file) CTRL-U Scroll window up 1 line CTRL-D Scroll window down 1 line MODIFYING TEXT Del key Delete the character under the cursor Backspace Delete the character to left of the cursor CTRL-N Delete the next word CTRL-P Delete the previous word CTRL-T Delete tail of line (all characters from cursor to end of line) CTRL-O Open up the line (insert line feed and back up) CTRL-G Get and insert a file at the cursor position BUFFER OPERATIONS CTRL-@ Set mark at current position for use with CTRL-C and CTRL-K CTRL-C Copy the text between the mark and the cursor into the buffer CTRL-K Delete text between mark and cursor; also copy it to the buffer CTRL-Y Yank contents of the buffer out and insert it at the cursor CTRL-Q Write the contents of the buffer onto a file MISCELLANEOUS numeric + Search forward (prompts for regular expression) numeric - Search backward (prompts for regular expression) numeric 5 Display the file status CTRL-] Go to specific line CTRL-R Global replace pattern with string (from cursor to end) CTRL-L Line replace pattern with string CTRL-W Write the edited file back to the disk CTRL-X Exit the editor CTRL-S Fork off a shell (use CTRL-D to get back to the editor) CTRL-\ Abort whatever the editor was doing and wait for command CTRL-E Erase screen and redraw it CTRL-V Visit (edit) a new file #mkdir Command: mkdir - make a directory Syntax: mkdir directory ... Flags: (none) Examples: mkdir dir # Create dir in the current directory mkdir /user/ast/dir # Create the specified directory The specified directory or directories are created. The entries . and .. are inserted into the new directory. #mkfs Command: mkfs - make a file system Syntax: mkfs special prototype Flags: -L Make a listing on standard output Examples: mkfs /dev/fd1 proto # Make a file system on /dev/fd1 mkfs /dev/fd1 360 # Make empty 360 block file system Mkfs builds a file system and copies specified files to it. The prototype file tells which directories and files to copy to it. If the prototype file cannot be opened, and its name is just a string of digits, an empty file system will be made with the specified number of blocks. A sample prototype file fol- lows. The text following the # sign is comment. In the real prototype file, comments are not allowed. boot # boot block file (ignored) 360 63 # blocks and i-nodes d--755 1 1 # root directory bin d--755 2 1 # bin dir: mode (755), uid (2), gid (1) sh ---755 2 1 /user/ast/shell # shell has mode rwxr-xr-x mv -u-755 2 1 /user/ast/mv # u = SETUID bit login -ug755 2 1 /user/ast/login# SETUID and SETGID $ # end of /bin dev d--755 2 1 # special files: tty (char), fd0 (block) tty c--777 2 1 4 0 # uid=2, gid=1, major=4, minor=0 fd0 b--644 2 1 2 0 360 # uid, gid, major, minor, blocks $ # end of /dev user d--755 12 1 # user dir: mode (755), uid (12), gid (1) ast d--755 12 1 # /user/ast $ # /user/ast is empty $ # end of /user $ # end of root directory The first entry on each line (except the first 3 and the $ lines, which ter- minate directories) is the name the file or directory will get on the new file system. Next comes its mode, with the first character being -dbc for regular files, directories, block special files and character special files, respec- tively. The next two characters are used to specify the SETUID and SETGID bits, as shown above. The last three characters of the mode are the rwx pro- tection bits. Following the mode are the uid and gid. For special files, the major and minor devices are needed. The size in blocks must also be specified for block special files (the MINIX block size is 1K; this can only be changed by changing BLOCK_SIZE and then recompiling the operating system). #mknod Command: mknod - create a special file Syntax: mknod file [b] [c] major minor Flags: (none) Example: mknod /dev/plotter c 7 0 # Create special file for a plotter Mknod creates a special file named file, with the indicated major and minor device numbers. The second argument specifies a block or character file. #more Command: more - pager Syntax: more [-cdflpsu] [-n] [+n] [+/pattern] [file] ... Flags: -d Display prompt message at each pause -f Do not fold lines -l Do not treat CTRL-L as form feed -p Page mode. Do not scroll -s Suppress multiple blank lines -u Use escape sequences for underlining Examples: more file # Display file on the screen more -p file1 file2 # Display two files in page mode more -10 file # Use a 10 line window more +/begin file # Hunt for the string begin More is a pager that allows one to examine files. This program is patterned after one originally produced at the University of California, Berkeley. When more starts up, it displays a screenful of information from the first file in its list, and then pauses for one of the following commands. In this descrip- tion, # represents an integer telling how many of something. <space> - Display next page <return> - Display next line CTRL-B - Go backward half a screenful CTRL-D - Go forward half a screenful CTRL-L - Redisplay the screen #<space> - Go forward # lines = - Print current line number . - Repeat previous command ' - (single quote) Go back to start of last search ! - Escape to a shell #/<expr> - Go to #-th occurrence of <expr> :f - Display current file name and line number #:n - Skip forward # files #:p - Skip backward # files b - Go backward half a screenful d - Go forward half a screenful #f - Skip # screenfuls h - Display /usr/lib/more.help #n - Go to #-th occurence of last <expr> q - Quit more Q - Quit more #s - Skip # lines v - Try to execute /usr/bin/vi #z - Go forward # lines and set screen size to # For the benefit of users who always want to use certain flags when calling more, the shell variable MORE can be set to the desired default flags, for example, MORE="-p". #mount Command: mount - mount a file system Syntax: /etc/mount special file [-r] Flags: -r File system is mounted read-only Example: /etc/mount /dev/fd1 /user # Mount floppy disk 1 on /user The file system contained on the special file is mounted on file. In the example above, the root directory of the file system in drive 1 can be accessed as /user after the mount. When the file system is no longer needed, it must be unmounted before being removed from the drive. #mref Command: mref - make listing and cross reference map of MINIX Syntax: mref [-n] [-dlmtsx] [-p page] file ... Flags: -n Number of lines to print per page, default = 50 -d Don't produce definition file (global symbol table) -l Don't produce listing -m Multiple reference on one line only are cited only once -p n Set initial page number to n -t Generate troff macro call before each page -s Suppress line numbering between procedures -x Don't produce the cross reference map Examples: mref *.[hc] # List and cross reference files .h and .c mref -60 -t *.c # Produce troff input at 60 lines/page mref -dx -p 100 *.c # Listing only, first page is numbered 100 In default mode, mref produces three output files: a numbered listing of the input files (on standard output), a global symbol table (on symbol.out), and a cross reference map to the global symbols (on xref.out). A global symbol in this context is one present in a #define, PUBLIC, PRIVATE, or SYMBOL statement (the latter being introduced to allow users to explicitly declare certain sym- bols as global). Any of the three outputs can be suppressed, or alternatively, be made suitable for input to troff for typesetting. #mv Command: mv - move or rename a file Syntax: mv file1 file2 mv file ... directory Flags: (none) Examples: mv oldname newname # Move oldname to newname mv file1 file2 /user/ast # Move two files to /user/ast Mv moves one or more files from one place in the file system to another. If the old path and new path are on the same device, it is done by linking and unlinking, otherwise by copying. #nm Command: nm - print name list Syntax: nm [-gnopru] [file] ... Flags: -g Print only external symbols -n Sort numerically rather than alphabetically -o Prepend file name to each line rather than only once -p Don't sort, print in symbol-table order -r Sort in reverse order -u Print only undefined symbols Examples: -nm -n a.out # Print all symbols in numerical order -nm -g a.out # Print global symbols alphabetically Nm prints the symbol table of executable files when it is available. If no file is given, the symbols in a.out are used. The format of the table is some- what compatible with the one produced by asld when used with the -s option. The symbol table can be added with ast. Archives are not supported. Note that assembly language files don't have symbol tables. #nro Command: nro - text formatter Syntax: nro [-bv] [+n] [-n] [-mmacros] [-pn] [file] ... Flags: +n First page to print -n Last page to print -b Output device can backspace -m Use /usr/lib/tmac/tmac.macros -p Shift each line n spaces right -v Print nro version number Examples: nro infile >outfile # Format infile nro +3 -5 infile >outfile # Only output pages 3-5 Nro is a text formatter patterned loosely on nroff, but much simpler. Unlike roff, it accepts parametrized macros. The commands are given in the file /usr/doc/nro.doc. #od Command: od - octal dump Syntax: od [-bcdhox] [file] [ [+] offset [.][b] ] Flags: -b Dump bytes in octal -c Dump bytes as ASCII characters -d Dump words in decimal -h Print addresses in hex (default is octal) -o Dump words in octal (default) -x Dump words in hex Examples: od -ox file # Dump file in octal and hex od -d file +1000 # Dump file starting at byte 01000 od -c file +10.b # Dump file starting at block 10 Od dumps a file in one or more formats. If file is missing, stdin is dumped. The offset argument tells od to skip a certain number of bytes or blocks before starting. The offset is in octal bytes, unless it is followed by a ``.'' for decimal or b for blocks or both. #passwd Command: passwd - change a login password Syntax: passwd [name] Flags: (none) Examples: passwd # Change current user's password passwd ast # Change ast's password (super-user only) Passwd is used to change your password. It prompts for the old and new passwords. It asks for the new password twice, to reduce the effect of a typ- ing error. Do not forget to copy the modified password file back to the root file system diskette, or the changes will be lost when the system is rebooted. #paste Command: paste - paste multiple files together Syntax: paste [-s] [-dc] file... Flags: -s Print files sequentially, file k on line k -dc Set delimiter used to separate columns Examples: paste file1 file2 # Print file1 in col 1, file2 in col 2 paste -s f1 f2 f3 f4 # Print f1 on line 1, f2 on line 2, etc Paste displays multiple files in parallel. Suppose a set of k files each have one word per line. Then the paste output will have k columns, with the contents of file j in column j. The columns are separate by tabs unless the separator is changed with the -d flag. If the -s flag is given, then the first file is on line 1, the second file on line 2, etc. In effect, -s turns the out- put sideways. #patch Command: patch - patches up a file from the original and a diff Syntax: patch [-DFNbcdeflnop] Flags: -D Mark changes with #ifdef...#endif next arg gives label -F Sets the maximum fuzz factor -N Ignore patches that are reversed or already applied -b Next argument is backup extension, instead of .orig -c Interpret the patch file as a context diff -d Cd to the next arg (assumed a dir) before doing anything -e Interpret the patch file as an ed script -f Forces patch to do its work without asking any questions -l Do matching loosely (e.g., all white space is equivalent) -n Interpret the patch file as a normal diff -o Next argument is the output file name -p Sets the pathname strip count Examples: patch file difflist # Fix up file patch <difflist # Patch multiple files Patch takes an original file and a diff listing and recreates the new file. It is functionally similar to fix, but much more powerful. Not only can it handle normal diffs, but also context diffs produced by cdiff. In addition, it works even when the file being patched has other changes to it. It deduces the type of difflist itself (unless given -c, -e, or -n). The normal usage is given in the example above. In this case patch will modify 'file' to incor- porate all the patches. The original file will be saved to a file ending in a tilde. If no input file is given, patch reads stdin which may contain the concatenation of multiple diff listings. In this way, all the files in a directory may be updated at once. #pr Command: pr - print a file Syntax: pr [[option] ... [-columns] [+page] [file] ... Flags: -h Take next argument as page header -l Sets page length in lines -n Number the output lines -t Do not print page header or trailer -w Sets line length in characters Examples: pr -w72 -l60 file # Use 72 character line, 60 line page pr -3 file # List file three columns to a page pr +4 file # Start printing with page 4 Pr formats one or more files for printing. If no files are specified, stdin is printed. Options are provided for setting the width and height of the page, the number of columns to use (default 1), and the page to start with, among others. #pretty Command: pretty - MINIX pretty printer Syntax: pretty file ... Flags: (none) Example: pretty file1 file2 # Convert two files to MINIX layout Pretty converts one or more C source files to MINIX format by changing their layout. Running this program does not affect the resulting binary programs. Actually, pretty is a postprocessor for indent, which must be installed in /bin or /usr/bin. Although the output is not bad, it is not entirely consistent with the book or even with itself. #prep Command: prep - prepare a text file for statistical analysis Syntax: prep [file] Flags: (none) Example: prep infile >outfile # Prepare infile Prep strips off most of the troff commands from a text file and then outputs all the words, one word per line, in the order they occur in the file. This file can then be sorted and compared to a dictionary (as a spelling checker), or used for statistical analyses. #printenv Command: printenv - print out the current environment printenv Flags: (none) Example: printenv # Print the environment Printenv prints out the current environment strings, one per line. #printroot Command: printroot - print the name of the root device on standard output Syntax: printroot Flags: (none) Example: printroot # Print the name of the root device Printroot is useful for initializing the /etc/mtab entry when the system is booted. It figures out what the root device is by searching /dev until it finds a block special file with the right major/minor device numbers. #pwd Command: pwd - print working directory Syntax: pwd Flags: (none) Example: pwd # Print the name of the working directory The full path name of the current working directory is printed. #rcp Command: rcp - remote copy Syntax: rcp [mach1]!file1 [mach2]!file2 Flags: (none) Examples: rcp file mach1!/usr/ast/x # Local file to remote machine rcp mach2!/usr/ast/x file # Fetch remote file x Rcp is not a program. It is a shell script that does remote copying. It makes use of the programs to and from. #readall Command: readall - read a device quickly to check for bad blocks Syntax: readall file Flags: (none) Example: readall /dev/hd0 # Read all of /dev/hd0 Readall reads all of the named device in large chunks. It reports about blocks that it cannot read. Unlike diskcheck, it does not attempt to write on the disk, making it safer to use when one is worried about a sick system. #readclock Command: readclock - read the AT's real time clock Syntax: readclock Flags: (none) Example: date `/usr/bin/readclock` </dev/tty# Useful in /etc/rc Readclock reads the AT's real time clock and prints the result in a form useful to date, namely, MMDDYYhhmmss. If the clock does not exist (e.g., on a PC), it outputs "-q" to query the user for the time. The example given above can be put in /etc/rc to load the real time when the system is booted. #readfs Command: readfs - read a MINIX file system Syntax: readfs [-il] block_special [dir] Flags: -i Give information about the file, but do not extract files -l List the files extracted on standard output Example: readfs -l /dev/fd0 # List contents of floppy disk Readfs reads a floppy disk containing a MINIX file system. It can extract all the files from it, give a listing of them, or both. The files extracted can be put in a user-specified directory (default: current directory). If sub- directories are needed, they will be created automatically. #recover Command: recover - recover files that have been removed. Syntax: recover file ... Flags: (none) Examples: rm x; recover x # Unremove x recover a b c # Recover three files MINIX allows files that have been deleted (e.g., with rm) to be restored (in /tmp). The trick is that when a file is unlinked, its i-node number is kept in the directory entry. As long as the directory entry and disk blocks are not reused, the file can be recovered. This program is actually just a little front end for de, which must be installed and executable. #rev Command: rev - reverse the characters on each line of a file Syntax: rev [file] ... Flags: (none) Example: rev file # Reverse each line Each file is copied to standard output with all the characters of each line reversed, last one first and first one last. #rm Command: rm - remove a file Syntax: rm [-fir] name ... Flags: -f Forced remove: no questions asked -i Interactive remove: ask before removing -r Remove directories too Examples: rm file # Remove file rm -i *.c # Remove .c files, asking about each Rm removes one or more files. If a file has no write permission, rm asks for permission (type ``y'' or ``n'') unless -f is specified. If the file is a directory, it will be recursively descended and removed if and only if the -r flag is present. #rmdir Command: rmdir - remove a directory Syntax: rmdir directory ... Flags: (none) Examples: rmdir /user/ast/foobar # Remove directory foobar rmdir /user/ast/f* # Remove 0 or more directories The specified directories are removed. Ordinary files are not removed. #roff Command: roff - text formatter Syntax: roff [-hs] [+n] [-n] file ... Flags: -h Expand tabs to spaces in output -s Stop before each page; continue on DEL +n Start printing with page n n Stop after page n Examples: roff file # Run off file roff +5 file # Run off file starting at page 5 Roff is a text formatter. Its input consists of the text to be output, intermixed with formatting commands. A formatting command is a line containing the control character followed by a two character command name, and possibly one or more arguments. The control character is initially ``.'' (dot). The formatted output is produced on standard output. The formatting commands are listed below, with n being a number, c being a character, and t being a title. A + before n means it may be signed, indicat- ing a positive or negative change from the current value. Initial values for n, where relevant, are given in parentheses. .ad Adjust right margin. .ar Arabic page numbers. .br Line break. Subsequent text will begin on a new line. .bl n Insert n blank lines. .bp +n Begin new page and number it n. No n means +1. .cc c Control character is set to c. .ce n Center the next n input lines. .de zz Define a macro called zz. A line with ``..'' ends definition. .ds Double space the output. Same as .ls 2. .ef t Even page footer title is set to t. .eh t Even page header title is set to t. .fi Begin filling output lines as full as possible. .fo t Footer titles (even and odd) are set to t. .hc c The character c (e.g., %) tells roff where hyphens are permitted. .he t Header titles (even and odd) are set to t. .hx Header titles are suppressed. .hy n Hyphenation is done if n is 1, suppressed if it is 0. Default is 1. .ig Ignore input lines until a line beginning with ``..'' is found. .in n Indent n spaces from the left margin; force line break. .ix n Same as .in but continue filling output on current line. .li n Literal text on next n lines. Copy to output unmodified. .ll +n Line length (including indent) is set to n (65). .ls +n Line spacing: n (1) is 1 for single spacing, 2 for double, etc. .m1 n Insert n (2) blank lines between top of page and header. .m2 n Insert n (2) blank lines between header and start of text. .m3 n Insert n (1) blank lines between end of text and footer. .m4 n Insert n (3) blank lines between footer and end of page. .na No adjustment of the right margin. .ne n Need n lines. If fewer are left, go to next page. .nn +n The next n output lines are not numbered. .n1 Number output lines in left margin starting at 1. .n2 n Number output lines starting at n. If 0, stop numbering. .ni +n Indent line numbers by n (0) spaces. .nf No more filling of lines. .nx f Switch input to file f. .of t Odd page footer title is set to t. .oh t Odd page header title is set to t. .pa +n Page adjust by n (1). Same as .bp .pl +n Paper length is n (66) lines. .po +n Page offset. Each line is started with n (0) spaces. .ro Page numbers are printed in Roman numerals. .sk n Skip n pages (i.e., make them blank), starting with next one. .sp n Insert n blank lines, except at top of page. .ss Single spacing. Equivalent to .ls 1. .ta Set tab stops, e.g., .ta 9 17 25 33 41 49 57 65 73 (default). .tc c Tabs are expanded into c. Default is space. .ti n Indent next line n spaces; then go back to previous indent. .tr ab Translate a into b on output. .ul n Underline the letters and numbers in the next n lines. #rsh Command: rsh - remote shell for networking rsh port [-beil] Flags: -b Start the rsh in the background -e Keep stderr separate from stdout -i Take input from the local process Examples: rsh machine5 # ls rsh abc cat /usr/doc/f >f # Fetch remote file rsh foobar # Log onto remote machine The remote shell command is the way to have a distant server carry out a command over the Ethernet. The port given as the first argument can be any string of up to 6 characters, but it must match the port used by some sherver. The command will be executed and the results returned on stdout. Unless the -e flag is given, the remote stderr and stdout are merged onto the local stdout. Giving rsh with just a port and no argument is the standard way to log onto a remote machine. #rz Command: rz - receive a file using the zmodem protocol Syntax: rz [-abepquvy] [-t timeout] Flags: -a CP/M to UNIX conventions -b Binary file -e Escape for all control characters -p Protect file if it already exists -q Quiet; opposite of verbose -t Set timeout in tenths of a second -v Verbose; opposite of quiet -y Yes, clobber existing files Examples: rz </dev/tty1 >/dev/tty1 # Receive a file Rz is a program that accepts a file sent from another computer using the zmodem protocol. It is a highly complex program. See the /usr/doc/rz.doc and /usr/doc/sz.doc files for more information. #sed Command: sed - stream editor Syntax: sed [-f script_file] [edit_script] [file] Flags: -f The following argument contains the edit script Examples: sed -f script <file # Run a sed script on file sed '/pig/s//hog/g' <file # Replace pig by hog in the file Sed is a stream editor. It takes an edit script either from its argument or a file, and performs an edit session on a named file or stdin, producing output on stdout. #sh Command: sh - shell sh [file] Flags: (none) Example: sh < script # Run a shell script Sh is the shell. It permits redirection of input and output, pipes, magic characters, background processes, shell scripts and most of the other features of the V7 (Bourne) shell. A few of the more common commands are listed below: date # Regular command sort <file # Redirect input sort <file1 >file2 # Redirect input and output cc file.c 2>error # Redirect standard error a.out >f 2>&1 # Combine standard output and standard error sort <file1 >>file2 # Append output to file2 sort <file1 >file2 & # Background job (ls -l; a.out) & # Run two background commands sequentially sort <file | wc # Two-process pipeline sort <f | uniq | wc # Three-process pipeline ls -l *.c # List all files ending in .c ls -l [a-c]* # List all files beginning with a, b, or c ls -l ? # List all one-character file names ls \? # List the file whose name is question mark ls '???' # List the file whose name is three question marks v=/usr/ast # Set shell variable v ls -l $v # Use shell variable v PS1='Hi! ' # Change the primary prompt to Hi! PS2='More: ' # Change the secondary prompt to More: ls -l $HOME # List the home directory echo $PATH # Echo the search path if ... then ... else ... fi # If statement for ... do ... done # Iterate over argument list while ... do ... done # Repeat while condition holds case ... esac # Select clause based on condition echo $? # Echo exit status of previous command echo $$ # Echo shell's pid echo $# # Echo number of parameters (shell script) echo $2 # Echo second parameter (shell script) echo $* # Echo all parameters (shell script) #shar Command: shar - shell archiver Syntax: shar file ... Flags: (none) Examples: shar *.c >s # Collect C programs in shell archive sh <s # Extract files from a shell archive The named files are collected together into a shell archive written onto standard output. The individual files can be extracted by redirecting the shell archive into the shell. The advantage of shar over ar is that shar archives can be read on almost any UNIX system, whereas numerous, incompatible versions of ar are in widespread use. Extracting the files from a shell archive requires that sed be accessible. #sherver Command: sherver - shell server Syntax: sherver port Flags: (none) Example: sherver machine1 # Start a sherver listening to port The rsh command does its remote execution by doing a remote procedure call to some sherver. The sherver executes the command and then exits. Usually a master will be running to make a new one. Because shervers get their input from a pipe, remote execution cannot handle signals and CTRL-D, because they cannot be sent down a pipe. #size Command: size - print text, data, and bss size of a program Syntax: size [file] ... Flags: (none) Example: size file # Print the size of file The text, data, bss, and total sizes for each argument are printed. If no arguments are present, a.out is assumed. The amount of memory available for combined stack and data segment growth is printed in the column ``stack.'' This is the value manipulated by the chmem command. The total amount of memory allocated to the program when it is loaded is listed under ``memory.'' This value is just the sum of the other four columns. #sleep Command: sleep - suspend execution for a given number of seconds Syntax: sleep seconds Flags: (none) Example: sleep 10 # Suspend execution for 10 sec. The caller is suspended for the indicated number of seconds. This command is typically used in shell scripts. #sort Command: sort - sort a file of ASCII lines Syntax: sort [-bcdfimnru] [-tx] [-o name] [+pos1] [-pos2] file ... Flags: -b Skip leading blanks when making comparisons -c Check to see if a file is sorted -d Dictionary order: ignore punctuation -f Fold upper case onto lower case -i Ignore nonASCII characters -m Merge presorted files -n Numeric sort order -o Next argument is output file -r Reverse the sort order -t Following character is field separator -u Unique mode (delete duplicate lines) Examples: sort -nr file # Sort keys numerically, reversed sort +2 -4 file # Sort using fields 2 and 3 as key sort +2 -t: -o out # Field separator is : sort +.3 -.6 # Characters 3 through 5 form the key Sort sorts one or more files. If no files are specified, stdin is sorted. Output is written on standard output, unless -o is specified. The options +pos1 -pos2 use only fields pos1 up to but not including pos2 as the sort key, where a field is a string of characters delimited by spaces and tabs, unless a different field delimiter is specified with -t. Both pos1 and pos2 have the form m.n where m tells the number of fields and n tells the number of charac- ters. Either m or n may be omitted. #spell Command: spell - print all words in a file not present in the dictionary Syntax: spell file Flags: (none) Example: spell document # Print the spelling errors on stdout Spell is the MINIX spelling checker. It is actually a short shell script. First, the program prep strips off the roff, nroff, and troff control lines, and the punctuation, and lists each word on a separate line. These words are then sorted. The resulting output is then compared to the dictionary. Words present in the file but not present in the dictionary are listed. The diction- ary should be located in /usr/lib/dictionary. #split Command: split - split a large file into several smaller files Syntax: split [-n] [file [prefix]] Flags: -n Number of lines per piece (default: 1000) Examples: split -200 file # Split file into pieces of 200 lines each split file z # Split file into zaa, zab, etc. Split reads file and writes it out in n-line pieces. By default, the pieces are called xaa, xab, etc. The optional second argument can be used to provide an alternative prefix for the output file names. #strings Command: strings - print all the strings in a binary file strings file ... Flags: - search whole file, not just data seg -o Print octal offset of each string -n N is minimum length string (default = 4) Examples: strings -5 a.out # Print the strings > 4 chars in a.out strings - /bin/sh # Search entire shell file (text and data) Strings looks for sequences of ASCII characters followed by a zero byte. These are usually strings. This program is typically used to help identify unknown binary programs #strip Command: strip - remove symbol table from executable file Syntax: strip [file] ... Flags: (none) Example: strip a.out # Remove symbols from a.out For each file argument, strip removes the symbol table. Strip makes a copy of the file being stripped, so links are lost. #stty Command: stty - set terminal parameters Syntax: stty [option ...] Flags: (none) Examples: stty -echo # Suppress echoing of input stty erase # # Set the erase character to # When given no arguments, stty prints the current terminal parameters. It can also be used to set the parameters, as follows: cbreak - Enter cbreak mode; erase and kill disabled echo - Echo input on the terminal nl - Accept only line feed to end lines raw - Enter raw mode; no input processing at all tabs - Output tabs (do not expand to spaces) erase c - Set erase character (initially backspace) int c - Set interrupt (SIGINT) character (initially DEL) kill c - Set kill line character (initially @) quit c - Set quit (SIGQUIT) character (initially CTRL-\) default - Set options back to original values The first five options may be prefixed by - as in -tabs to turn the option off. The next four options each have a single character parameter separated by a space from the option. The default option sets the mode and the four settable characters back to the values they had when the system was booted. It is use- ful when a rogue program has messed them up. #su Command: su - temporarily log in as super-user or another user Syntax: su [name] Flags: (none) Examples: su # Become super-user su ast # Become ast Su can be used to temporarily login as another user. It prompts for the super-user password. If the correct password is entered, su creates a shell with the desired uid. If no name is specified, root is assumed. To exit the temporary shell, type CTRL-D. #sum Command: sum - compute the checksum and block count of a file Syntax: sum file Flags: (none) Examples: sum /user/ast/xyz # Checksum /user/ast/xyz Sum computes the checksum of one or more files. It is most often used to see if a file copied from another machine has been correctly received. This program works best when both machines use the same checksum algorithm. #svc Command: svc - shell version control system Syntax: ci [-l] [-u] file co [-l] [-r rev] file svc file Flags: -l For ci, checkin, checkout again, and lock file -l For ci, checkout file and then lock the archive -u After checking in, do not delete the file -r Check out revision rev instead most recent revision Examples: ci -u file # Check in file co -l file # Check out file and lock archive co -r 2 file # Check out version 2 Svc is the Shell Version Control system, patterned on RCS. It maintains a sequence of versions in archive files, so that new versions can be checked in (added to the archive), and old versions can be checked out (made available). To create an archive for file, check it in with the -u flag. This action will prompt for a log message and then create an archive called file,S in the current directory, or in the subdirectory SVC if it exists. The file will not be deleted, but will be made unwritable. To update the file, check it out with the -l flag. Then modify it, and check it back in, giving a new message when prompted. After this process has been repeated many times, the archive will contain the entire history. Any version can be checked out using the -r flag. To get a printout of the his- tory, use svclog. #sync Command: sync - flush the cache to disk Syntax: sync Flags: (none) Example: sync # Write out all modified cache blocks MINIX maintains a cache of recently used disk blocks. The sync command writes any modified cache blocks back to the disk. This is essential before stopping the system, and should be done before running any a.out program that might crash the system. #sz Command: sz - send a file using the zmodem protocol Syntax: sz [-+LNbdefnopqruvy] [-ci command] [-Ll n] [-t timeout] Flags: -+ Append to an existing file -L Use n-byte packets -N Overwrite if source is newer/longer -b Binary file -c Send command for execution -d Convert dot to slash in names -e Escape for all control characters -f Send full path name -i Send command and return immediately -l Flow control every n packets -n Overwrite destination if source is newer -o Use old (16-bit) checksum -p Protect file if it already exists -q Quiet; opposite of verbose -r Resume interrupt file transfer -t Set timeout in tenths of a second -u Unlink file after successful transmission -v Verbose; opposite of quiet -y Yes, clobber existing files Examples: sz file </dev/tty1 >/dev/tty1# Send file Sz is a program that sends a file sent from another computer using the zmo- dem protocol. It is a highly complex program. See the /usr/doc/sz.doc and /usr/doc/rz.doc files for more information. #tail Command: tail - print the last few lines of a file Syntax: tail [-n] [file] ... Flags: -n How many lines to print Examples: tail -6 # Print last 6 lines of stdin tail -1 file1 file2 # Print last line of two files The last few lines of one or more files are printed. The default count is 10 lines. The default file is stdin. #tar Command: tar - tape archiver Syntax: tar [cxtv] tarfile file ... Flags: -F Force tar to continue after an error -c Create a new archive -o Use the uid/gid of the extractor -t Print a table listing the archive's contents -v Verbose mode-tell what is going on as it happens -x The named files are extracted from the archive Examples: tar c /dev/fd1 file1 file2 # Create a two-file archive tar xv /dev/fd1 file1 file2 # Extract two files from the archive (cd src; tar c -) | (cd dest; tar x -)# Move src tree to dest Tar is an archiver in the style of the standard tape archiver, except that it does not use tape. It's primary advantage over ar is that the tar format is somewhat more standardized than the ar format, making it theoretically possible to transport MINIX files to another computer, but do not bet on it. If the target machine runs MS-DOS, try doswrite. #tee Command: tee - divert stdin to a file Syntax: tee [-ai] file ... Flags: -a Append to the files, rather than overwriting -i Ignore interrupts Examples: cat file1 file2 | tee x # Save and display two files pr file | tee x | lpr # Save the output of pr on x Tee copies stdin to standard output. It also makes copies on all the files listed as arguments. #term Command: term - turn PC into a dumb terminal Syntax: term [baudrate] [parity] [bits_per_character] Flags: (none) Examples: term 2400 # Talk to modem at 2400 baud term 1200 7 even # 1200 baud, 7 bits/char, even parity term 8 9600 # 9600 baud, 8 bits/char, no parity Term allows MINIX to talk to a terminal or modem over RS232 port 1. The program first sets the baudrate, parity and character length, and then forks. The parent sits in a loop copying from stdin (usually the console's keyboard), to the terminal or modem (/dev/tty1). The child sits in a loop copying from the terminal or modem (/dev/tty1) to standard output. Thus when RS232 port 1 is connected to a modem, every keystroke typed on the keyboard is sent to the modem, and every character arriving from the modem is displayed. Standard input and output may be redirected, to provide a primitive file transfer pro- gram, with no checking. To exit term, hit the middle button on the numeric pad. Important note: to use term, it is essential that /etc/ttys is configured so that there is no shell hanging on /dev/tty1. If there is, both the shell and term will try to read from /dev/tty1, and nothing will work. #termcap Command: termcap - print the current termcap entry Syntax: termcap [type] Flags: (none) Example: termcap # Print the termcap entry Termcap reads the /etc/termcap entry corresponding to the terminal type sup- plied as the argument. If none is given, the current $TERM is used. It then prints out all the parameters that apply. #test Command: test - test for a condition Syntax: test expr Flags: (none) Example: test -r file # See if file is readable Test checks to see if files exist, are readable, etc. and returns an exit status of zero if true and nonzero if false. The legal operators are -r file true if the file is readable -w file true if the file is writable -x file true if the file is executable -f file true if the file is not a directory -d file true if the file is a directory -s file true if the file exists and has a size > 0 -t fd true if file descriptor fd (default 1) is a terminal -z s true if the string s has zero length -n s true if the string s has nonzero length s1 = s2 true if the strings s1 and s2 are identical s1 != s2 true if the strings s1 and s2 are different m -eq m true if the integers m and n are numerically equal The operators -gt, -ge, -ne, -le, -lt may be used as well These operands may be combined with -a (Boolean and), -o (Boolean or), ! (negation). The priority of -a is higher than that of -o. Parentheses are permitted, but must be escaped to keep the shell from trying to interpret them. #time Command: time - report how long a command takes Syntax: time command Flags: (none) Examples: time a.out # Report how long a.out takes time ls -l *.c # Report how long ls takes The command is executed and the real time, user time, and system time (in hours, minutes, and seconds) are printed. #to Command: to - output half of a connection Syntax: to port Flags: (none) Example: cat f1 f2 | to mach4 # Send the catted files to port 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. As a simple example, consider: on machine1: cat f1 f2 | to Johnny on machine2: from Johnny | sort >x The effect of these two commands is that the files f1 and f2 are concatenated, transferred to machine 2, and sorted their, with the output going to a file x on machine 2. The string Johnny is used by the transaction system to identify which sender goes with which receiver; any unique string can be used. #touch Command: touch - update a file's time of last modification Syntax: touch [-c] file ... Flags: -c Do not create the file Example: touch *.h # Make the .h files look recent The time of last modification is set to the current time. This command is mostly used to trick make into thinking that a file is more recent than it really is. If the file being touched does not exist, it is created, unless the -c flag is present. #tr Command: tr - translate character codes Syntax: tr [-cds] [string1] [string2] Flags: -c Complement the set of characters in string1 -d Delete all characters specified in string1 -s Squeeze all runs of characters in string1 to one character Examples: tr ''[a-z]'' ''[A-Z]'' <x >y # Convert upper case to lower case tr -d ''0123456789'' <f1 >f2 # Delete all digits from f1 Tr performs simple character translation. When no flag is specified, each character in string1 is mapped onto the corresponding character in string2. #traverse Command: traverse - print directory tree under the named directory Syntax: traverse dir Flags: (none) Example: traverse . # Print tree starting at working dir Traverse prints the tree structure starting at the named directory. All the subdirectories are listed, with the depth shown by indentation. #treecmp Command: treecmp - recursively list differences in two directory trees Syntax: treecmp [-v] dir1 dir2 Flags: -v (verbose) list all directories processed Example: treecmp -v /usr/ast/V1 /usr/ast/V2# Compare two trees Treecmp recursively descends the directory tree of its first argument and compares all files to those at the corresponding position in the second argu- ment. If the two trees are identical, i.e., all the corresponding directories and files are the same, there is no output. Otherwise, a list of files missing from one of the trees or present in both but whose contents are not identical in both are printed. #true Command: true - exit with the value true Syntax: true Flags: (none) Example: while true # List the directory until DEL is hit do ls -l done This command returns the value true. It is used for shell programming. #tset Command: tset - set the $TERM variable Syntax: tset [device] Flags: (none) Example: eval `tset` # Set TERM Tset is used almost exclusively to set the shell variable TERM from inside profiles. If an argument is supplied, that is used as the value of TERM. Oth- erwise it looks in /etc/ttytype. #tsort Command: tsort - topological sort Syntax: tsort file Flags: (none) Example: ar cr libc.a `lorder *.s | tsort`# Build library Tsort accepts a file of lines containing ordered pairs and builds a total ordering from the partial orderings. #ttt Command: ttt - tic tac toe Syntax: ttt Flags: (none) Example: ttt # Start the game This program allows the user to engage in a game of tic tac toe (noughts and crosses) with the computer. The program uses the alpha-beta algorithm, so the user had better be sharp. #tty Command: tty - print the device name of this tty Syntax: tty Flags: -s Silent mode (return status only) Example: tty # Print the tty name Print the name of the controlling tty #umount Command: umount - unmount a mounted file system Syntax: /etc/umount special Flags: (none) Example: /etc/umount /dev/fd1 # Unmount floppy disk 1 A mounted file system is unmounted after the cache has been flushed to disk. A floppy disk should never be removed while it is mounted. If this happens, and is discovered before another floppy disk is inserted, the original one can be replaced without harm. Attempts to unmount a file system holding working directories or open files will be rejected with a ``device busy'' message. #unexpand Command: unexpand - convert spaces to tabs Syntax: unexpand [-a] Flags: -a All spaces are unexpanded Example: unexpand oldfile >newfile # Convert leading spaces to tabs Unexpand replaces spaces in the named files with tabs. If no files are listed, stdin is given. The -a flag is used to force all sequences of spaces to be expanded, instead of just leading spaces (the default). #uniq Command: uniq - delete consecutive identical lines in a file Syntax: uniq [-cdu] [+n] [-n] [input [output]] Flags: -c Give count of identical lines in the input -d Only duplicate lines are written to output -u Only unique lines are written to output Examples: uniq +2 file # Ignore first 2 fields when comparing uniq -d inf outf # Write duplicate lines to outf Uniq examines a file for consecutive lines that are identical. All but duplicate entries are deleted, and the file is written to output. The +n option skips the first n fields, where a field is defined as a run of charac- ters separated by white space. The -n option skips the first n spaces. Fields are skipped first. #update Command: update - periodically write the buffer cache to disk Syntax: /etc/update Flags: (none) Example: /etc/update & # Start a process that flushes the cache When the system is booted, update is started up in the background from /etc/rc to issue a SYNC system call every 30 sec. #users Command: users - list the logged-in users Syntax: users Flags: (none) Example: users # list the users Users prints a single line of text containing the names of all the currently logged-in users. #uud Command: uud - decode a binary file encoded with uue Syntax: uud [-n] [-s srcdir/] [-n dstdir/] file Flags: -n Do not verify checksums -s Name of directory where .uue file is -t Name of directory where output goes Examples: uud file.uue # Re-create the original file uud - <file.uue # The - means use stdin Uud decodes a file encoded with uue or UNIX uuencode. The decoded file is given the name that the original file had. The name information is part of the encoded file. Mail headers and other junk before the encoded file are skipped. #uue Command: uue - encode a binary file to ASCII (e.g., for mailing) Syntax: uue [-n] file [-] Flags: -n Do not verify checksums -n How many lines to put in each file Examples: uue file # Encode file to file.uue uue file - >x # Encode file and write on stdout uue -800 file # Output on file.uaa, file.uab etc. Uuuencode is a famous program that converts an arbitrary (usually binary) file to an encoding using only 64 ASCII characters. Uudecode converts it back to the original file. The uue and uud programs are the MINIX versions of these programs, and are compatible with the UNIX ones. The files produced can even be sent successfully over BITNET, which is notorious for mangling files. It is possible to have uue automatically split the encoded file up into chunks small enough to fit into mail messages. The output files then get the suffixes .uaa, .uab, etc., instead of .uue. When uud is given file.uaa to decode, it automat- ically includes the subsequent pieces. The encoding takes 3 bytes (24 bits) from the input file and renders it as 4 bytes in the output file. #vol Command: vol - split stdin into diskette-sized volumes Syntax: vol [-u] size block_special Flags: -u Unsave from diskettes Examples: tar c - . | vol 360 /dev/fd0 # Prompt for disk every 360K vol -u 360 /dev/fd0 | tar x - # Restore a saved file system It occasionally happens that a program generates an output stream intended for diskette but the stream is to large to fit on one diskette. Vol is a pro- gram that accepts such a stream, and pauses every n blocks to request a new diskette to be inserted. This makes it possible to save arbitrarily long streams on a series of diskettes, as shown in the examples above. #wc Command: wc - count characters, words, and lines in a file Syntax: wc [-clw] file ... Flags: -c Print character count -l Print line count -w Print word count Examples: wc file1 file2 # Print all three counts for both files wc -l file # Print line count only Wc reads each argument and computes the number of characters, words and lines it contains. A word is delimited by white space (space, tab, or line feed). If no flags are present, all three counts are printed. #whatsnew Command: whatsnew - print a newly modified file, marking changes Syntax: whatsnew [-n] file.c file.c.cdif Flags: -n Output line length Examples: whatsnew file.c file.c.cdif # Print file.c with changes marked whatsnew -70 file.c file.c.cdif# Same as above, but with 70 column line It commonly occurs that cdifs are posted to USENET. After installing a cdif file, it is sometimes desirable to print out the new file, with the changes marked on it. Whatsnew does precisely this, with the changes + and ! printed in the right-hand margin. #whereis Command: whereis - examine system directories for a given file Syntax: whereis file Flags: (none) Example: whereis stat.h # Prints: /usr/include/sys/stat.h Whereis searches a fixed set of system directories, /bin, /lib, /usr/bin, and others, and prints all occurrences of the argument name in any of them. #which Command: which - examine $PATH to see which file will be executed Syntax: which name Flags: (none) Example: which a.out # Tells which a.out will be executed The $PATH shell variable controls the MINIX search rules. If a command a.out is given, the shell first tries to find an executable file in the working directory. If that fails, it looks in various system directories, such as /bin and /usr/bin. The which command makes the same search and gives the absolute path of the program that will be chosen, followed by other occurrences of the file name along the path. #who Command: who - print list of currently logged in users Syntax: who [file] Flags: (none) Example: who # Print user names, terminals and times Who prints a list of currently logged in users. For each one, the user name, terminal, and login time is printed. This program gets its information from the file /usr/adm/wtmp, which is updated by init and login. If the file does not exist, neither of these will create it, and who will not work. Note that if you decide to create an empty /usr/adm/wtmp to enable the login accounting, it will grow forever and eventually fill up your disk unless you manually truncate it from time to time. If an optional file name is provided, the logins in that file will be printed. #whoami Command: whoami - print current user name Syntax: whoami Flags: (none) Example: whoami # Print user name In case you forget who you are logged in as, whoami will tell you. If you use su to become somebody else, whoami will give the current effective user. #width Command: width - force all the lines of a file to a given width Syntax: width [-n [ infile [outfile] ] Flags: -n Outline line size Examples: width -60 x y # Copy x to y, force lines to 60 cols width x # Copy default (80) column lines to stdout The input file is copied to the output file. All lines are forced to a given size (default: 80 columns) by padding with spaces or truncating. Tabs are expanded to spaces. #write Command: write - send a message to a logged-in user Syntax: write [cv] user [tty] Flags: -c Use cbreak mode -v Verbose mode Examples: write ast # Send a message to ast write ast tty1 # Send a message to ast on tty0 Write lets a user send messages to another logged-in user. Lines typed by the user appear on the other user's screen a line at a time (a character at a time in the case of cbreak mode). The file /usr/adm/wtmp is searched to deter- mine which tty to send to. If the user is logged onto more than one terminal, the tty argument selects the terminal. Type CTRL- D to terminate the command. Use ! as a shell escape.