Home
${Unix_Tools} - The Computer Laboratory
Contents
1. days the value of the scalar variable days days 28 element 29 of the array days days Feb the Feb value from the hash table days days last index of array days days days 0 days days days 3 4 5 edays 3 5 days a c days a days c days keyl vall key2 val2 82 perl scalar values Y A scalar variable can hold a string number or reference Scalar variables can also hold the special undef value set with undef and tested with defined Strings can consist of bytes or characters Unicode UTF 8 More on Unicode character strings man perluniintro Numeric decimal and string values are automatically converted into each other as needed by operators 5 3 2 a 0 In a Boolean context the values 0 0 or undef are interpreted as false everything else as true Boolean operators return O or 1 References are typed pointers with reference counting 83 perl scalar literals v Numeric constants follow the C format 123 decimal 0173 octal Ox7b hex 3 14e9 float Underscores can be added for legibility 4 294 967 295 String constants enclosed with will substitute variable references and other meta characters In only and NN are substituted header From name i host n Subject subject msgid n print Metacharacters include Strings can contain line fe
2. pstex t file pair The pstex file lacks the text parts of the figure The pstex t file contains ATEX commands that first load the pstex image and then add all the text in the figure Select the special text mode in xfig to enable ATEX metacharacters Use include pstex_t to add such a figure in your document PDF equivalent pdftex pdftex t K Command line export tool e g for Makefile fig2dev eps fig fig2dev L eps 0 4 pstex pstex_t fig fig2dev L pstex t p pstex lt pstex t fig2dev L pstex pstex 4 pdftex pdftex t fig fig2dev L pdftex t p pdftex pdftex t fig2dev L pdftex pdftex Other graphics tools TikZ pnmtops Inkscape MATLAB R gnuplot Python matplotlib 127 Conclusions gt Unix is a powerful and highly productive platform for experienced users This short course could only give you a quick overview to get you started with exploring advanced Unix facilities Please try out all the tools mentioned here and consult the man and info online documentation gt You ll find on http www cl cam ac uk teaching current UnixTools easy to print versions of the bash make and perl documentation links to further resources and hints for installing Linux on your PC Good luck and lots of fun with your projects x 128
3. T For more information man perlre 94 perl predefined variables The default variable for many operations e g print print _ tr a z A Z _ tr a z A Z while lt FILE gt while _ lt FILE gt Line number of the line most recently read from any file Child process return value from the most recently closed pipe or operator Error message for the most recent system call equivalent to C s strerror errno Example open FILE test dat die Can t read test dat n For many more man perlvar 95 perl file input output gt open filehandle expr open Fi test dat open file test dat for reading open F2 gt test dat create file test dat for writing open F3 gt gt test dat append to file test dat open F4 date invoke date and connect to its stdout open F5 mail s test invoke mail and connect to its stdin gt print fzlehandle list gt close eof getc seek read format write truncate gt X filehandle reads another line from file handle FILE and returns the string Used without assignment in a while loop the line read will be assigned to _ K opens one file after another listed on the command line or stdin if none given and reads out one line each time 96 perl invocation Y wv Y Vy Yy First line of a Perl script 4t usr bin perl as with shell Option e reads code from command
4. prefix it with 0 or amp according to the resulting type Use 1 L around the reference to clarify operator precedence a is short for a Hash table and list references used in a lookup can also be dereferenced with gt therefore a gt john is short for a john and b gt 5 is short for b 5 References to anonymous arrays can be created with K References to anonymous hash tables can be created with 1 For more information man perlref 91 perl examples of standard functions split pattern ezpr Splits string into array of strings separated by pattern join expr list Joins the strings in List into a single string separated by value of expr reverse list Reverse the order of elements in a list Can also be used to invert hash tables substr expr offset len Extract substring mgk25 x 1597 1597 Markus Kuhn homes mgk25 usr bin bash user split line logname pw uid gid name home shell Quser line join reverse user 92 perl more standard functions chop chomp lc uc lcfirst ucfirst Remove trailing character linefeed Change entire string or first character from string to lowercase uppercase pack unpack chr ord build parse binary records ASCII integer conversion sprintf hex oct format strings and numbers shift unshift push pop string number conversion add remove first last array el
5. userresources Xdefaults usermodmap Xmodmap if f userresources then xrdb userresources fi if f usermodmap then xmodmap usermodmap fi start some X clients as background processes xterm geometry 80x10 10 5 C title hostname s console bg lightgreen amp xclock geometry 80x80 0 0 update 1 amp xload geometry 80x80 90 0 nolabel amp start window manager as foreground process if x usr bin X11 fvwm2 then usr bin X11 fvwm2 else twm fi 45 sed a stream editor Designed to modify files in one pass and particularly suited for doing automated on the fly edits of text in pipes sed scripts can be provided on the command line sed e command files or in a separate file sed f scriptfile files General form of a sed command address address command arguments Addresses can be line numbers or regular expressions Last line is One address selects a line two addresses a line range specifying start and end line All commands are applied in sequence to each line After this the line is printed unless option n is used in which case only the p command will print a line The negates address match 1 can group commands per address 46 sed regular expressions Regular expressions enclosed in Some regular expression meta characters Y Y wv Y NN tt 11 UP Ug Hen lial ug E use in character list matches any c
6. The third case passes _ on as parameters gt Parameters are passed as a flat list of scalars in the array _ gt Perl subroutines are call by reference that is _ 0 are aliases for the actual parameters Assignments to _ elements will raise errors unless the corresponding parameters are lvalues gt Subroutines return the value of the last expression evaluated or the argument of a return statement It will be evaluated in the scalar list context in which the subroutine was called gt Use my a b to declare local variables a and b within a block For more information man perlsub 89 perl operators gt Normal C Java operators SU K lt K gt gt 1 amp amp amp Exponentiation Numeric comparison lt gt lt gt lt gt String comparison eq ne cmp 1t gt le ge String concatenation a a a eq a x 8 Y wv V Y Y Apply regular expression operation to variable line s sed perl g executes a shell command returns list with a number range in a list context and works as a flip flop in a scalar context for sed style line ranges For more information man perlop 90 perl references Scalar variables can carry references to other scalar list hash table or subroutine values K To create a reference to another variable subroutine or value prefix it with Much like amp in C gt To dereference such a reference
7. amp testrun2 amp testrun3 amp 3 5106 4 5107 5 5108 Shell prints both a job number identifying all processes in pipe as well as process ID of last process in pipe Shell will list all its jobs with the jobs command where a sign marks the last stopped default job 27 Job control cont d Foreground job Stdin connected to terminal shell prompt delayed until process exits keyboard signals delivered to this single Job Background job Stdin disconnected read attempt will suspend job next shell prompt appears immediately keyboard signals not delivered shell prints notification when job terminates Keyboard signals keys can be changed with stty tool gt Ctrl C intr SIGINT 2 by default aborts process gt Ctrl N quit SIGQUIT 3 aborts process with core dump gt Ctrl Z susp SIGSTOP 19 suspends process Another important signal not available via keyboard gt SIGKILL 9 destroys process immediately 28 Job control cont d Job control commands fg resumes suspended job in foreground K bg resumes suspended job in background gt kill sends signal to job or process Job control commands accept as arguments process ID gt job number gt 7 command name Examples ghostview press Ctrl Z 6 Stopped ghostview bg kill 7 6 29 Job control cont d A few more job control hints gt kill 9 sends SIGKILL to process Should only be used as a last r
8. and macros read for each argument either a single character or a block enclosed by and Typeset textsl M in textsl slanted style 4 Typeset M in slanted style Values of optional ATEX macro arguments are enclosed by 106 Typewriting versus Typesetting The ASCII ISO 646 7 bit character set with its 94 graphic characters 4 4 amp 0123456789 lt gt ABCDEFGHI JKLMNOPQRSTUVWXYZ _ abcdefghijklmnopqrstuvwxyzil was designed to cover the character repertoire of US typewriters and teletype printers Some new symbols such as 13 were added in the hope that they will be useful for programming TEX defines a number of shortcuts and macros to access the full range of typographic characters used in high quality book printing These still cannot be found on the standard PC keyboard which was designed for T bit ASCII Dashes ASCII provides only a single combined hyphen minus character but typesetters distinguish carefully between several dash characters gt hyphen gt en dash em dash minus The hyphen is the shortest of these and is used to combine separate words or split words across line breaks The en dash is often used to denote a range of numbers as in pages 64 128 or as in this example as a punctuation dash The em dash is used like this as a punctuation dash often without surrounding space especially in US ty
9. be done off line Creating and merging branches are quick and easy operations Branches do not have to be made visible to other developers Revisions identified by secure hash value rather than integer Distributed version control systems are far more flexible and powerful than centralized ones like Subversion but require more experience 69 git Repository and working directories Gace Imit git clone git repository URL git or http git pull git es repository git push git wort Ta commit git wort Ta commit Working directory Working directory of user 2 of user 1 Each working directory contains an associated repository in a git subdirectory of its top level directory 70 git Y wv wv Y most basic commands git init Create a new repository inside a working directory Option bare creates a stand alone repository for others to push into git clone Copy an existing repository and create an associated working directory around it unless bare is used A cloned repository will remember the URL of the origin repository where it came from git pull Fetch updates from another repository default origin and merge them into local working directory git add Add a new modified file to the next commit git commit Save a revision to the local repository git push Forward local revisions to another repository git branch g
10. different mode from that used for normal text Inline formulas such as an a n that appear as part of a normal paragraph have to be surrounded with while displayed formulas such as Py Fn 1 Fn 2 F_n F_ n 1 F_ n 2 are entered in between In math mode gt space characters are ignored TEX adds its own space around operators based on heuristics manually add thinspace with gt a special math italic font with different inter character spacing is used to show single letter variables better in products gt many additional macros for special symbols are defined Math italic is very dif ferent and not suitable for writing words Use mathrm around words as in v_ mathrm diff vui Macros for neatly aligning multiple equations usepackage amsmath see texdoc amsldoc Mathematical symbols Greek letters 115 NGamma delta T Np A Delta epsilon w Nvarpi O Theta varepsilon p Nrho A NLambda C Meta Q varrho W n Meta OC Nsigma l Pi 0 theta varsigma gt Sigma vartheta T Ntau T Upsilon L Mota U upsilon Phi k Kappa phi V Psi A lambda y Nvarphi Q NOmega u m X chi a alpha U Nu w psi DB Nbeta E xi w omega Ngamma o o 116 Mathematical symbols Binary operators 4 e o o X pm mp setminus cdot times ast star diamond circ bullet div triangleleft tria
11. email addresses of everyone on the Computer Lab s People web page sorted by surname Example input lt tr gt lt td gt lt a NAME 2 asa28 asa28 a td td FEO4 td td 63622 td td td td gt lt td gt lt td gt lt a HREF users asa28 gt Abrahams Alan lt a gt lt td gt lt tr gt lt tr gt lt td gt lt a NAME mha23 gt mha23 lt a gt lt td gt lt td gt FE22 lt td gt lt td gt 63692 lt td gt lt td gt lt td gt lt td gt lt td gt lt td gt lt a HREF users mha23 gt Allen Williams Mair lt a gt lt td gt lt tr gt lt tr gt lt td gt lt a NAME sa333 gt sa333 lt a gt lt td gt lt td gt GC33 lt td gt lt td gt 63680 lt td gt lt td gt lt td gt lt td gt lt td gt lt td gt Allott Stephen lt td gt lt tr gt Example output Alan Abrahams lt asa28 cl cam ac uk gt Mair Allen Williams lt mha23 cl cam ac uk gt Stephen Allott lt sa333 cl cam ac uk gt 99 perl a simple example Possible solution usr bin perl url http www cl cam ac uk UoCCL people directory html open HTML wget 0 url die Can t start wget n while lt HTML gt 1 if tr td a name wt gt lt tr gt i crsid 1 if lt td gt lt a href 2 2 3O 7 lt gt Va lt td gt lt tr gt i email crsid 3 2 lt crsid cl cam ac uk gt surname crsid 2 else die Syntax error n _ T F foreach
12. end figure The automatically assigned figure number can be quoted as in See also Figure ref fig expsetup page pageref fig expsetup The label command can also be used after section subsection etc and inside begin equation end equation to assign symbolic names to section and equation numbers which can then be resolved via ref or pageref No need to manually renumber figures sections or equations 125 Build tools for TEX To make sure label references and tables of contents use the correct numbers it may be necessary to call latex twice It will output Rerun to get cross references right in this case The following implicit Makefile rule takes care of this DELETE ON ERROR A pdf aux idx tex pdflatex lt while grep Rerun to get log do pdflatex lt done An alternative is the latexmk tool which automatically determines dependencies e g from includegraphics and recompiles ATEX documents where file modification timestamps indicate that this is necessary 126 Graphics editor xfig gt Its fig files have a simple plain text format that can be edited manually script generated and leads to useful diffs gt Can export eps or pdf files Can also produce figures in which TEX is used to fill in all the text This provides math mode macros symbols references fonts that match the main text etc Ask xfig to export a pstex
13. files recursively option 1 limits recursion depth gt ssh user hostname command Log in via compressed and encrypted link to remote machine If command is provided execute it in remote shell otherwise go interactive Preserves stdout stderr distinction Can also forward X11 requests option X or arbitrary TCP IP ports options L and R over secure link gt ssh keygen t dsa Generate DSA public private key pair for password free ssh authentication in ssh id dsa pub and ssh id dsa Protect id dsa like a password Remote machine will not ask for password with ssh if your private key 7 ssh id dsa fits one of the public keys locks listed on the remote machine in ssh authorized keys On MCS Linux your Novell server home directory with ssh authorized keys is mounted only after login and therefore no password free login for first session 52 rsync rsync options source destination An improved cp gt The source and or destination file directory names can be prefixed with user 9 hostname if they are on a remote host K Uses ssh as a secure transport channel may require e ssh gt Options to copy recursively entire subtrees r preserve symbolic links 71 permission bits 7p and timestamps t Will not transfer files or parts of files that are already present at the destination An efficient algorithm determines which bytes actually need to be tr
14. iUnix Tools Markus Kuhn Computer Laboratory University of Cambridge http www cl cam ac uk teaching 1314 UnixTools Michaelmas 2013 Part IB Why do we teach Unix Tools gt Second most popular OS family after Microsoft Windows gt Many elements of Unix have became part of common computer science folklore terminology amp tradition over the past 25 years and influenced many other systems including DOS Windows Many Unix tools have been ported and become popular on other platforms full Unix environment in Apple s OS X Cygwin Your future project supervisors and employers are likely to expect you to be fluent under Unix as a development environment gt Good examples for high functionality user interfaces This short lecture course can only give you a first overview You need to spend at least 2 3 times as many hours with e g MCS Linux to explore the tools mentioned K solve exercises which often involve reading documentation to understand important details skipped in the lecture Brief review of Unix history First Edition developed at AT amp T Bell Labs during 1968 71 by Ken Thompson and Dennis Ritchie for a PDP 11 Rewritten in C in 1973 Sixth Edition 1975 first widely available version Seventh Edition in 1979 UNIX 32V for VAX During 1980s independent continued development at AT amp T System V Unix and Berkeley University BSD Unix Commercial variants Solaris SCO HP UX AIX I
15. locate command file The Unix shell clear reset clear screen reset terminal stty configure terminal driver xv display ghostview acroread graphics file viewers xfig tgif gimp inkscape graphics drawing tools topnm pnmto cd jpeg graphics format converters be calculator passwd change your password chmod change file permissions lex yacc flex bison scanner parser generators 11 gt The user program that Unix starts automatically after a login gt Allows the user to interactively start stop suspend and resume other programs and control the access of programs to the terminal gt Supports automation by executing files of commands shell scripts provides programming language constructs variables string expressions conditional branches loops concurrency gt Simplifies file selection via keyboard regular expressions file name completion gt Simplifies entry of command arguments with editing and history functions gt Most common shell sh developed 1975 by Stephen Bourne modern GNU replacement is bash Bourne Again SHell 12 Unix inter process communication mechanisms invocation return value command line arguments sockets environment variables current directory shared memory files and pipes semaphores standard input output error signals messages m resource limits umask priority execution time not supported by shell supported by shel
16. of the current block i e the next or end L Packages A huge collection of extension packages exists for ATEX Some merely define additional macros and environments others rewrite parts of ATEX s internal machinery For example adding to the preamble usepackagefhyperref loads all the macros and settings defined in the hyperref sty package hyperref adds new marcros such as url for typesetting URLs but also automatically turns every reference to a page section or bibliographic entry into a hyperlink Documentation texdoc packagename e g texdoc geometry 113 Example changing page layout geometry Adjust margins manually via numerous length variables setlength oddsidemargin 0 4mm 25 mm left margin setlength evensidemargin oddsidemargin setlength textwidth 160mm 25 mm right margin setlength topmargin 5 4mm 20 mm top margin setlength headheight 5mm setlength headsep 5mm setlength footskip 10mm setlength textheight 237mm 20 mm bottom margin More comfortable Nusepackage vmargin 20mm hmargin 25mm geometry The geometry sty package automatically recalculates any dimensions not specified Make paragraphs not indented at the first line but spaced apart slightly setlength parindent Omm setlength parskip medskipamount Or just usepackage parskip 114 Mathematical typesetting In TEX mathematical formulas are formatted in a completely
17. s sort surname a cmp surname b keys email print email s n J Warning This simple minded solution makes numerous assumptions about how the web page is formatted which may or may not be valid Can you name examples of what could go wrong 100 perl email header parsing example Email headers as defined in RFC 822 have the form header EOT From Ian Grant cl cam ac uk 21 Sep 2004 10 10 18 0100 Received from ppsw 8 csi cam ac uk 131 111 8 138 by mtai cl cam ac uk with esmtp Exim 3 092 1 id 1V9afA 0004E1 00 for Markus Kuhn cl cam ac uk Tue 21 Sep 2004 10 10 16 0100 Date Tue 21 Sep 2004 10 10 05 0100 To Markus Kuhn cl cam ac uk Subject Re Unix tools notes Message ID lt 514FGFED mailVJ3982Y cl cam ac uk gt EOT This can be converted into a Perl hash table as easily as header s n st g fix continuation lines hdr FROM gt split S s m header and accessed as in if hdr Subject Unix tools ITEX a document formatter 101 IATEX is a sophisticated macro package for the TEX text formatting system Thanks to its excellent facilities for mathematical typesetting it has become the de facto standard for preparing scientific publi mathematical physical computing and engineering disciplines Classic processing steps Modern alt gl eps g2 eps g1 pdf latex dvips ps2pdf pdflat f tex gt f dvi f ps gt f pdf f tex cation
18. set user id and set group id elevated execution rights Y wv Vy Yy sticky bit only owner can delete file from directory gt chmod ugoa rwxst files Examples Make file unreadable for anyone but the user owner 1s 1 message txt rw r r 1 mgk25 private 1527 Oct 8 01 05 message txt chmod go rwx message txt 1s 1 message txt r 1 mgk25 private 1527 Oct 8 01 05 message txt For directories execution right means right to traverse Directories can be made traversable without being readable such that only those who know the filenames inside can access them 50 find traverse directory trees find directories expression recursively traverse the file trees rooted at the listed directories Evaluate the Boolean expression for each file found Examples Print relative pathname of each file below current directory find print Erase each file named core below home directory if it was not modified in the last 10 days find name core mtime 10 exec rm i V The test mtime 10 is true for files older than 10 days concatenation of tests means logical and so exec will only be executed if all earlier terms were true The is substituted with the current filename and N terminates the list of arguments of the shell command provided to exec 51 Some networking tools gt wget url Fetch a file over the Internet via HTTP or FTP Option r fetches HTML
19. wide configuration file with information about your character set and language country conventions e g en GB UTF 8 LC_ sets locale only for one category e g LC_CTYPE for character set and LC_COLLATE for sorting order LANG sets default for everything locale a lists all available locales K TZ Specification of your timezone mainly for remote users IT 11 gt O0LDPWD Previous working directory also available as 32 Standard environment variables cont d PS1 The normal command prompt e g PS1 033 7m NuQNh NW NINSN NOS3 m PRINTER The default printer for lpr lpq and lprm TERM The terminal type usually xterm or vt100 PAGER EDITOR The default pager editor usually less and emacs respectively DISPLAY The X server that X clients shall use v v v v man 7 environ 33 Executable files and scripts Many files signal their format in the first few magic bytes of the file content e g Ox7f E L F signals the System V Executable and Linkable Format which is also used by Linux and Solaris The file tool identifies hundreds of file formats and some parameters based on a database of these magic bytes file which 1s bin ls ELF 32 bit LSB executable Intel 80386 The kernel recognizes files starting with the magic bytes 4t as scripts that are intended for processing by the interpreter named in the rest of the line e
20. working directories svn checkout Team members repeatedly fetch latest version svn update and return their changes svn commit 60 svn Subversion vs CVS Subversion was specifically written to replace an older system CVS which in turn started out as a layer on top of RCS for managing entire directory trees Its command line interface closely follows that of CVS but improves and simplifies the latter in many ways In particular Subversion understands renaming moving copying and replacing of both files and entire directory trees no per file version numbers understands symbolic links performs atomic commits versioned metadata MIME types EOL semantics etc is easy to learn and understand for current CVS users simpler branching and tagging through efficient copying more efficient transactions more disconnected operations Y WV NW V Y NN wider choice of remote access protocols WebDAV ssh etc Old CVS repositories can easily be converted http cvs2svn tigris org 61 svn setting up Create new repository e g SVN separate from working directory svnadmin create SVN Then checkout a working copy of the repository into a new working directory wdir referring to the repository via its URL svn checkout file HOME SVN wdir Note that every subdirectory in your new working directory has a svn subdirectory This contains among other things the URL of your repository see svn info
21. 2 svn resolved filei Resolved conflicted state of file1 ex2 svn status M filet ex2 svn commit m k9 extension Sending file1 Transmitting file data Committed revision 4 67 The URL to an svn repository can point to a local file file gt Subversion WebDAV Apache server http or https gt Subversion server svn gt Subversion server accessed via ssh tunnel svn ssh The command svn list svntssh mgk25 linux2 home mgk25 SVN proj1 will ssh as user mgk25 into host linux2 and will start a server there with svnserve t If you give others full shell access to your account to start svnserve t they could abuse this Fortunately ssh allows you to give others access to only a single program running under your user identity You can add their public key to your ssh authorized keys file with the option command and other suitable restrictions see man sshd and the svn book for details command svnserve t tunnel user john r home mgk25 SVN no port forwarding no agent forwarding no X11 forwarding no pty ssh dss AAAB3 ogUc john bla com 68 Distributed revision control systems Popular examples git mercurial bazaar No single central repository more reliable and democratic Each participant holds a local repository of the revision history Committing and uploading a commit to another site are separate actions i e commits branches etc can
22. Emacs search function Ctrl S and finally Q uit Check usr share doc and Web for further documentation Examples of Unix tools man apropos xman info help documentation browser more less plaintext file viewer ls find list traverse directories search cp mv rm touch ln copy move rename remove renew files link shortcut files mkdir rmdir make remove directories cat dd head tail concatenate split files du df quota rquota examine disk space used and free ps top free uptime w process table and system load vi emacs pico interactive editors cc gcc C compilers make project builder cmp diff patch compare files apply patches rcs cvs svn git he bzr revision control systems adb gdb debuggers awk perl python tcl scripting languages m4 cpp macro processors sed tr edit streams replace characters sort grep cut sort search lines of text extract columns nroff troff tex latex text formatters mail pine mh exmh elm electronic mail user agents 10 Examples of Unix tools cont d telnet ftp rlogin finger talk ping traceroute wget curl ssh scp rsync hostname host ifconfig route network tools xterm VT100 terminal emulator tar cpio compress zip gzip bzip2 file packaging and compression echo cd pushd popd exit ulimit time history builtin shell commands fg bg jobs kill builtin shell job control date xclock clocks which whereis
23. RIX gt IEEE and ISO standardisation of a Portable Operating System Interface based on Unix POSIX in 1989 later also Single Unix Specification by X Open both merged in 2001 The POSIX standard is freely available online http www unix org and http pubs opengroup org onlinepubs 9699919799 Y wv wv Y Y A brief history of free Unix gt In 1983 Richard Stallman MIT initiates a free reimplementation of Unix called GNU GNU s Not Unix leading to an editor emacs compiler gcc debugger gdb and numerous other tools gt In 1991 Linus Torvalds Helsinki CS undergraduate starts development of a free POSIX compatible kernel later nicknamed Linux which was rapidly complemented by existing GNU tools and contributions from volunteers and industry to form a full Unix replacement gt In 1991 Berkeley University releases a free version of BSD Unix after removing remaining proprietary AT amp T code Volunteer projects emerge to continue its development FreeBSD NetBSD OpenBSD gt In 2000 Apple releases Darwin the now open source core components of their OS X and iOS operating systems Volunteer projects emerge to port many Unix tools onto Darwin Homebrew Fink MacPorts GNU Darwin etc Free software license concepts public domain authors waive all copyright MIT BSD licences allow you to copy redistribute and modify the software in any way as long as e you respect the identity and rig
24. Therefore inside the working directory it is no longer necessary to add that repository URL as an argument to svn operations Now populate the repository with content Create or move into the working directory some files K Register them with Subversion svn add gt Push them into the repository svn commit Then every team member after their own initial svn checkout does gt Pull the latest version svn update Make edits K Push them back to the repository svn commit 62 svn directory edits gt svn add filenames Put new files folders under version control Warning adding a directory adds all content as well unless you use svn add N dirnames gt svn delete filenames Delete files folders gt svn copy source destination Copy files folders gt svn move source destination Move files folders The above four operations will not transfer the requested changes to the repository before the next commit however the delete copy move operations perform the requested action immediately on your working files Remember not to use rm cp mv on working files that are under Subversion control otherwise these operations will not be reflected in the repository after your next commit If you delete a version controlled file with rm the next svn update will restore It 63 svn querying the working directory status gt svn status List all files that differ between your working directory and the rep
25. ace character and line feed multiple spaces are treated like a single space multiple line feeds empty lines are treated as a paragraph separator just like the par command command macro and variable names start with a backslash followed by either a sequence of letters or a single non letter character uppercase lowercase is significant Correct Npar item pagethree NLaTeX NN 3 Wrong page33 lt gt space and line feed characters are ignored if they follow a command macro variable name consisting of letters Use Yu to add an explicit space e g TeX syntax TEX syntax 104 Characters with special semantics In tex input files the characters ha N have special functions Some of these can be included in regular text by writing MENS Vh ME N N ML NE ATEX supports typesetting all ASCII characters via the verb and url macros starts a comment All characters between and including a and the next line feed will be ignored Append at the end of a line to avoid interpretation of the subsequent line feed as a space plus a digit denotes a parameter in macros is a no break space delimits inline equations amp is used as a tabulator mark is a line separator indicates a superscript and _ a subscript in math mode 105 Blocks State changes inside a block last only until the next This is a bf bold statement u This is a bold statement Commands
26. ansmitted only very useful to keep huge file trees synchronised over slow links Application example Very careful backup rsync e ssh v rlpt delete backup backup dir OLD date Im me myhost org mycopy Removes files at the destination that are no longer at the source but keeps a timestamped copy of each changed or removed file in mycopy OLD yyyy mm dd so nothing gets ever lost 53 tar converting file trees into byte streams and back Originally tape archiver Create archive recurses into subdirectories tar cvf archive tar files Show archive content tar tvf archive tar Extract archive tar xvf archive tar files 54 gzip amp friends compressing byte streams v gzip file convert file into a compressed fle gz using a Lempel Ziv Huffman algorithm gunzip file decompress gz files un compress file de compress Z files older tool using less efficient and patented LZW algorithm b un zip2 file de compress bz2 files newer tool using Burrows Wheeler blocktransform zcat file decompress Z gz to stdout for use in pipes Extract compressed tar archive zcat archive tar gz tar xvf tar xvzf archive tgz GNU tar only 55 diff patch managing file differences diff oldfile newfile Show difference between two text files as lines that have to be inserted deleted to change oldfile into neufi
27. ary to add rules with phony targets for routine tasks that will never produce the target file and just execute the commands clean rm f bak o TARGETS core Common phony targets are clean test install 80 perl the Swiss Army Unix Tool v a portable interpreted language with comprehensive library combines some of the features of C sed awk and the shell the expression and compound statement syntax follows closely C as do many standard library functions powerful regular expression and binary data conversion facilities make it well suited for parsing and converting file formats extracting data and formatting human readable output offers arbitrary size strings arrays and hash tables garbage collecting memory management dense and compact syntax leads to many potential pitfalls and has given Perl the reputation of a write only hacker language widely believed to be less suited for beginners numerical computation and large scale software engineering but highly popular for small to medium sized scripts and Web CGI 81 perl data types Perl has three variable types each with its own name space The first character of each variable reference indicates the type accessed Les a scalar an array of scalars 4 an associative array of scalars hash table selects an array element queries a hash table entry Examples of variable references
28. command gt gt filename Send both stdout and stderr to the same file First redirect stdout to filename then redirect stderr file descriptor 2 to where stdout goes target of file descriptor 1 amp 1 command gt filename 2 gt amp 1 Feed stdin from file command filename File redirecting advanced Open other file descriptors for input output or both command O lt in 1 gt out 2 gt gt log 3 lt auxin 4 gt auxout 5 lt gt data Here Documents allow us to insert data into shell scripts directly such that the shell will feed it into a command via standard input The lt lt is followed immediately by an end of text marker string tr lt lt THEEND A MN Za mn z N ZA Mn za m gt Vs lbh zhfg cbfg n ehqr wbxr ba HFRARG ebgngr gur gt nycunorg ol 13 punenpgref naq nqq n jneavat THEEND Redirecting to or from dev tcp hostname port will open a TCP socket connection echo GET mgk25 iso paper c gt amp 3 cat amp 3 3 lt gt dev tcp www cl cam ac uk 80 The above example is a bash implementation of a simple web browser It downloads and displays the file http www cl cam ac uk mgk25 iso paper c Bash s dev tcp feature is disabled in some Linux distributions security concerns Command line argument conventions Each program receives from the caller as a parameter an array of strings argv The shell places into the argv parameters the words entered following the command name afte
29. e expansion gt parameter expansion gt pathname expansion filename matching p quote removal NV 22 Brace and tilde expansion Brace expansion Provides for convenient entry of words with repeated substrings echo a b c d e abe ace ade echo mgk25 fapp2 rjal4 cam ac uk mgk250cam ac uk fapp2 cam ac uk rjal4 cam ac uk rm slides bak aux dvi log ps This bash extension is not required by the POSIX standard e g Ubuntu Linux bin sh lacks it Tilde expansion Provides convenient entry of home directory pathname echo pb Mail inbox home pb homes mgk25 Mail inbox The builtin echo command simply outputs argv to stdout and is useful for demonstrating command line expansion and for single line text output in scripts 23 Parameter and command expansion Substituted with the values of shell variables OBJFILE skipjack o echo OBJFILE OBJFILE o c skipjack o skipjack c echo HOME PATH LOGNAME homes mgk25 bin usr bin usr local bin usr X11R6 bin mgk25 or the standard output lines of commands which emacs usr bin emacs echo which emacs usr bin emacs 1s 1 which emacs rwxr xr x 2 root system 3471896 Mar 16 2001 usr bin emacs Shorter alternatives variables without braces and command substitution with grave accent or with older fonts back quote echo 0BJFILE Skipjack o echo which emacs usr bin emacs 24 Pathname e
30. e files as an alternative to manually making backup copies of such files RCS is no longer commonly used for joint software development If you work in a distributed team on a project with subdirectories need remote access want to rename files easily or simply hate locks use svn or git instead 58 svn Subversion Subversion is a popular centralized version control system 2001 Main advantages over RCS K Supports a copy modify merge workflow RCS lock modify unlock This allows team members to edit the same files concurrently e Concurrent edits in different lines gt merged automatically e Concurrent edits in the same lines gt requires manual resolution of conflicts Manages entire directory trees not just single files Understand tree edits file copy delete rename move K Supports several remote access protocols WebDAV ssh etc Full documentation http svnbook red bean com and http subversion apache org Microsoft Windows Subversion GUI http tortoisesvn tigris org 59 svn repository and working directories svnadmin create Subversion repository URL file homes mgk25 SVN svn update NG commit svn commit svn update Working directory di sene Ts sns Working directory of user 3 Working directory svn checkout of user 2 of user 1 svn checkout svn checkout Team administrator first creates repository svnadmin create Team members create personal
31. eds multiple source code lines gt Multiline strings can also be entered with here docs header EOT From name i host Subject subject msgid EOT 84 perl arrays Y wv wv Y Arrays start at index 0 Index of last element of foo is foo length minus 1 Array variables evaluate in a scalar context to array length i e scalar foo foo 1 List values are constructed by joining scalar values with comma operator parenthesis often needed due to precedence rules Ofoo 3 1 h last Lists in lists lose their list identity 1 2 3 equals 1 2 3 Use to generate reference to list e g for nested lists Null list List assignments a undef b c 1 2 3 4 5 equals a 1 b 3 O c 4 5 Command line arguments are available in ARGV 85 perl hash tables Y wv yV yY Literal of a hash table is a list of key value pairs hage adam 19 bob 22 charlie 7 Using lt gt instead of comma between key and value increases readability wage adam gt 19 bob gt 22 charlie gt 7 Access to hash table age age john age adam 6 Remove entry delete age charlie Get list of all keys family keys age Use to generate reference to hash table Environment variables are available in ZENV For more information man perldata 86 perl syntax gt Comments start with and go to end of line as in shel
32. ement wantarray die warn check scalar list context in subroutine abort program with error warning call map grep require use Iterate over or filter list elements Import library module Perl provides most standard C and POSIX functions and system calls for arithmetic and low level access to files network sockets and other interprocess communication facilities All built in functions are listed in man perlfunc A comprehensive set of add on library modules is listed in man perlmodlib and thousands more are on http www cpan org 93 perl regular expressions gt Perl s regular expression syntax is similar to sed s but O are metacharacters and need no backslashes gt Substrings matched by regular expression inside are assigned to variables 1 2 3 and can be used in the replacement string of as expression gt The substring matched by the regex pattern is assigned to amp the unmatched prefix and suffix go into and gt Predefined character classes include whitespace s digits d alphanumeric or _ character w The respective complement classes are defined by the corresponding uppercase letters e g S for non whitespace characters Example line mgk25 x 1597 1597 Markus Kuhn homes mgk25 usr bin bash if line wt 7 dt dt 32 5 15 logname 1 name 2 print logname name n else L die Syntax error in line n
33. esort if a normal kill which sends SIGINT failed otherwise program has no chance to clean up resources before it terminates gt The jobs command shows only jobs of the current shell while ps and top list entire process table Options for ps differ significantly between System V and BSD derivatives check man pages gt fg or just runs previously stopped job in foreground which allows you to switch between several programs conveniently 30 Shell variables Serve both as variables of type string in shell programming as well as environment variables for communication with programs Set variable to value variable value Note No whitespace before or after allowed Make variable visible to called programs export variable export variable value Modify environment variables for one command only variablei value variable2 value command set shows all shell variables printenv shows all exported environment variables 31 Standard environment variables bland gt HOME Your home directory also available as gt USER LOGNAME Your login name gt PATH Colon separated list of directories in which shell looks for commands e g bin usr bin usr X11R6 bin Should never contain at least not at beginning Why LD LIBRARY PATH Colon separated list of directories where the loader looks for shared libraries see man 1d so gt LANG LC_ Your locale the name of a system
34. files lack instructions to output paper but define a rectangular bounding box using special AABoundingBox comments Load the graphicx extension of IATEX by adding usepackage graphicx to the preamble Then write includegraphics filename eps wherever you want to include the graphics file into your text In pdflatex the graphicx package allows you to include graphics from PDF vector graphics JPEG photos and PNG bitmap files includegraphics filename pdf 123 Postscript PDF graphics facilities Applying coordinate transforms The graphicx package provides access to the geometric transform capabilities of the PostScript and PDF languages scalebox 0 8 includegraphics diagram pdf includegraphics height 60mm diagram2 pdf resizebox 190mm 60mm becomes 19 cm x 6 cm large resizebox 190mm this becomes 19 cm wide rotatebox 180 this is upside down Changing colours The color package also uses Postscript PDF special commands This text is textcolor red printed in red if This text is printed in red if you include usepackage color Default definecolor red rgb 1 0 0 124 Figures and references Larger diagrams interfere with page breaking They are best placed into a figure environment such that ATEX can move them around Example begin figure Nincludegraphics width 0 6 linewidth photo jpg caption This photograph shows the experimental setup label fig expsetup
35. g a bash script starts with it bin bash If the kernel does not recognize a command file format the shell will interpret each line of it therefore the 3t is optional for shell scripts Use chmod x file and file or bash file 34 Plain text files K File is a sequence of lines trad each 80 characters long K Characters ASCII encoded or extension ISO 8859 1 Latin 1 Microsoft s CP1252 EUC Unicode UTF 8 etc gt Each line ends with a special line feed control character LF Ctrl J byte value 1019 OAi6 gt Horizontal tabulator HT TAB Ctrl l byte value 9 advances the position of the next character to the next multiple of 8 column Some systems e g DOS Windows some Internet protocols end each line instead with a two control character sequence carriage return CR Ctrl M 1310 OD16 plus line feed Different end of line conventions and different ASCII extensions make conversion of plain text files necessary dos2unix iconv Very annoying Alternative flowed plain text format no LF is stored inside a paragraph line wrapping of paragraph happens only while a file is being displayed LF terminates paragraph Some plain text editors e g Windows Notepad start each UTF 8 plain text file with a Unicode Byte Order Mark BOM U4 FEFF EFig BBig BF16 which is not normally used under Unix 35 Shell compound commands A list is a sequence of one or more pipel
36. haracter except new line matches the preceding item zero or more times matches the preceding item one or more times matches the preceding item optionally 0 1 times matches start of line matches end of line matches one of listed characters to negate and for ranges K C grouping in m match n times V escape following meta character 47 sed some examples Substitute all occurrences of Windows with Linux command s substitute option g global all occurrences in line sed s Windows Linux g Delete all lines that do not end with OK command d delete sed OK d Print only lines between those starting with BEGIN and END inclusive sed n BEGIN END p Substitute in lines 40 60 the first word starting with a capital letter with XC sed 40 60s A Z a zA Z X 48 grep head tail sort Print only lines that contain pattern grep pattern files Option v negates match and i makes match case insensitive gt Print the first and the last 25 lines of a file head n 25 file tail n 25 file tail f outputs growing file Print the lines of a text file in alphabetical order sort file Options k select column n sort numbers u eliminate duplicate lines r reverse order 49 chmod set file permissions Unix file permissions 3 x 3 2 1 12 bit information Read write execute right for user group other
37. hts of the author preserve copyright notice and licence terms in source code and documentation e you agree not sue the author over software quality accept exclusion of liability and warranty GNU General Public Licence GPL requires in addition that any derived work distributed or published e must be licensed under the terms of the GPL e must have its source code made publicly available Numerous refinements and variants of these licences have been written For more information on the various opensource licence types and their philosophies http opensource org Original Unix user interfaces The initial O devices were teletype terminals Photo Bell Labs VT100 terminals and later video display terminals such as the DEC VT100 all providing 80 characters per line fixed width ASCII output Their communications protocol is still used today in graphical windowing environments via terminal emulators e g xterm konsole Photo http www catb org esr writings taouu html The VT100 was the first video terminal with microprocessor and the first to implement the ANSI X3 64 ECMA 48 control functions For instance Psc 7m activates and Ta LOW returns to normal where sc is the ASCII escape control character 27 Ox1B http www vt100 net http www ecma international org publications standards Ecma 048 htm man console_codes Unix tools design philosophy gt Compact and concise i
38. il next source code line skip function calls K n continue until next source code line follow function calls Also consider starting gdb within emacs with ESC x gdb which causes the program counter position to be indicated in source file windows 75 make a project build tool The files generated in a project fall into two categories gt Source files Files that cannot be regenerated easily such as e working files directly created and edited by humans e files provided by outsiders e results of experiments gt Derived files Files that can be recreated easily by merely executing a few shell commands such as e object and executable code output from a compiler e output of document formatting tools e output of file format conversion tools e results of post processing steps for experimental data e source code generated by other programs e files downloaded from Internet archives 76 make writing a Makefile Many derived files have other source or derived files as prerequisites They were generated from these input files and have to be regenerated as soon as one of the prerequisites has changed and make does this A Makefile describes gt which target file in a project is derived on which other files that target depends as a prerequisite gt which shell command sequence will regenerate it A Makefile contains rules of the form targeti target2 prereqi prereq2 command 1 command2 Command li
39. ines separated by amp ae or and optionally terminated by one of amp or end of line The return value of a list is that of the last command executed gt list executes list in a subshell gt list groups a list to override operator priorities gt for variable in words do list done Expands words like command line arguments assigns one at a time to the variable and executes list for each Example for f in txt do cp f f bak done gt if list then lit elif list then list else list fi gt while list do list done until ist do list done 36 Shell compound commands cont d case word in pattern pattern list esac Matches expanded word against each pattern in turn same matching rules as pathname expansion and executes the corresponding ist when first match is found Example case command in start app_server amp processid stop kill processid echo unknown command esac 37 Boolean tests The first ist in the if while and until commands is interpreted as a Boolean condition The true and false commands return 0 and 1 respectively note the inverse logic compared to Boolean values in C The builtin command test expr which can also be written as L expr evaluates simple Boolean expressions on files such as e file is true if file exists d file is true if file exists and is a directory f fi
40. it merge git rebase gitk GUI history browser Tutorial https www kernel org pub software scm git docs gittutorial html Manual https www kernel org pub software scm git docs user manual html Git for computer scientists http eagain net articles git for computer scientists Git concepts simplified http gitolite com gcs Tutorial for Subversion users http git or cz course svn html 71 Version control etiquette v Use diff before commit carefully review what you actually changed This often uncovers editing accidents and left over temporary changes never intended to go into the repository Provide a useful commit message a complete meaningful honest and accurate summary of everything you changed Don t write just bug fixed which or API changed how and why Under git there is a format convention for commit messages a one line summary followed by an empty line followed by details Include function names bug numbers Commit unrelated changes separately Others may later want to undo or merge them separately Commit related changes together Do not forget associated changes to documentation test cases build scripts etc Leave the repository in a usable and consistent state It should always compile without errors and pass tests Avoid dependent or binary files in the repository Diffs on binary files are usually incomprehensible Compiled output should be easy to recreate t just
41. l Compound statements if expr block elsif expr block else block while ezpr block continue block for expr expr expr block foreach var list block Each block must be surrounded by no unbraced single statements as in C The optional continue block is executed just before expr is evaluated again The compound statements if unless while and until can be appended to a statement n O if n gt 9 do x gt gt 1 until x lt 64 A do block is executed at least once perl syntax cont d gt Loop control e last immediately exits a loop e next executes the continue block of a loop then jumps back to the top to test the expression e redo restarts a loop block without executing the continue block or evaluating the expression gt The loop statements while for or foreach can be preceded by a label for reference in next last or redo instructions LINE while lt STDIN gt 1 next LINE if t discard comments No need to declare global variables For more information man perlsyn 88 per1 subroutines sub max gt Subroutine declaration my x y return x if x gt y sub name block y T Subroutine call name list m max 5 7 name list print max m n amp name A amp prefix clarifies that a name identifies a subroutine This is usually redundant thanks to a prior sub declaration or parenthesis
42. l 13 Command line arguments return value environment A Unix C program is invoked by calling its main function with gt a list of strings argv as an argument gt a list of strings environ as a predefined global variable include lt stdio h gt Environment strings have the form extern char environ name value int main int argc char argv where name is free of int i printf Command line arguments n Argument argv LO is usually the for i 0 i lt argc i puts argv i name or path of the program printf Environment n for i 0 environ i NULL i Convention main 0 signals puts environ i success other values signal errors return 0 to calling process 14 File descriptors Unix processes access files in three steps gt Provide kernel in open or creat system call a path name and get in return an integer file descriptor gt Provide in read 7 write and seek system calls an opened file descriptor along with data gt Finally call close to release any data structures associated with an opened file position pointer buffers etc The 1sof tool lists the files currently opened by any process Under Linux file descriptor lists and other kernel data can be accessed via the simulated file system mounted under proc As a convention the shell opens three file descriptors for each process K 0 standard input for reading the da
43. le Option u gives better readable unified format with context lines Option r compares entire directory trees diff u example bak example txt diff example bak example txt example bak 2c2 3 example txt this sentence no verb 00 1 2 1 3 00 lt a an unmodified line gt this sentence has a verb this sentence no verb gt a newly added line this sentence has a verb a newly added line patch lt diff fzle Apply the changes listed in the provided diff output file to the old files named in it The diff file should contain relative pathnames If not use option pn to strip the first n directory names from pathnames in diff file If the old files found by patch do not match exactly the removed lines in a u diff output patch will search whether the context lines can be located nearby and will report which line offset was necessary to apply them diff3 myfile oldfile yourfile Compare three files and merge the edits from different revision branches 56 RCS Revision Control System Operates on individual files only For every working file example an associated RCS file example v keeps a revision history database RCS files can be kept next to the working files or in a subdirectory RCS K ci example Move a file back into the RCS file EE as the new latest revision check in RCS file RCS example v gt ci u example Keep a read only unlocked copy Worki
44. le is true if file exists and is a normal file r file is true if file exists and is readable w file is true if file exists and is writable g file is true if file exists and is executable or strings such as string1 string2 stringl lt string2 stringl string2 string1 gt string2 38 Boolean tests examples if e HOME rhosts then echo Found rhosts mail LOGNAME s Hacker backdoor fi Note A backslash at the end of a command line causes end of line to be ignored if hostname python cl cam ac uk then sleep 10 play sounds greeting wav amp else xmessage Good Morning Dave amp fi arch 12 1x86 clear echo I m a PC L 39 Aliases and functions Aliases allow a string to be substituted for the first word of a command alias dir ls la dir Shell functions are defined with name 7 list Y In the function body the command line arguments are available as 1 2 3 etc The variable contains all arguments and their number unalias dir dir O 1s la Outside the body of a function definition the variables 1 2 3 can be used to access the command line arguments passed to a shell script 40 Shell history The shell records commands entered These can be accessed in various ways to save keystrokes Y wv Y Y history outputs all recently entered commands In is sub
45. line as with sed Option w prints warnings about dubious looking code Option d activates the Perl debugger see man perldebug Option p places the loop while lt gt print T around the script such that perl reads and prints every line This way Perl can be used much like sed sed e s sed perl g perl pe s sed perl g Option n is like p without the print Option ilbackup suf fix adds in place file modification to p It renames the input file opens an output file with the original name and directs the input into it For more information man perlrun 97 perl a stream editing example Spammers send out unsolicited bulk email junk email for marketing or fraud They harvest millions of valid email addresses for example from web pages To make email addresses in your web pages slightly harder to harvest you can avoid the sign in the HTML source For instance convert lt a href mailto jdoe acm org gt jdoe acm org lt a gt into lt a href mailto jdoe 40acm org gt jdoe amp 64 acm org lt a gt The lines perl pi bak EOT html s href mailto 7 CL7 J 1 40 2 ig s a zA Z0 9 _ a zA Z0 9 1 amp 64 2 ig EOT will do that transformation for all HTML files in your directory More sophisticated methods hide an email address in JavaScript or use a CAPTCHA 98 perl a simple example Generate a list of
46. nes must start with a TAB character ASCII 9 77 make writing a Makefile cont d Examples demo demo c demo h gcc g 0 o demo demo c data gz demo demo gzip c gt data gz Call make with a list of target files as command line arguments It will check for every requested target whether it is still up to date and will regenerate it if not t first checks recursively whether all prerequisites of a target are up to date t then checks whether the target file exists and is newer than all its prerequisites gt If not it executes the regeneration commands specified Without arguments make checks the targets of the first rule 78 make variables Variables can be used to abbreviate rules CC gcc CFLAGS g 0 demo demo c demo h CC CCFLAGS o 0 lt data gz demo gzip c gt 0 0 file name of the target of the rule name of the first prerequisite gt names of all prerequisites Environment variables automatically become make variables for example HOME A in a shell command has to be entered as 79 make implicit rules phony targets Implicit rules apply to all files that match a pattern h eps gif giftopnm lt pnmtops noturn gt h eps jpg djpeg lt pnmtops noturn gt make knows a number of implicit rules by default for instance h o h c CC c CPPFLAGS CFLAGS lt It is custom
47. ng file ci 1 is equivalent to ci followed by co example gt ci l example Keep a writable locked copy only one user can have the lock for a file at a time ci 1 is equivalent to ci followed by co 1 co example Fetches the latest revision from example v asa read only file check out Use option rn m to retrieve earlier revisions There must not be a writable working file already gt co l example Fetches the latest revision as a locked writable file if the lock is available 57 RCS Revision Control System cont d gt rcsdiff example Show differences between working file and latest version in repository use option rn m to compare older revisions Normal diff options like u can be applied K rlog example Show who made changes when on this file and left what change comments If you want to use RCS in a team keep all the v files in a shared repository directory writable for everyone Team members have their own respective working directory with a symbolic link named RCS to the shared directory As long as nobody touches the v files or manually changes the write permissions on working files only one team member at a time can edit a file and old versions are never lost The rcs command can be used by a team leader to bypass this policy and break locks or delete old revisions RCS remains useful for quickly maintaining history of singl
48. ngleright gt lt VO CIECDA Mathematical symbols Relations F1 C oT m Ifi Q ATA AIA AMA leq prec preceq XLI subset subseteq sqsubseteq in vdash smile frown sqsubset not lt not leq not prec KM U L UU lU IU U WIY Y IV M hd Ncap Ncup Nuplus sqcap sqcup wr Nbigcirc rhd vee wedge IVIAR O OQ 8O D oplus ominus otimes oslash odot dagger ddagger Namalg unlhd unrhd A bigtriangleup V bigtriangledown geq succ succeq gg supset supseteq sqsupseteq Mni dashv mid parallel sqsupset not not geq not succ XFIT R X Ie R 2 i TL WK equiv sim Nsimeq Nasymp Napprox Ncong bowtie propto models Ndoteq perp Join not gt not equiv 118 Mathematical symbols Arrows leftarrow Leftarrow rightarrow Right arrow leftrightarrow Leftrightarrow mapsto hookleftarrow leftharpoonup leftharpoondown rightleftharpoons longleftarrow Longleftarrow longrightarrow Longrightarrow longleftrightarrow ll dt va rtitaeteent Mathematical symbols aleph hbar imath jmath ell wp Re Im partial infty Box O8 6 756 s gt s 9 mx oO PK EA lt de ldots PiNneeeescoi ll lif prime emptyset nabla surd top bot M Nangle Ntriangle backslash Diamond cdots Longleftrightarrow longmapsto hookrightarrow rightharpoonup rightharpoondown lead
49. nput syntax making full use of ASCII repertoire to minimise keystrokes gt Output format should be simple and easily usable as input for other programs Programs can be joined together in pipes and scripts to solve more complex problems gt Each tool originally performed a simple single function gt Prefer reusing existing tools with minor extension to rewriting a new tool from scratch The main user interface software shell is a normal replaceable program without special privileges Support for automating routine tasks Brian W Kernighan Rob Pike The Unix Programming Environment Prentice Hall 1984 Unix documentation Most Unix documentation can be read from the command line Classic manual sections user commands 1 system calls 2 library functions 3 devices 4 file formats 5 The man tool searches for the manual page file MANPATH and activates two further tools nroff text formatter and more text file viewer Add optional section number to disambiguate man 3 printf C subroutine not command Honesty in documentation Unix manual pages traditionally include a BUGS section xman X11 GUI variant offers a table of contents info alternative GNU hypertext documentation system Invoke with info from the shell of with C h i from emacs Use M enu key to select topic or Enter to select hyperlink under cursor N ext P rev U p D irectory to navigate document tree
50. ok But not always E g NASA Dr K Smith et al agree To correct failures of this heuristic use D gt no break space u force normal space following punctuation ends sentence as in E g N NASA Dr K Smith et al agree 4 E g NASA Dr K Smith et al agree Or disable the distinction of spaces with frenchspacing Structure of a ATEX document First select a document class and its options e g with documentclass 12pt a4paper article Standard classes article report book letter slides Publishers often provide authors with their own class as a cls file Appendix A of The ATEX Companion explains how to write new class files A popular class for presentation slides beamer Delimit block environments as in begin document end document Others abstract center verbatim itemize tabular Mark headings with section subsection subsubsection paragraph and ATEX will take care of font sizes numbering and table of contents TEX is a full programming language with macros variables recursion conditional branching file O and a huge collection of add ons Tweaking and extending ATEX IATEX behaviour can be changed by overwriting predefined variables and macros This can be done gt in the preamble between the documentclass and begin document lines for the entire document anywhere in the document the effect will last only until the end
51. onflict but was automatically resolved Remaining conflicts indicated as C must be merged manually To assist in manual merging of conflicts the update operation will write out all three file versions involved all identified with appropriate filename extensions as well as a diff3 style file that shows the differing lines next to each other for convenient editing 65 svn some more commands svn resolved filenames Tell Subversion you have resolved a conflict Also cleans up the three additional files svn revert filenames Undo local edits and go back to the version you had at your last checkout commit or update svn ls filenames List repository directory entries svn cat filenames Output file contents from repository Use svn cat filenames rev to retrieve older revision rev Some of these commands can also be applied directly to a repository without needing a working directory In this case specify a repository URL instead of a filename svn copy file HOME SVN trunk file HOME SVN tags release 1 0 An svn copy increases the repository size by only a trivial amount independent of how much data was copied Therefore to give a particular version a symbolic name simply svn copy it in the repository into a new subdirectory of that name 66 Working example User 1 svnadmin create HOME svn repos svn mkdir file HOME svn repos example m demo Committed re
52. ository The status code shown indicates e A added this file will appear in the repository e D deleted this file will disappear from the repository e M modified you have edited this file e R replaced you used svn delete followed by svn add e C conflict at the last update there was a conflict between your local changes and independent changes in the repository which you still need to resolve manually e unversioned file is not in repository suppress q e I missing file in repository but not in working dir gt svn diff filenames Show what you changed so far compared to the base version that you got at your last checkout or update K svn info Show metadata about the working directory revision of last update URL of repository etc 64 svn commits and updates svn commit filenames Check into the repository any modifications additions removals of files that you did since your last checkout or commit Option m provides a commit log message without it svn commit will call EDITOR for you to enter one svn update filenames Apply modifications that others committed since you last updated your working directory This will list in the first column a letter for any file that differed between your working directory and the repository Apart from the letter codes used by status it also may indicate e U updated get newer version of this file from repository e G merged c
53. pography The minus is a mathematical operator whose shape matches the plus unlike the hyphen or dashes Compare r 108 Quotation marks Typewriters and ASCII offer only undirectional single and double quotation marks while typesetters use curly and directed variants TEX input files use the single quotation mark and the grave accent to encode these as well the mathematical prime marker and the French accents left quote right quote left doublequote right doublequote prime acute accent grave accent u Vu The apostrophe it s is identical to the right single quotation mark In some older terminal fonts especially of US origin the and characters have a compromise shape somewhere between the quotation marks and the accents V V V V V uu 109 Non ASCII Symbols TED AA q NP LOST o T Mag Noe NO i ddag E GE t Al copyright Nae L NL Npounds A ME D ss Mdots Naa o S Combining characters o 0 O 10 t oo Vo 6 o Nc o Vo Lot o d o o 5 vfo o bfo 6 Vo 6 Hot 110 Space the final frontier Traditional English typesetting inserts a larger space at the end of a sentence TEX believes any space after a period terminates a sentence unless it is preceded by an uppercase letter Parenthesis are ignored This works often J F Kennedy s U S budget Lo
54. r several preprocessing steps have been applied first cp Lecture Timetable pdf lecture timetable pdf mv bak old files Command options are by convention single letters prefixed by a hyphen 7h Unless followed by option parameters single character flag options can often be concatenated ls l a t 1s lat GNU tools offer alternatively long option names prefixed by two hyphens help Arguments not starting with hyphens are typically filenames hostnames URLs etc gcc version curl head http www cl cam ac uk 20 Command line argument conventions cont d The special option signals in many tools that subsequent words are arguments not options This provides one way to access filenames starting with a hyphen rm i rm i The special filename signals often that standard input output should be used instead of a file All these are conventions that most but not all tools implement usually via the getopt library function so check the respective manual first The shell remains ignorant of these conventions http pubs opengroup org onlinepubs 9699919799 basedefs V1 chapi2 html 21 Shell command line preprocessing A number of punctuation characters in a command line are part of the shell control syntax lE lt gt or can trigger special convenience substitutions before argv is handed over to the called program gt brace expansion 1 7 gt tild
55. s in ernative 2 jpg ex f pdf A Document Preparation System Recommended introduction Leslie Lamport ATEX a document preparation system 2nd ed Addison Wesley 1994 Online tutorials http www latex project org guides TEX Frequently Asked Questions http www tex ac uk cgi bin texfaq2html For advanced users Mittelbach et al The ATEX Companion 2nd ed Addison Wesley 2004 102 ITEX example documentclass 12pt article mmar setlength textwidth 75mm TEX SE ay begin document title TeX a summary Markus Kuhn author Markus Kuhn date 28 November 2013 28 November 2013 maketitle thispagestyle empty section Introduction 1 Introduction Mathematical formul ae such as Mathematical formule such as e 1 e i pi 1 or even or even XL Phi z frac i sqrt 2 pi Mint O x e fraci2 x72 M z soe were a real pain to typeset until V2r Jo textsc Knuth s text formatter TeX became available cite Knuth86 were a real pain to typeset until KNUTH s text formatter TEX became available 1 begin thebibliography 9 bibitem Knuth86 Donald E Knuth The TeX book Ad dison Wesley 1986 References end thebibliography 1 Donald E Knuth The TFXbook Ad end document dison Wesley 1986 103 TEX input syntax Y wv vV Yy TEX reads plain text tex files e g prepared with emacs no distinction is made between sp
56. stituted by the n th history entry 11 and 1 are equivalent to the previous command 1x is the previous command line minus the first word Use cursor up down keys to access history list modify a previous command and reissue it by pressing Return Type Ctrl O instead of Return to issue command from history and edit its successor which allows convenient repetition of entire command sequences Type Ctrl R to search string in history Most others probably only useful for teletype writers without cursor 41 Readline Interactive bash reads commands via the readline line editor library Many Emacs like control key sequences are supported such as Y Ww Ww V Y NN Ctrl A Ctrl E moves cursor to start end of line Ctrl K deletes kills the rest of the line Ctrl D deletes the character under the cursor Ctrl W deletes a word first letter to cursor Ctrl Y inserts deleted strings ESC performs history expansion on current line ESC turns current line into a comment Automatic word completion Type the Tab key and bash will complete the word you started when it is an existing variable user hostname command or filename depending on the context If there is an ambiguity pressing Tab a second time will show list of choices 42 Startup files for terminal access When you log in via a terminal line or telnet rlogin ssh After verifying your password the login command checks etc passwd to find o
57. sto uparrow Uparrow downarrow Downarrow updownarrow Updownarrow nearrow searrow swarrow nwarrow 119 forall exists neg flat natural sharp clubsuit diamondsuit heartsuit spadesuit 9304439 U lt Nvdots ddots 120 Mathematical symbols Large operators saM sum prod coprod int oint Delimiters NN EAM h A E lbrack lfloor lceil lbrace langle YL L gt lt C CD langle langle Mathematical symbols Alternative names 2 ne neq le ge T lt Stacking things b a b NC AF to gets overline a b underline a b bigcap bigcup bigsqcup bigvee bigwedge ILC Kd o ES Kd J UU ab c Qoo rbrack rfloor rceil rbrace rangle J bigodot bigotimes bigoplus biguplus rangle rangle owns land lor lnot a_ b Wert Wert ge m a b overbrace a b a b Nunderbrace a b left begin array cl a 271272 amp a ge O NN a K a lt end array right 0 Including graphics DVI only supports characters and filled rectangles but dvips and pdftex also understand embedded special instructions that provide more Embedded PostScript EPS vector graphics Normal PostScript files ps produce a sequence of pages An EPS file describes only an image and is meant to be included into a PostScript page EPS
58. ta to be processed gt 1 standard output for the resulting output data K 2 standard error for error messages 15 Basic shell syntax pipes Start a program and connect the three default file descriptors stdin stdout and stderr to the terminal command Connect stdout of command1 to stdin of command2 and stdout of command2 to stdin of command3 by forming a pipe commandi command2 command3 Also connects terminal to stdin of command1 to stdout of command3 and to stderr of all three Note how this function concatenation notation makes the addition of command arguments somewhat clearer compared to the mathematical notation command3 command2 commandi argi arg2 arg3 ls la sort n k5 less 16 Basic shell syntax sequences Execute several commands or entire pipes in sequence commandi command2 command3 For example date host ryath ds cam ac uk Thu Oct 31 11 48 22 GMT 2013 ryath ds cam ac uk has address 131 111 8 223 Conditional execution depending on success of previous command as in logic expression short cut make ftest amp amp ftest ftest echo Test failed Return value 0 for success is interpreted as Boolean value true other return values for problems or failure as false The trivial tools true and false simply return 0 and 1 respectively File redirecting basics Send stdout to file command gt filename Append stdout to file
59. ut what shell to start for you gt Asa login shell bash will execute the scripts etc profile profile The second one is where you can define your own environment Use it to set exported variable values and trigger any activity that you want to happen at each login gt Any subsequently started bash will read bashrc instead which is where you can define functions and aliases which unlike environment variables are not exported to subshells 43 Startup files for X Window System access The X server provides access to display keyboard and mouse for X client applications via the X11 protocol Before login the only client is the X Display Manager xdm After login xdm will start the script usr lib X11 xdm Xsession That invokes the X clients xterm etc that run on your desktop by default If xsession exists this script will be called instead Most X clients in Xsession or xsession are started in background except for the last one which is usually a window manager twm fvwm2 KDE etc When this last client terminates and with it the Xsession script then xdm will reset the X server This will terminate all X clients and the user is logged out You can configure your login screen in xsession You can also configure default parameters for many X clients via the xrdb command See man X for details 44 Typical xsession file bin bash profile set X defaults and keymaps
60. vision 1 svn checkout file HOME svn repos example exi Checked out revision 1 cd exi ex1 echo hello world gt file1 exi svn add filei A filet exi svn commit m adding my first file Adding filet Transmitting file data Committed revision 2 exi echo bla gt file2 A file2 exi svn add file2 exi echo hello humans filei exi svn status M filet A file2 exi svn commit m world gt humans Sending filet Adding file2 Transmitting file data Committed revision 3 exi svn status exi svn update U file1 Updated to revision 4 ex2 cat file1 hello humans and dogs svn remote access Working example User 2 svn checkout file HOME svn repos example ex2 A ex2 filel Checked out revision 2 cd ex2 ex2 echo hello dogs gt file1 ex2 svn status M file1 ex2 svn commit m world gt dogs Sending file1 svn Commit failed details follow svn File example file1 is out of date ex2 svn update Conflict discovered in file1 Select p postpone df diff full e edit mc mine conflict tc theirs conflict s show all options p C filet A file2 Updated to revision 3 Summary of conflicts Text conflicts 1 ex2 cat filei lt lt lt lt lt lt lt mine hello dogs hello humans gt gt gt gt gt gt gt r3 ex2 svn status T filei mine filei r2 T filei r3 C filet ex2 echo hello humans and dogs gt file1 ex
61. wastes repository space and others can never be sure what is in it 72 cc gcc the C compiler Example cat hello c include lt stdio h gt int main printf Hello World n return 0 gcc o hello hello c hello Hello World Compiler accepts source c and object o files Produces either final executable or object file option c Common options gt W Wall activate warning messages better analysis for suspicious code gt 0 activate code optimizer K g include debugging information symbols line numbers 73 gdb the C debugger Best use on binaries compiled with g gt gdb binary run command inside debugger r after setting breakpoints gt gdb binary core post mortem analysis on memory image of terminated process Enter in shell ulimit c 100000 before test run to enable core dumps Core dump can be triggered by gt a user pressing Ctrl N SIGQUIT K a fatal processor or memory exception segmentation violation division by zero etc 74 gdb some common commands v bt print the current stack backtracing function calls gt p expression print variable and expression values K up down move between stack frames to inspect variables at different function call levels gt b set breakpoint at specified line or function gt r run program with specified command line arguments K s continue unt
62. xpansion Command line arguments containing or are interpreted as regular expression patterns and will be substituted with a list of all matching filenames gt 7 stands for an arbitrary single character K stands for an arbitrary sequence of zero or more characters gt stands for one character out of a specified set Use to specify range of characters and to complement set Certain character classes can be named within None of the above will match a dot at the start of a filename which is the naming convention for hidden files Examples bak A Za z alpha l A Z files o 25 Quote removal Three quotation mechanisms are available to enter the special characters in command line arguments without triggering the corresponding shell substitution gt suppresses all special character meanings suppresses all special character meanings except for H X N suppresses all special character meanings for the immediately following character Example echo HOME x HOME homes mgk25 HOME The bash extension provides access to the full C string quoting syntax For example Nx1b is the ASCII ESC character 26 Job control Start command or entire pipe as a background job without connecting stdin to terminal command amp 1 4739 testrun 2 amp 1 gzip 9c gt results gz amp 2 4741 testruni
Download Pdf Manuals
Related Search
Related Contents
Balança Pesadora Manual do Usuário - w w w . u p x s o l u t i o n Télécharger La Santé de l`homme 410 - Inpes Genicom 3600 User's Manual Opticon OPN-2006 QTA Access Point Configurator User Manual ver 1.0 Canon PowerShot A80 User's Manual 5082 Guide to the MVI56 UM351W/UM301W/ UM361X/UM301X COMPOSITE Ver.Ka キョンの妹ロボ 取扱説明書 Copyright © All rights reserved.
Failed to retrieve file