<<

Unix Notes for Tutorial Inclusion – From OS-X Tutorial v4.doc From p 10 reports where the ls is found ls -lt long list sorted by modified ls –h sometimes give on a command like ls ls .. listing of next higher directory .hidden creates a hidden name .hidden if it does not exist, modifies the date if it does exist ls ../.. directory listing of two levels up man > put man entry for tcsh command into file –i rename file1 to file2; if it would overwrite, ask first; if -f then don't ask, just overwrite if needed. –i delete file1 and file2; ask first to verify; -d to empty as well as files; -f attempts to override permissions, but gives no errors -r delete dir and everything in it, implies -f; -P delete & scrub 3 x rm -r * display command as it would actually be executed for each file matched, but no deletions rm -r /Users/Jim\ Deleted danger: admin allowed delete of all of Users/"Jim Delete" mv ~/.Trash/ file to the desktop trash bin, rather that direct delete From p 19 trash mv \:\* ~/.Trash/ creates new command which translates to mv ~/.Trash display the command history file ~/.tcsh_history look history in less !59 recall command #59 from history to command line p20,26 notes on creating new defaults for command via alias p22 pushd

push the onto the directory stack popd pop the directory entry on the stack to the command line pushd ~ push to home directory onto the stack dirs – the directory stack, one directory per line pushd –v popd –v pushdsilent no stack printed on a pushd or popd man tcsh you can search this for on –p create directory with all nec intermediate directories mkdir –p a///d create directory d with any of a, b, c if needed ls –R list directory of current recursively example:**** mkdir –p one/too/for/three create a nest of directories mv one/too one/two correct spelling error; too->two mv one/two/for/three one/two ?? mv one/two/for one/two/three/four move dir for from under two to under three and simultaineously correct spelling

Unix Notes for Tutorialv4.doc Page 1 JFW ls –R one check current nest ******* p24 mkdir –p a/b/c/d create a nest of dirs –p a/b/c/d if empty remove the nest of dirs ls –ld

lists not contents of dir but details of dir note: on a mv a trailing means treat as if a dir, e.g. mv path1/two path2/ p26 ls b[aeiou]g list dir for dirs bag, beg, big, bog, bug rm .txt does ls [mt]*day[0-9] matches m or t followed by day followed by a digit –R copies dir and nested dirs (and files) below to dir2 rm –ri deletes the files in dir2 and the subdirectorys but asks for confirmation first rm –r * deletes everything in currect directory; if entered at top level (root) deletes everything without asking for confirmation note: danger*** cp does not resource forks; use command ditto rm –rf danger: removes recursively without warning, even if not normally allowed to delete p28 ~ report size of every dir from home down; units at blocks – 512 bytes = 1/2 k; so divide by 2 to get in units of k du –sk ~ print a single line of total size of directory in units of k –k show how full each disk and partition is in units of k ls –aF display each file with a trailing character to indicate file ls –Fsk display each file with file type and file size in units of k file determine file type last reports loged in since last cleanup, when and what p30 user ; primary group= staff, admin, wheel, shadowy users = daemon, nobody, unknown, www, root spare user—with admin access good idea p31 permissions as three triplets read (r) () execute (x) owner group other r w x r w x r w x Applications/ directory , only admin user can add items, others can read and execute only rwxrwxr-x /System/Library/ only root owner can modify this; others and even those in admin group can only read and execute. rwxr-xr-x ls –l lists contents of dir with permissions ls –ld examines the enclosing directory, i.e. the directory itself =

Unix Notes for Tutorialv4.doc Page 2 JFW who can be owner (u), group (g), other (o) prot can be either a set of prots to be enabled or + to add or - to disable chmod u=rwx set read, write and execute for owner chmod g=rx set only read for others chmod u=rwx, g=rx,o=r set all three as stated chmod o-r disable the read on other chmod g+w add write to group : chown :admin new group is admin chown weiher:staff new user owner is weiher, new group owner is admin; needs sudo and admin PW p34 /Users/Shared everyone can write to it but only as an append. Note this has the (t) set drwxrwxrwt . Others can add to the directory (w) but not remove any files. ~/Public/ others can read but not write ~/Public/Drop\ Box/ others can write and execute, but not read note Finder shows root as System, sounds Mac-like ~/ shortcut of home of another user nidump / shows all users nidump group / shows all groups note: in single user mode, these are held as flat files in /etc/passwd and /etc/groups as in many other UNIX systems passwd to change your password id gives your UID, user name, primary GID, group name and list of all groups to which you belong.

P38 Shells- The is your interface to the UNIX OS; it listens for input, launches other programs as found in the command line, displays output of those programs. Displays a prompt, keeps a command history, allows auto completion, includes framework to enable piping and a . The Terminal is an Aqua program that runs the shell for you. It adds the and , drag and drop complete -, etc for ease of use The (sh) is in every UNIX system, good scripting system, poor interactives csh was an improvement on sh but scriping is different tcsh was a further improvement incorporating many OS-features that DEC developed in their PDP-6, 10, Tops-10 etc systems. Good interactives but different scripting than sh (is default for OSX10.1 and 10.2 incorporated many improvements of previous systems, retaining excellent interactive behavior but with a scripting system upward compatible with sh (bourne again shell) is default for OSX10.3

Unix Notes for Tutorialv4.doc Page 3 JFW p40 *.txt display first 10 or so lines the each file with extension .txt head –25 /var/log/system.log display first 25 lines of system log /var/log/system.log display last 10 or so lines of system log tail –f /var/log/system.log display last 10 or so lines of system log but leave it open and display any additions to the file (a command line equivalent of the aqua console program.) ctrl-c to end P41 using the locate database all files matching the given pattern. This database is updated weekly if your computer is on all the time. If it is not you need to run the update yourself from the command line (see chrontab) or use a shareware program, Cocktail. Normally the pattern is in quotes. Legal wild cards are *, ?, [] but the pattern must be in quotes and have an asterisk in front. If unquoted and no * before or after the given string it is sent to locate with an asterisk at the and and the end locate “bio” If an explicit string is given any match anywhere is found locate “Bio.*”If a wild card is included, then the exact absolute path only is searched, so if nothing at top level it will not be found. locate bio is the same as locate “*bio*” or “bio” locate bio.* because not quoted and one (so it is not “*bio*”, the * is expanded by the shell to get the name in the current directory that match a ls of bio.*. If that is more than one the list is sent to locate which fails because locate can take only one argument. If there is only one such entry however, it is sent to locate, and locate finds that item. Note: to see the expansion of the shell before executing a command before entering the return, enter ctl-X followed by *. The expanded version will the glob pattern locate "Bi[Go]" will not find anything because it includes wildcards and not * at front. locate "*Bi[Go]" will find anything ending in BiG or Bio anywhere locate "*Bi[Go]*" will find any file anywhere containing BiG or Bio locate "MLP*" will not find anything because no * at front locate "*MLP?P" will locate any file ending in MLP(any char)P

P42 find [options] [pattern] [action] runs a live search of the , from the start- dir down. It is slower than locate, but will find files created after the last locate database update and has many more features. Legal wildcards are *, ?, [ ] in the name options, but the pattern must be quoted to keep the shell from expanding them. find . lists all files in the current directory down find . –name “*.txt” will find all files with name matching *.txt from current dir down find ~/Sites –mtime 5 find in your Sites directory all files modified 5 days ago find ~/Sites –mmin 12 find in your Sites directory all files modified 12 minutes ago

Unix Notes for Tutorialv4.doc Page 4 JFW find ~/Sites –mtime –7 find in your Sites dir all files modified less than 7 days ago find ~/Sites –mtime +7 find in your Sites dir all files modified moe than 7 days ago find ~ -newer last-backup.log find all files changed or created since the last-backup.log was modified find ~ –size +2000 find all files larger than 2000 blocks (i.e. 512 byte blocks) find ~ -size –2000 find all files smaller than 2000 blocks (i.e. 512 byte blocks) find . –empty find all empty files (includes empty directories that do have the . and .. in them so they are not 0 bytes long. find ~ -name “*.doc” –ls give a dir listing of all files matching the pattern inyour home dirs find ~ -name “*.txt” –exec {} \; do a cat listing on all files found find ~ -name “*.sh” –ok chmod a+x {} \; change the protection on all files found. find . -maxdepth 2searches nested dirs only 2 levels find . -maxdepth 2 -name "index.*" finds ./Sites/index.html (here ~ was current dir) find . -maxdepth 2 -name "ind" finds nothing (here ~ was current dir) find . -maxdepth 2 -name "ind*" finds ./Sites/index.html (here ~ was current dir) find . -maxdepth 2 -name "ind??.*" finds ./Sites/index.html (here ~ was current dir) find . -maxdepth 2 -name "ind??" finds nothing (here ~ was current dir) find . -maxdepth 2 -name ind finds nothing (here ~ was current dir) find . -maxdepth 2 -name index.html finds ./Sites/index.html (here ~ was current dir) Note on times in find: -amin and -atime are access time -cmin and -ctime are changed time (i.e. change in any way, permissions changed or content) -mmin and -mtime are contents modified time sh run the Bourne shell csh run the c-shell tcsh run the tcsh bash run the Bourne again shell zsh run the z-shell p46 [optons] get regular expressson grep Janice * get occurrences of string Janice in files in current directory grep –I Adrian * get occurrences of string Adrian, case insensitive in files in current dir grep –ic Adrian * get and count occurrences of Adrian in each file grep –li Adrian * get filenames only of files that contain string Adrian, case insensitive grep –hi Adrian * list only lines contain Adrian (case insensitive) i.e. no file names grep –w *pattern must occur as a word , not part of a word other options: -v is search of lines not having pattern -I is ignore binary files -E is use extended regular expressions; equivalent of egrep -r is do a recursive search grep –iIrc Monday * find Monday occurrences case insensitive, ignore binary files, recursive to all dirs below the current one Wildcards in regular expressions:

Unix Notes for Tutorialv4.doc Page 5 JFW [chrs] any character inside the [] will be a match for that postion [^chrs] any character but those inside the [] will be a match [chr1-chr2] any character between and included chr1 and chr2 will be a match . any charcter in a list in [] a literal ] must be first in a list in [] a literal ^ must not be first in a list in [] a literal - must be last the $ anchors to the end of line for a match the ^ anchors to the beginning of line \< matches the empty at the beginning of a word \> matches the empty at the end of a word \b matches the empty a the edge of a word \B matches the empty anywhere but at the end of a word ? is a repetition operator; preceding item must be repeated 0 or 1 time * is a repetition operator; preceding item must be matched 0 or more times + is a repetition operator; preceding item must be matched 1 or more times {n} is a repetition operator; preceding item must be matched exactly n times {n,} is a repetition operator; preceding item must be matched n or more times {n,m} is a repetition operator; preceding item must be matched at least n times but not more than m times two regular expressions can be concatenated; a match is any string which is a contatenation of the match for each two regular expressions can combined with the infix operator (|); a match is a match for either expression repetition take precedence over concatenation which takes preference over alternation any subexpression can be enclosed in ( ) to override the default precedence backreference \n matches the substring previously matched by the nth parenthesized subexpression; n must be a single digit. The metacharacters ? + { | ( and ) in basic regular expressions lose their special meaning; use the backslashed versions instead \? \+ \{ \| \( \) Examples: ‘Janice’ simple string will be matched only by that string ‘Ja.’ Will match Ja followed by any character, but not match the word Ja; it will match Jazz, Jabber, Jane etc ‘Ja..e’ will match Ja followed by any two characters followed by e; thus matches Jabber and Jayne but not Jane ‘J[aeiou]n’ will match the first three characters of Janice, Jenny, Jinny, Jon, or June but not Jean because one one the the alternative characters can be matched against. ‘F[0-9][a-z][A-Z]L’ will match F0oOL for example ‘Ja*’ will match J, Ja, Jaa, Jaaa or the first two characters of Janice. Note * does not match anything, it is a repetition operator. ‘He+lp’ will match Help, Heeeelp, but not Hlp ‘He?lp’ will match either Hlp or Help, no others ‘K[a-zA-Z][0-9]’ will match K followed by an upper or lowercase character followed by a digit ‘J.*e’ will match J followed by any number of any characters followed by an e; e.g. Je, Jayne or Jpokijuyklyt6o9e

Unix Notes for Tutorialv4.doc Page 6 JFW ‘J[aeiou]+n’ will match J followed by one or more vowels followed by n; e.g. Jen and Jean and Jeeeeeeaaaaaaaaaan ‘^Start’ matches Start but only a the beginning of a line ‘End$’ matche End but only at the end of a line ‘^A whole line$’ will match only a line that contains only ‘A whole line’ and nothing else ‘goodbye.$’`matches at the end of a line goodby. And goodbyZ because the . is interpreted as any character not as the literal . To treat a special character as a literal use the backslash or []; e.g. \. Or [.] for the literal .

‘x+’ is the same as ‘xx*’ ‘j*’ will match anything! Note: wildcards in shell globbing have a different meaning than in regular expressions. To see what the shell will do to a regular expression, before you give the return to the command, enter chrtl-x followed by *. The line will be rewritten as the shell expands it. To regular expression at Terminal enter grep or egrep followed by the desired pattern (in single quotes of course). Terminal waits on the next line for input from you. Enter a string to see if it matches. If it matches it will be echoed back and Terminal will for another test. If it does not match the Terminal will just wait for another test. Use ctrl-D to end the cycle. P 47 cat invoke cat program, waits for input from keyboard and echoes each line inpu cat displays contents of to the standard output (display by default) cat letter.txt > copy_of_letter.txt displays contents of file letter.txt and writes same to a file copy_of_letter.txt replacing any previous contents the file had. The shell interprets the redirection operator > and writes the output of cat into the new file. If the file did not exist, one is created. ls –al > ls.txt output of ls is written to the file ls.txt ls –al >> ls.txt output of ls is appended to the end of the existing file ls.txt ‘a’ ‘b’ waits for input and in any input every occurance of a is replaced by b tr ‘\r’ ‘\n’ < mac-file > unix-file tr takes input from mac-file replaces every mac style end of line (return) to a unix style end of line (new line) and writes to unix-file. tr ‘\r’ ‘\n’< file1 >tmp; mv tmp file first command write converted file to a temporary and sencond command changes the name of the file (tmp) to file1 replacing the previous contents. cat file1 >& outfile writes contents of file 1 to outfile, including any error msgs (cat file1 > outfile ) >& errfile writes contents of file 1 to outfile and then nothing is left but error msgs which are written to errfile P 55 ls –al

| grep “^……..w”takes the long listing of directory and finds all lines in whch others have write permission and outputs them to the standard output stream. Note the start of line anchor and the 8 dots to match any 8 characters (the dir marker (1), the user priv (3), the group priv (3) and the other read priv).

Unix Notes for Tutorialv4.doc Page 7 JFW cx | grep –i finder uses ps (the status program) to get all running processes, including those without a controlling terminal (-w) and report them using just the (not the full path, -c) Note that here the normal for a flag (-) is not needed but can be used. The i flag allows the lower case in the search pattern to match the Finder entry. Note also that for grep the explicit string does not need to be quoted. P 56 sudo cmd1 | cmd2 cmd1 required super user priv, cmd2 did not; output of cmd1 is piped by the shell to cmd2. cmd1 is run by root; cmds 2 is not. ps cux | grep –i –e finder –e pid ps outputs the lines with more info (-u); grep finds and outputs all lines with either finder (the process we are looking for) or pid (one of the heading items) in the line. Notice grep can have to more than one match string if each is preceded by the –e. cmd1 | cmd2 | cmd3 | cmd4 output of 1 is pipelined to 2, output of 2 to 3, output of 3 to 4 cat file1 | grep Hello if there is an error, e.g. the file does not exist, the error msg is sent to the terminal not grep. cat file1 |& grep Helloerror msgs are also sent to grep p 93 chmod u+t testdir sets the sticky bit for the directory; others can append but not delete from the directory chmod g+t testdir sets the sticky bit for the directory; others can append but not delete from the directory chmod o+t testdir has no effect chmod u-t testdir clears the sticky bit

Macworld Nov 2002 p90 open /Applications/calculator.app open the calculator applicaton open /Users/weiher/Pictures Finder open my Pictures folder

MacAddict July 2003 p59 sudo softwareupdate p94 /usr/share/emacs/21.1/lisp/play displays the list of text based games; type ‘emacs’ to launch this editor, then escape followed by ‘x’ to get to the menu bar. Finally type in the name of the script minus the .el or .etc extension and you are off to the races.

MacAddict Nov 2003 p 65 df –kl shows free disk space –l for local only, -k for in Kb

MacAddict Dec 2003 p 69 find . –name ‘*and*’ –type f finds all files of type file (f) whose names contain the string ‘and’ starting at the current dir and working down the directory

Unix Notes for Tutorialv4.doc Page 8 JFW Macworld April 2003 p 89 Ditto –rsrcFork ~/*.doc /private/tmp will copy all your wp documents to a temp directory including the resource forks. `cat gohere.txt` file gohere.txt contain a line with a directory; the backticks send the result the display of that file to cd. So the new working dir is set accordingly find ~ -name ‘*.doc’ | cpio –o | > `date +~/%Y%m%d.cpio.gz` the find lists the name of all doc files in your home folder. This is passed to cpio (copy I/O) which is a simplified unix version of Stuffit. The output option (-o) tells t yor want to create an archive. That output is sent to gzip, which it and write it to a file whose name is made up out of the date command: your home folder (~), the exact date (%Y%m%d), followed by the typical file extension attached to a file that has passed through cpio and gzip (cpio.gz). You can restore individual files by reversing the process as next shown. gzip - YYYYMMDD.cpio.gz | cpio -idr ‘*filename*’ the YYYYMMDD is the date you made the archive; filename is part of the filename you want to restore. For each match you will be asked if you want to restore it and where. To restore the entire archive omit the –r. To look at all files and decide if you want to restore each one omit the ‘*filename*’ an Example of this archiving and dearchiving : [WeiherG4:~] weiher% find ~ -name '*Unix\ Notes*' /Users/weiher/Documents/unix stuff/Unix Notes for Tutorial I.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv3.doc [WeiherG4:~] weiher% find ~ -name '*Unix\ Notes*' | cpio -o | gzip > `date +~/%Y%m%d.cpio.gz` [WeiherG4:~] weiher% find ~ -name '*cpio.gz*' /Users/weiher/20031128.cpio.gz [WeiherG4:~] weiher% find ~ -name '*Unix\ Notes*' /Users/weiher/Documents/unix stuff/Unix Notes for Tutorial I.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv3.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv4.doc [WeiherG4:~] weiher% gzip -dc 20031128.cpio.gz \ cpio -idr `*Tutorial*` *Tutorial*: No match. gzip: illegal option -- i usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...] [WeiherG4:~] weiher% gzip -dc 20031128.cpio.gz | cpio -idr `*Tutorial*` *Tutorial*: No match.

Unix Notes for Tutorialv4.doc Page 9 JFW ATTENTION: cpio interactive file rename operation. -rw-r--r-- Nov 23 07:07 /Users/weiher/Documents/unix stuff/Unix Notes for Tutorial I.doc Input new name, or a "." to keep the old name, or a "return" to skip this file. Input > Skipping file.

ATTENTION: cpio interactive file rename operation. -rw-r--r-- Nov 27 16:12 /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2.doc Input new name, or a "." to keep the old name, or a "return" to skip this file. Input > /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2a.doc Processing continues, name changed to: /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2a.doc

ATTENTION: cpio interactive file rename operation. -rw-r--r-- Nov 28 11:51 /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv3.doc Input new name, or a "." to keep the old name, or a "return" to skip this file. Input > Skipping file.

ATTENTION: cpio interactive file rename operation. -rw-r--r-- Nov 28 15:09 /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv4.doc Input new name, or a "." to keep the old name, or a "return" to skip this file. Input > Skipping file. [WeiherG4:~] weiher% find ~ -name '*Unix\ Notes*' /Users/weiher/Documents/unix stuff/Unix Notes for Tutorial I.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv2a.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv3.doc /Users/weiher/Documents/unix stuff/Unix Notes for Tutorialv4.doc [WeiherG4:~] weiher%

Misc Notes & Examples from Unix for OS-X and elsewhere

^stri1^str2 at new command line edits previous command & enters it ps -auxc get process status for all processes (a), extended info (u), without path (c), include those without controling terminal (x) ps -ax | grep -e "" -e "PID" get ps lines for Microsoft with header n closes process with PID n kill -STOP n pauses process with PID n kill -CONT n continues process with PID n open

causes Finder to open the designated Folder open -a Microsoft\ Excel -a specifies the application to use launches Microsoft Excel if file given, it is opened by it open -e opens with Text Edit

Unix Notes for Tutorialv4.doc Page 10 JFW open *.doc opens all *.doc with the default application (Microsoft Word) cat … > concatenates files history lists history of commands !n enters the n'th command ! enters the command with the following characters--danger it's thewrong one !:p ????

Filenames with spaces need to be quoted. Apple missed a couple of quotes in iTunes once which opened up the possibility of a users getting all of his disk erased. ls * ls *.txt ls ? ls *.? ls [A-Z]*.txt ls -s report size in bytes ls -k report size in k ls -A almost all, . and .. files are excluded ls -R recursive ls -r reverse order find . -type d -and -name '*Doc*' find in current dir down directories (d) and (-and) with name containing Doc find . -type d -and -name 'Documents' find directories with exact name Documents sort -o filel filel2… sorts lines in combined files output option to (o); -n is numeric sort; -r is reverse order -c counts duplicates and removes all but 1 uniq removes duplicates sort … | uniq -c | sort -rn sorts lines if combined files, counts and removes dups, sorts in reverse numeric order ls -lo long listing with file flags included, e.g. the imutable flag; these flags are changed with the command chflags chflags uchg set the user immutable flag for file chflags nouchg turn the user immutable flag off currently defined flags are: arch set the archived flag (super-user only) opaque set the opaque flag (owner or super-user only) nodump set the nodump flag (owner or super-user only) sappnd set the system append-only flag (super-user only) schg set the system immutable flag (super-user only) uappnd set the user append-only flag (owner or super-user only) uchg set the user immutable flag (owner or super-user only)

Unix Notes for Tutorialv4.doc Page 11 JFW now shutdown computer now shutdown n shutdown in n minutes shutdown < yymmddhhmm> shutdown at yymmddhhmm, several options available reboot flushes the disk cache and reboots, several options available; also a halt command date >> dates.dat ps -u get processes for ps -auxw get processes for all users (-a) (-u) more info, (-x) all processes, (-w) wide output top continuous display of process status; enter q to quit top -l3 | toplog save three samples to file toplog ls -l /bin |cut -c38- > output cut first 38 columns from a long listing and write to file, output $ execute command in background; when done give report; but if it asks for input it will wait forever unless you bring it to the foreground and enter the desired input. jobs displays jobs running fg %n brings job number n to the foreground ctrl-z suspends current job and sends it to background kill %n kills job #n kill kills all jobs kill -9 send kill signal that can not be ignored bg %n restarts suspended job in background and leaves it in background

*****Sample terminal session showing use of background jobs (bold is user input) [localhost:~] weiher% top& [1] 1163 [localhost:~] weiher% fg %1 top

Processes: 38 total, 3 running, 35 sleeping... 127 threads 22:05:00 Load Avg: 0.42, 0.31, 0.17 CPU usage: 13.0% user, 12.2% , 74.8% idle SharedLibs: num = 102, resident = 23.6M code, 1.60M data, 6.39M LinkEdit MemRegions: num = 4522, resident = 141M + 8.04M private, 113M shared PhysMem: 74.1M wired, 76.8M active, 256M inactive, 407M used, 233M free VM: 2.36G + 45.9M 11707(0) pageins, 0(0) pageouts

PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE 1163 top 7.7% 0:02.24 1 19 15 248K 320K 504K 1.65M 1025 Microsoft 0.0% 0:02.97 2 74 93 1.83M 10.9M 3.11M 57.6M 989 Sherlock 0.0% 0:14.39 3 88 119 2.98M 9.15M 6.96M 57.6M …

Unix Notes for Tutorialv4.doc Page 12 JFW 2 mach_init 0.0% 0:05.85 1 123 12 56K 312K 144K 1.27M 1 0.0% 0:00.02 1 20 12 48K 300K 248K 1.26M ^Z [1] + 1163 Suspended top [localhost:~] weiher% bg %1 [1] top & [localhost:~] weiher% jobs [1] Running top [localhost:~] weiher% kill %1 [localhost:~] weiher% jobs [1] Terminated top [localhost:~] weiher% jobs [localhost:~] weiher% ***** bin directories contain the binary commands $path contains the search path /Users/weiher/bin/powerpc-apple-darwin ?? /Users/weiher/bin your personal commands /usr/local/bin your commands as admin /usr/bin other command delivered with OS-X /bin the minimum set of essentail commands /usr/local/sbin your system commands as admin /usr/sbin other system commands delivered with OS-X /sbin minimum set of essential system commands

Some History: 1969 's 4 yrs & dropped 1973 Unix & Thompson? (pun on Multics) first portable OS based on C 1977 Berkley Software Distribution version 1 DARPA Defence Advanced Research Program Agency 1983 ARPAnet -> TCP/IP 1983 BSD 4.2 Bill Joy 1983 AT&T System V 1983± HP HP/UX 1985 Jobs Next 1991 Linus Torvalds version 0.02 of 1992 Boll Jolitz 386/BSD no original AT&T code 1992 Sun Microsystems Solaris 1994 v1 Linux 1994 BSD -4.4 Lite 1999 Newton released

Grep example: [localhost:~] weiher% grep -ilr "gute Miene zum b.sen Spiel machen" /Users/weiher/0104121623

Unix Notes for Tutorialv4.doc Page 13 JFW [localhost:~] weiher% another grep example: [localhost:~] weiher% grep -E 'a?b' xyb xyb ab ab aaaa b b aaaaab aaaaab caaaab caaaab [localhost:~] weiher% grep -E 'ca?b' xyb xycb xycb xycabkk xycabkk ytcaabkk [localhost:~] weiher%

[localhost:~] weiher% egrep 'ca\?t' cat ct caaat c?t ca?t ca?t [localhost:~] weiher% grep 'ca\?t' cat cat ct ct caaat

[localhost:~] weiher% grep 'a?b' b ab a?b a?b a\?b [localhost:~] weiher% grep

Unix Notes for Tutorialv4.doc Page 14 JFW