📄 intro
字号:
Also, the command.IR tabs (1)will set the tab stops automatically on many terminals..LP.IHow to run a program; the Shell.\ \ .RWhen you have successfully logged in, a programcalled the Shell is listening to your terminal.The Shell reads typed-in lines, splits them upinto a command name and arguments, and executes the command.A command is simply an executable program.The Shell looks first in your current directory(see below)for a program with the given name,and if none is there, then in a system directory.There is nothing special about system-providedcommands except that they are kept in a directorywhere the Shell can find them..LPThe command name is always the first word on an input line;it and its arguments are separated from one another byspaces..LPWhen a program terminates, the Shell will ordinarily regain control and type a `$' at you to indicate that it is ready for another command..LPThe Shell has many other capabilities, which are described in detail in section.IR sh (1)..LP.IThe current directory.\ \ .R.UXhas a file system arranged in a hierarchy of directories.When the system administrator gave you a user name,he also created a directory for you (ordinarilywith the same name as your user name).When you log in, any filename you type is by defaultin this directory.Since you are the owner of this directory, you havefull permission to read, write, alter, or destroyits contents.Permissions to have your will with other directoriesand files will have been granted or denied to youby their owners.As a matter of observed fact, few.UXusersprotect their files from destruction,let alone perusal, by other users..LPTo change thecurrent directory (but not the set of permissions youwere endowed with at login) use.IR cd (1)..LP.IPath names.\ \ .RTo refer to files not in the current directory, you mustuse a path name.Full path names begin with `/', the name of the root directory of thewhole file system.After the slash comes the name of each directory containing the nextsub-directory (followed by a `/') until finally thefile name is reached.For example,.I/\^usr/\^lem/\^filex.Rrefers to the file.Ifilex.Rin the directory.Ilem; lem.Ris itself a subdirectory of.Iusr; usr.Rsprings directly from the root directory..LPIf your current directory has subdirectories,the path names of files therein begin withthe name of the subdirectory with no prefixed `/'..LPA path name may be used anywhere a file name isrequired..LPImportant commands which modify the contents of filesare.IR cp (1),.IR mv (1),and.IR rm (1),which respectively copy, move (i.e. rename) and remove files.To find out the status of files or directories, use .IR ls (1).See.IR mkdir (1)for making directories and.Irmdir.R(in.IR rm (1))for destroying them..LPFor a fuller discussion of the file system, see`The.UXTime-Sharing System,'by Ken Thompson and Dennis Ritchie.It may also be useful to glance throughsection 2 of this manual, which discussessystem calls, even if you don't intendto deal with the system at that level..LP.IWriting a program.\ \ .RTo enter the text of a source program into a.UXfile, usethe editor.IR ed (1).The three principal languages in.UXareprovided by the C compiler.IR cc (1),the Fortran compiler.IR f77 (1),and the assembler.IR as (1).After the program text has been entered through the editorand written on a file, you can give the fileto the appropriate language processor as an argument.The output of the language processorwill be left on a file in the current directory named `a.out'.(If the output is precious, use.I mvto move it to a lessexposed name soon.)\ If you wrote in assembly language, you will probablyneed to load the program with library subroutines; see.IR ld (1).The other two language processors callthe loader automatically..LPWhen you have finally gone through this entire processwithout provoking any diagnostics, the resulting programcan be run by giving its name to the Shellin response to the `$' prompt..LPYour programs can receive arguments from the command linejust as system programs do,see.IR exec (2)..LP.IText processing.\ \ .RAlmost all text is entered through the editor.IR ed (1).The commands most often used to write text on a terminal are:.Icat, pr, roff.Rand.I nroff,all in section 1..LPThe.I catcommand simply dumps \s8ASCII\s10 texton the terminal, with no processing at all.The.IR pr ""command paginates the text, supplies headings,and has a facility for multi-column output..INroff.Ris an elaborate text formatting program.Used naked, it requires careful forethought, but forordinary documents it has been tamed;see.IR ms (7)..I Roffis a simpler text formattingprogram, and requires somewhat less forethought..I.LP.I Troffprepares documents for aGraphics Systems phototypesetter;it is very similar to .I nroff,and often works from exactly the samesource text.It was used to produce this manual..LP.IStatus inquiries.\ \ .RVarious commands exist to provide you with usefulinformation..IR Who (1)prints a list of users presently logged in..IR Date (1)prints the current time and date..IR Ls (1)will list the files in your directory or givesummary information about particular files..LP.ISurprises.\ \ .RCertain commands provide inter-user communication.Even if you do not plan to use them, it would bewell to learn something about them, because someone else mayaim them at you..LPTo communicate with another user currently logged in,.IR write (1)is used;.IR mail (1)will leave a message whose presence will be announcedto another user when he next logs in.The write-ups in the manual also suggest how to respond tothe two commands if you are a target..LPWhen you log in, a message-of-the-day may greet youbefore the first `$'..SHCONVERTING FROM THE 6TH EDITION.LPThere follows a catalogue of significant, mostly incompatible,changes that will affect old users converting to the 7th edition.No attempt is made to list all new facilities, or even allminor, but easily spotted changes,just the bare essentials without which it will bealmost impossible to do anything..LP.IAddressing files.\ \ .RByte addresses in files are now long (32-bit) integers.Accordingly.I seekhas been replaced by.IR lseek (2).Every program that contains a .I seekmust be modified..I Statand.IR fstat (2)have been affected similarly, since file lengths are now32- rather than 24-bit quantities..LP.IAssembly language.\ \ .RSystem entry points are no longer built in symbols.Their values must be obtained from.I /usr/include/sys.s,see.IR intro (2).All system calls modify r0.This means that sequences like.DSmov file,r0sys lseek,0,0,2sys write,buf,n.DEwill no longer work.(In fact, .I lseeknow modifies r1 as well, so be doubly cautious.).LPThe.IR sleep (2)entry point is gone; see the more general facility,.IR alarm,plus.I pause..LPFew library functions have assembly language entry points any more.You will have to simulate the C calling sequence..LP.IStty and gtty.\ \ .RThese system calls have been extensively altered,see.IR ioctl (2)and.IR tty (4)..LP.IArchive files.\ \ .RThe format of files produced by.IR ar (1)has been altered.To convert to the new style, use.IR arcv (1)..LP.I C language, lint.\ \ .RThe official syntax for initializationrequires an equal sign = before an initializer,and brackets { } around compound initial values;arrays and structures are now initialized honestly.Two-address operators, such as =+ and =-, are now written+= and -= to avoid ambiguities, although the oldstyle is still accepted.You will also certainly want to learn about.DSlong integerstype definitionscasts (for type conversion)unions (for more honest storage sharing)#include <filename> (which searches in standard places).DE.LPThe program.IR lint (1)checks for obsolete syntax anddoes strong type checking of C programs, singlyor in groups that are expected to be loaded together.It is indispensable for conversion work..LP.I Fortran.\ \ The old .I fcis replaced by.I f77,a true compiler for Fortran 77,compatible with C.There are substantial changes in the language;see `A Portable Fortran 77 Compiler' in Volume 2..LP.IStream editor.\ \ .RThe program.IR sed (1)is adapted to massive, repetitiveediting jobs of the sort encountered in converting tothe new system.It is well worth learning..LP.IStandard I/O.\ \ .RThe old .Ifopen, getc, putc.Rcomplex and the old.I \-lppackage are both dead,and even.I getcharhas changed.All have been replaced by the clean, highly efficient,.IR stdio (3)package.The first things to know are that.IR getchar (3)returns the integer EOF (\-1), which is not a possible byte value,on end of file, that 518-byte buffers are out, and that thereis a defined FILE data type..LP.I Make.\ \ The program.IR make (1)handles the recompilation and loading ofsoftware in an orderly way froma `makefile' recipe given for each piece of software.It remakes only as much as the modification dates of the input filesshow is necessary.The makefiles will guide you in building your new system..LP.IShell, chdir.\ \ .RF. L. Bauer once said Algol 68 is the Everest thatmust be climbed by every computer scientist becauseit is there.So it is with the shell for.UXusers.Everything beyond simple command invocation from a terminal isdifferent.Even.I chdiris now spelled.I cd.You will want to study.IR sh (1)long and hard..LP.I Debugging.\ \ .IR Adb (1)is a far more capable replacement for the debugger.I db.The first-time user should be especially careful aboutdistinguishing / and ? in.I adbcommands, and watching to make sure that the.I xwhose value he asked for is the real.I x,and not just some absolute location equal to the stack offsetof some automatic.I x.You can always use the `true' name,.I _x,to pin down a C external variable..LP.I Dsw.This little-known, but indispensable facility has beentaken over by.Irm \-ri..LP.IBoot procedures.\ \ .RNeedless to say, these are all different.See section 8 of this volume, and`Setting up \s8UNIX\s10' in Volume 2.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -