AMIGADOS CLI: THE AMIGA'SCOMMAND LINE OPERATING SYSTEM By Joel Halbert, CCCC Amiga SIG, Tucson, AZ. This article is intended to serve as an introduction to AmigaDOS, primarily for new users. It is NOT another command summary, and does not replace the AmigaDOS manual (now available at dealers and bookstores for $24.95). Read this article to get yourself started but please refer also to the official manual for details. 1. What is AmigaDOS and the CLI? Like most all modern computers, the Amiga runs an "operating system", which is a collection of commands and procedures that enable it to communicate with the outside world (human beings as well as software programs). The Amiga's operating system is on the "Kickstart" disk which you load into the computer when you first turn the power on. The name of this operating system is "AmigaDOS" (DOS stands for Disk Operating System). Within AmigaDOS, there are two ways to communicate. The first is by manipulating the various pictures or "icons". This graphical interface is called "Intuition" and is covered in the INTRODUCTION TO AMIGA manual. In this article, we will discuss the Intuition interface only as it compares to the CLI commands. The second method of communication in AmigaDOS is called "CLI" or "Command Line Interface". In the CLI mode of operation, the user types commands from the keyboard and sees results displayed on the screen. The CLI is entirely text oriented - no mouse or graphic operations are involved (although you can use the CLI to start up other programs which do use Amiga graphics/mouse features). For those of you who have experienced other computers and DOS systems, the CLI will appear similar in many respects. You probably can skim over much of the article, though you'll want to become acquainted with Amiga jargon. If you are not completely comfortable with these topics, however, it is recommended that you read through them at least once. 2. What can the CLI be used for? Anything that can be done using the icons with "Intuition" (such as copying files or disks, running programs, etc.) can also be done by typing commands using the CLI. For most ordinary tasks, it is less convenient to use the CLI. However, the advantage of CLI is that it opens up many more options to the user, allowing more detailed manipulation of files and programs as well as certain modifications to the Amiga's normal way of doing things. For example, this document is being written using a text editor in CLI which is not available using the Intuition graphical interface. Furthermore, most of the possible operations in Intuition can ONLY be used on files and directories which have graphical icons assigned to them. For example, double-clicking the "Workbench" disk icon will reveal Systems and Utilities drawers, Clock, Preferences, etc. Unless you know how to use the CLI, those icons represent the only files and programs that you can control. In reality, there are many more files on the Workbench disk that cannot be shown because they have no icons. Also, there are many public domain software disks which are useful only by knowing the CLI. We could go on about this...but you get the point: Learn how to use the CLI! 3. What do you have to read to learn the CLI? The official version of the AmigaDOS User's Manual is now available at most good bookstores. It is a good investment once you are familiar with some of the basics. Until you purchase it, you can find much of the information in the previous three issues of the CCCC newsletter. 4. How do you get into the CLI? There are several ways of getting into the CLI environment, but our purposes will be served by describing only one. Normal method: While you are in the Intuition graphical interface mode, select "Preferences". Click the "CLI ON" box. Now exit from Preferences using the "SAVE" box (be sure that your Workbench disk is not write-protected at the time). The next time you open the "System" drawer of Workbench, you will see an icon for CLI in the System window. Double-click the icon, and a "New CLI Window" will appear. You can now type commands using the CLI (as long as the CLI window is selected). Note that you can resize the CLI window up to the entire screen area. This will make it more convenient to use CLI. If you prefer, however, you can size the CLI window so that it leaves some of the Intuition graphics screen visible. Because the Amiga and AmigaDOS are "multitasking", you are free to go back and forth between CLI and other programs or tasks. In fact, you can open up additional CLI windows to do different things at once, by typing the "NewCLI" command. 5. Once you are in CLI, how do you get back out again (back to Intuition)? Remember that if you entered CLI from Intuition as described above, you are simply using CLI in a window. You can exit from the window at any time simply by clicking the mouse outside of it. If the window covers the entire screen, you can resize it smaller and move it out of the way, or click the "behind" gadget to put it in the background as with any other Amiga window. You can now go about your business as usual in Intuition, and get back into CLI by clicking inside the CLI window and/or moving it to the front. Finally, you can get rid of the CLI window altogether. Notice that there is no "cancel" dot gadget in the upper leftcorner. The only way to cancel the window completely is to type "endcli" at the CLI prompt. 6. Typing commands in the CLI : When AmigaDOS is ready to receive your command input, it will display a prompt. When you first call up the CLI, the prompt is the symbol "1>". This means "CLI window number 1". If you create new CLI windows while running the first, the prompts will be "2>", "3>", etc. You can change the prompt to anything you like by using the "Prompt" command. It doesn't matter whether you use capital or lower-case letters when you type a command. Dir, dir, and dIR are all the same to AmigaDOS. You must, however, spell the command names exactly right or AmigaDOS won't understand what you mean. Some AmigaDOS commands are used by themselves. For example, the "EndCLI" command will simply close the current CLI window. Many commands will require more information, which you must type on the same line following the command. An example is the "Copy" command. You must tell AmigaDOS which file you want copied to which other file. These extra parameters are called command Arguments. Some commands have optional arguments. For example, the "Date" command will set the system time and date if you include those arguments on the command line. On the other hand, typing "Date" with no arguments will cause the system to show the current time and date with no change. If you need to be reminded of the syntax for an AmigaDOS command, you can type the command followed by a space and a question mark. You will then be shown the "command template", which tells you what arguments must be specified, what is optional, etc. Refer to the DOS manual for further information on this. 7. Files, directories, and devices: 7.1. What are they? The most basic concept of the operating system is the organization of FILES. Almost everything the computer uses is stored as a file: programs, graphics images, text documents (such as this one), and information about icons are all examples. The computer filing system is analogous to a conventional office filing system using manila folders. Any individual file can be retrieved if you know its name - but you must also know where it is stored. In an office, you would have to know what file drawer to look in, as well as which file cabinet. In a similar fashion, you can use AmigaDOS to specify a particular file which resides inside a particular "drawer". The "drawer" is officially called a DIRECTORY in the AmigaDOS CLI (Notice that Intuition actually does use a picture of a drawer to represent each directory - such as the Utilities drawer which contains the Notepad and Calculator program files). You can see how handy this system is. You can organize your files on a disk in sensible groups. For example, you could have a directory for correspondence called "Letters", another directory for notes on Amiga club activities, and so on. AmigaDOS even permits directories inside other directories. Your "Letters" directory could contain other directories called "Business", "Mom&Dad", "Congress", etc., each containing letters (stored as text files) in the appropriate category. To continue the analogy to an office filing system, we need to know which "file cabinet" contains the specified drawer (or directory). The AmigaDOS equivalent of a file cabinet is a DEVICE. A device can be an actual piece of hardware, such as a disk drive. AmigaDOS refers to the internal and external disk drives using the device names "DF0" and "DF1". You can also refer to a particular disk by its name, without regard for which drive it may be placed in. 7.2. How do you specify files, directories, and devices in the CLI? 7.2.1. Naming files: Every file has a name associated with it, so that AmigaDOS can keep track of where it is (on a disk or in electronic memory) and distinguish it from other files. The name of a file, or simply the "filename", can have up to 30 characters. The characters may be anything you like EXCEPT slash (/) or colon (:). The characters can even include spaces, although you will have to be careful always to enclose the filename in quotes (Example: "My First File"). For the moment, it may be easiest to avoid spaces and unusual punctuation marks in your filenames - this will cut down on the confusion. Complete details on acceptable filenames are found in the DOSmanual. 7.2.2. Precautions in using filenames: Note that AmigaDOS does not normally care about filename "extensions" or "version numbers", which are used in some other computer operating systems. Filenames can contain any sequence of letters, numbers, periods, commas, etc., and it is left up to YOU, the user, to keep track of what the names mean. If you modify a file by editing it or processing it through a program, and the resulting new file has the same name as the old one, then the old file will be erased - just like recording a new song over an old one on a music tape. We are emphasizing this point because you may be familiar with other computers, which are able to save several versions of a file with the same name to avoid unintentional erasure of information - AmigaDOS DOES NOT DO THAT. It will ERASE the old file, so be careful when you specify filenames. Avoid unintentional duplication of names. Here is another point about filenames, which also applies to anything else you type to the computer: Remember that computers take you very literally. The computer generally cannot guess at what you MEANT to type, even if it is very similar to what you actually DID type. Example: "My.First.File" is different than "My.First-File". 7.2.3. Naming and creating directories: The rules for naming directories are essentially the same as for naming files. The major difference is the following: AmigaDOS will gladly write information to a file under any name, whether or not a file by that name already exists. If there was previously no file by that name in the directory, it will simply create one. On the other hand, you cannot specify a nonexistent directory. If you want to store a file in a new directory, you must first create the directory using the "MakeDir" command (see the CLI Command Descriptions). 7.2.4. Complete syntax for file specification: If you were to tell someone at the office to retrieve a certain file folder, you might say something like "Go to the left hand file cabinet, second drawer down, and get out the File on Budget Overruns". A complete AmigaDOS file specification works in much the same way. It contains: 1) The device or disk name, followed by a colon (:), 2) The directory name or names, each followed by a slash(/), 3) The filename itself. Here are some examples of valid file specifications: DF0:Letters/JobRequest (Specifies the file "JobRequest", in the "Letters" directory, on the disk which is in the 0 (internal) disk drive.) Calendar:Amiga.Notes/Meeting-Times (Specifies the file "Meeting-Times" in in the "Amiga.Notes" directory on the disk named "Calendar". AmigaDOS will find the Calendar disk no matter what drive it is in, or it will ask you to insert the disk if it cannot find it.) Note that your desired file may be in a directory which is inside another directory, or the file may not even be inside a special directory: DF1:Letters/Mom&Dad/Send.Money! (Specifies the file "Send.Money!" in the "Mom&Dad" directory, which is contained in the "Letters" directory on the disk in the external drive.) CALENDAR:1986 (Specifies the file "1986" on the Calendar disk. The file is not in any special directory; in this case it is said to be in the ROOT directory of the Calendar disk.) At this point in our discussion, the "Office Filing Cabinet" analogy begins to break down. The next section covers some of the major extra features in the AmigaDOS filing system, which have no counterpart in a conventional file cabinet. 7.3. AmigaDOS filing system - more features: 7.3.1 Multiple, heirachical directories: As mentioned above, AmigaDOS allows you to have directories inside other directories. This "nesting" of multiple directories can go as far as you like - you can have an essentially unlimited number of directory levels. To understand this multiple directory capability, it is useful to think of the device:directory/file system as a TREE structure. The tree starts at the "root" directory, which is the device or disk name. The various directories are the branches of the tree, and each file is a leaf. It is possible to have an unlimited number of branches coming off from any other branch. MainDisk (disk name and root directory) I I I _________]_______ / I \ / I \ / I \ Dog-Track.losses /I \ (file) / I AmigaClub / I (DIR) GroceryList____/ I /\___ (file) / I / \ / I MemberList \ Letters_____/ I (file) I (DIR) Programs I I (DIR) I I \_________ \ Meetings I \ Sketch (file) I \ (file) I I I I I I Mom&Dad Jobs (DIR) (DIR) I /I\ I / I \____ Send.Money! / I \ (file) / I \ _______/ I AT&T.letter / I (file) / \ / \IBM.letter Chuck.E.Cheese.letter (file) (file) 7.3.2. Viewing directory contents ("Dir" and "List" commands) To examine various directories on a disk, you need to use the CLI commands "Dir" and "List". The command: "Dir df1:Letters"displays all the files and directories which are contained inside the "Letters" directory on the disk in the external drive. There are several options for for more sophisticated use of the "Dir" command - see the AmigaDOS manual. The "List" command is similar to the "Dir" command, but is used to display information about files (rather than just listing their names as the "Dir" commmand does). The command: "List df1:Letters" will display the file and/or directory names inside the Letters directory, but will also show the file size in bytes, the file creation date, and will print a one-line "Filenote" comment if the file has one. 7.3.3 Setting the Current Directory: It would be very annoying if AmigaDOS always forced you to type the entire "Device:Directory/Subdirectories/File" everytime you wanted to specify a particular file or directory. To avoid this chore, you can use the "CD" (Current Directory) command to tell AmigaDOS what directory you want to work in. From that point on, AmigaDOS will assume that you are working in the specified directory (unless you purposefully specify otherwise. This is best illustrated with a few examples. Let's say that you want to write a bunch of letters to various people. You select the disk named "MainDisk", which contains the "Letters" directory, and insert it into one of the drives. Then you issue the CLI command: CD MainDisk:Letters This sets your Current Directory. Now, if you issue the command: Dir you will see the contents of the Letters directory WITHOUT having to specify a"Dir MainDisk:Letters". If you want to see the contents of the "Mom&Dad" directory inside the "Letters" directory, just type: Dir Mom&Dad. Alternatively, you could use the CD command to change the Current Directory to "Mom&Dad": CD Mom&DadNotice that you didn't have to specify "CD MainDisk:Letters/Mom&Dad". That is because AmigaDOS already was set to "MainDisk:Letters" - it assumed that the "Mom&Dad" directory had to be inside "Letters". Setting the Current Directory doesn't prevent you from issuing a full: Device:Directory/Subdirectory/Filespecification if you want to. Suppose you were working in the "MainDisk:Letters/Mom&Dad" directory, and you needed to see the "Jobs" directory, which is another subdirectory of the "Letters" directory. There are several ways of accomplishing this: Option 1. Dir MainDisk:Letters/Jobs This is very unambiguous - it gives AmigaDOS the entire specification. Again, it doesn't CHANGE your Current Directory (still "MainDisk:Letters/Mom&Dad"). It simply BYPASSES the Current Directory for the purposes of using the Dir command. Option 2. Dir :Letters/Jobs This does the same thing. Notice that you didn't have to explicitly specify that the root directory is MainDisk: - AmigaDOS assumed that it is, because of your Current Directory setting. Option 3. Dir /Jobs This again does the same thing. Here, we simply told AmigaDOS to look in the "parent" directory, which is Letters. This may seem confusing, but it doesn't have to be: Remember that the Current Directory is "MainDisk:Letters/Mom&Dad". Therefore, the "/Jobs" specification simply told AmigaDOS to go UP one directory level to the "Letters" directory, and then DOWN again to the "Jobs" subdirectory. If you ever forget what your Current Directory is, simply type the "CD" command with no argument, and AmigaDOS will show you the full specification of the Current Directory. In our example, CDwould cause AmigaDOS to display: MainDisk:Letters/Mom&Dad7. 4. More about devices: So far, we have seen that the "device" is analogous to the file cabinet, with the "directories" being the file drawers and the "files" being like the individual file folders. As mentioned above, this analogy was only good up to a point. AmigaDOS devices are really somewhat more versatile than file cabinets, as we will see. 7.4.1. Physical devices and disk volumes: Disk drives are considered to be "physical" devices - they correspond to an actual piece of hardware. Disk drive devices are good for both input and output (i.e. both storage and retrieval of files). Other physical devices include the serial and parallel communications ports, the keyboard, monitor, etc. Some examples of AmigaDOS physical devices are shown below: DF0: the internal floppy disk drive. DF1: the first external floppy disk drive. DH1: the first hard disk drive. RAM: the RAMdisk (causes electronic memory to simulate a high speed disk drive - more on this later). PAR: the parallel port. SER: the serial port. PRT: the printer - may be assigned to either the SER: or PAR: device as appropriate - PRT: also handles the interpretation of all printer text and graphics commands. CON: the console device - the screen, or current output window within the screen. RAW: used for input/output processing without interpretation by the CON: or PRT: devices - only for advanced programmers. You may have noticed that a full AmigaDOS file specification can use either the DEVICE name: DF0:Accounts/Balance.Record OR the name of the actual DISK: Finances:Accounts/Balance.Record The first example refers to the Accounts directory on whatever disk is in drive 0. The second example refers to the Accounts directory on the Finances disk. That means AmigaDOS will look for the Finances disk in any drive. If it doesn't find a disk by that name, it will issue a "System Requestor" which asks you to insert the Finances disk. The official AmigaDOS jargon for a disk name is the VOLUME name - so the Requestor box will ask you to insert "volume Finances". The capability to search for a specific disk volume is a powerful and convenient feature of AmigaDOS. It is especially useful if you only have one disk drive connected, because you can force the system to perform file and directory functions on disks that are not currently in the drive - the system will simply ask you to insert the disk when it is ready.7.4.2. Logical devices and assignments (you'll have to read this carefully at first): Besides the physical devices, AmigaDOS also makes reference to "logical" devices. These logical devices are basically treated as if they were separate disks, although they are usually contained within the system disk (Workbench disk). The purpose of logical devices is to act as "reference libraries" so that AmigaDOS can interpret commands and have access to various system routines that it needs. For example, AmigaDOS looks for the "C:" device whenever it needs to execute a CLI command that you have typed. In this case, "C:" is NOT the name of a disk, but of a logical device - the CLI command library. Because the logical devices do not correspond to physical pieces of hardware, AmigaDOS has to know where to look to find them. This is done by ASSIGNING each logical device to a particular directory. When you first boot up with the Workbench disk, the "C:" DEVICE is assigned to the "C" DIRECTORY on the Workbench disk. This is a little confusing because the device and the directory happen to have the same name - but they don't necessarily have to. You could ASSIGN the C: device to a directory named "Widget" if you felt like it - then AmigaDOS would automatically look in the Widget directory to interpret each CLI command. In a similar fashion, AmigaDOS looks for the FONTS: device whenever a program requests a new text font. Again, this happens to be assigned to the Fonts directory on the Workbench disk. Below is a list of some AmigaDOS logical devices. Remember that most of these can be specified in the same way as physical device names. SYS: (The System disk - initially, the root directory of the disk you booted with; can be reassigned to any other disk or directory. Some programs will make file accesses to to the SYS: device.) C: (The AmigaDOS CLI Command library - contains the code to execute all CLI commands. Initially assigned to the SYS:C directory. In fact, a quick way to list the available CLI commands is to issue the command DIR C). Note that AmigaDOS always looks for the command file in your current directory first, and then goes to the C: device if it cannot find the command file in the current directory.) L: (The Library directory -contains certain large programs used by AmigaDOS uses for disk drive, memory, and peripheral control.) S: (The Sequence library - contains command sequence files that can be called by the EXECUTE and RUN commands. If you issue the command "EXECUTE CmdFile1", AmigaDOS will look in the current directory first for the file "CmdFile1", and then will go to the S: device (initially assigned to the S directory) if it cannot find it.) LIBS: (Contains various program utilities, such as floating-point mathematical function libraries and and the English text-to-phoneme translator used for computer speech.) DEVS: (Contains program code for handling various physical devices, such as the serial port, the parallel port, and the printer device. See explanation of physical devices above.) FONTS: (Contains program code for displaying the various text fonts, which are accessible from word processors, Notepad, and other programs. That's about as far as we want to go with our "introduction" to AmigaDOS - you are strongly encouraged to read the AmigaDOS manual for further details. Enjoy your experimentation, and come to the club meetings to ask and/or answer any specific questions!