computers 1st sem notes

September 5, 2017 | Author: Sugandha Agarwal | Category: Central Processing Unit, Computer Data Storage, Random Access Memory, Read Only Memory, Instruction Set
Share Embed Donate


Short Description

it contains all the notes related to the computers application of 1st sem in MBA...

Description

Computers types

I, Computer: Definition A computer is a machine that can be programmed to manipulate symbols. Its principal characteristics are: It responds to a specific set of instructions in a well-defined manner. It can execute a prerecorded list of instructions (a program). It can quickly store and retrieve large amounts of data. Therefore computers can perform complex and repetitive procedures quickly, precisely and reliably. Modern computers are electronic and digital. The actual machinery (wires, transistors, and circuits) is called hardware; the instructions and data are called software. All general-purpose computers require the following hardware components: Central processing unit (CPU): The heart of the computer, this is the component that actually executes instructions organized in programs ("software") which tell the computer what to do. Memory (fast, expensive, short-term memory): Enables a computer to store, at least temporarily, data, programs, and intermediate results. Mass storage device (slower, cheaper, long-term memory): Allows a computer to permanently retain large amounts of data and programs between jobs. Common mass storage devices include disk drives and tape drives. Input device: Usually a keyboard and mouse, the input device is the conduit through which data and instructions enter a computer. Output device: A display screen, printer, or other device that lets you see what the computer has accomplished. In addition to these components, many others make it possible for the basic components to work together efficiently. For example, every computer requires a bus that transmits data from one part of the computer to another.

II, Computer sizes and power Personal Computers Least powerful

Workstations

Minicomputer s

Mainframes

Supercomputers Most powerful

Computers can be generally classified by size and power as follows, though there is considerable overlap: Personal computer: A small, single-user computer based on a microprocessor. Workstation: A powerful, single-user computer. A workstation is like a personal computer, but it has a more powerful microprocessor and, in general, a higher-quality monitor. Minicomputer: A multi-user computer capable of supporting up to hundreds of users simultaneously. Mainframe: A powerful multi-user computer capable of supporting many hundreds or thousands of users simultaneously. Supercomputer: An extremely fast computer that can perform hundreds of millions of instructions per second.

Supercomputer and Mainframe Supercomputer is a broad term for one of the fastest computers currently available. Supercomputers are very expensive and are employed for specialized applications that require immense amounts of mathematical calculations (number crunching). For example, weather forecasting requires a supercomputer. Other uses of supercomputers scientific simulations, (animated) graphics, fluid dynamic calculations, nuclear energy research, electronic design, and analysis of geological data (e.g. in petrochemical prospecting). Perhaps the best known supercomputer manufacturer is Cray Research.

Mainframe was a term originally referring to the cabinet containing the central processor unit or "main frame" of a room-filling Stone Age batch machine. After the emergence of smaller "minicomputer" designs in the early 1970s, the traditional big iron machines were described as "mainframe computers" and eventually just as mainframes. Nowadays a Mainframe is a very large and expensive computer capable of supporting hundreds, or even thousands, of users simultaneously. The chief difference between a supercomputer and a mainframe is that a supercomputer channels all its power into executing a few programs as fast as possible, whereas a mainframe uses its power to execute many programs concurrently. In some ways, mainframes are more powerful than supercomputers because they support more simultaneous programs. But supercomputers can execute a single program faster than a mainframe. The distinction between small mainframes and minicomputers is vague, depending really on how the manufacturer wants to market its machines.

Minicomputer It is a midsize computer. In the past decade, the distinction between large minicomputers and small mainframes has blurred, however, as has the distinction between small minicomputers and workstations. But in general, a minicomputer is a multiprocessing system capable of supporting from up to 200 users simultaneously. Workstation It is a type of computer used for engineering applications (CAD/CAM), desktop publishing, software development, and other types of applications that require a moderate amount of computing power and relatively high quality graphics capabilities. Workstations generally come with a large, high-resolution graphics screen, at large amount of RAM, built-in network support, and a graphical user interface. Most workstations also have a mass storage device such as a disk drive, but a special type of workstation, called a diskless workstation, comes without a disk drive. The most common operating systems for workstations are UNIX and Windows NT. Like personal computers, most workstations are single-user computers. However, workstations are typically linked together to form a local-area network, although they can also be used as stand-alone systems.

N.B.: In networking, workstation refers to any computer connected to a local-area network. It could be a workstation or a personal computer.

Personal or micro Computers for personal use come in all shapes and sizes, from tiny PDAs (personal digital assistant) to hefty PC (personal computer) towers. More specialized models are announced each week - trip planners, expense account pads, language translators...

Hand-held (HPC) PDA

Tablet PC

Laptop/Notebook

Types of computer according to technology Hybrid computers are computers that comprise features of analog computers and digital computers. The digital component normally serves as the controller and provides logical operations, while the analog component normally serves as a solver of differential equations. An analog computer (spelled analogue in British English) is a form of computer that uses electrical[1], mechanical or hydraulic phenomena to model the problem being solved. More generally an analog computer uses one kind of physical quantity to represent the behavior of another physical system, or mathematical function. Modeling a real physical system in a computer is called simulation. A digital system is one that uses discrete words such as electrical voltages, representing numbers or nonnumeric symbols such as letters or icons, for input, processing, transmission, storage, or display, rather than a continuous range of values (ie, as in an analog system). The distinction between "digital" and "analog" can refer to method of input, data storage and transfer, or the internal working of a device. How computers work Main articles: Central processing unit and Microprocessor A general purpose computer has four main sections: the arithmetic and logic unit (ALU), the control unit, the memory, and the input and output devices (collectively termed I/O). These parts are interconnected by busses, often made of groups of wires. The control unit, ALU, registers, and basic I/O (and often other hardware closely linked with these) are collectively known as a central processing unit (CPU). Early CPUs were composed of many separate components but since the mid-1970s CPUs have typically been constructed on a single integrated circuit called a microprocessor. Control unit Main articles: CPU design and Control unit The control unit (often called a control system or central controller) directs the various components of a computer. It reads and interprets (decodes) instructions in the program one by one. The control system decodes each instruction and turns it into a series of control signals that operate the other parts of the

computer.[11] Control systems in advanced computers may change the order of some instructions so as to improve performance. A key component common to all CPUs is the program counter, a special memory cell (a register) that keeps track of which location in memory the next instruction is to be read from.[12] Diagram showing how a particular MIPS architecture instruction would be decoded by the control system. The control system's function is as follows—note that this is a simplified description and some of these steps may be performed concurrently or in a different order depending on the type of CPU: 1. Read the code for the next instruction from the cell indicated by the program counter. 2. Decode the numerical code for the instruction into a set of commands or signals for each of the other systems. 3. Increment the program counter so it points to the next instruction. 4. Read whatever data the instruction requires from cells in memory (or perhaps from an input device). The location of this required data is typically stored within the instruction code. 5. Provide the necessary data to an ALU or register. 6. If the instruction requires an ALU or specialized hardware to complete, instruct the hardware to perform the requested operation. 7. Write the result from the ALU back to a memory location or to a register or perhaps an output device. 8. Jump back to step (1). Since the program counter is (conceptually) just another set of memory cells, it can be changed by calculations done in the ALU. Adding 100 to the program counter would cause the next instruction to be read from a place 100 locations further down the program. Instructions that modify the program counter are often known as "jumps" and allow for loops (instructions that are repeated by the computer) and often conditional instruction execution (both examples of control flow). It is noticeable that the sequence of operations that the control unit goes through to process an instruction is in itself like a short computer program - and indeed, in some more complex CPU designs, there is another yet smaller computer called a microsequencer that runs a microcode program that causes all of these events to happen. Arithmetic/logic unit (ALU) Main article: Arithmetic logic unit The ALU is capable of performing two classes of operations: arithmetic and logic. The set of arithmetic operations that a particular ALU supports may be limited to adding and subtracting or might include multiplying or dividing, trigonometry functions (sine, cosine, etc) and square roots. Some can only operate on whole numbers (integers) whilst others use floating point to represent real numbers—albeit with limited precision. However, any computer that is capable of performing just the simplest operations can be programmed to break down the more complex operations into simple steps that it can perform. Therefore, any computer can be programmed to perform any arithmetic operation—although it will take more time to do so if its ALU does not directly support the operation. An ALU may also compare numbers and return boolean truth values (true or false) depending on whether one is equal to, greater than or less than the other ("is 64 greater than 65?"). Logic operations involve Boolean logic: AND, OR, XOR and NOT. These can be useful both for creating complicated conditional statements and processing boolean logic. Superscalar computers contain multiple ALUs so that they can process several instructions at the same time. Graphics processors and computers with SIMD and MIMD features often provide ALUs that can perform arithmetic on vectors and matrices. Memory Main article: Computer storage

Magnetic core memory was popular main memory for computers through the 1960s until it was completely replaced by semiconductor memory. A computer's memory can be viewed as a list of cells into which numbers can be placed or read. Each cell has a numbered "address" and can store a single number. The computer can be instructed to "put the number 123 into the cell numbered 1357" or to "add the number that is in cell 1357 to the number that is in cell 2468 and put the answer into cell 1595". The information stored in memory may represent practically anything. Letters, numbers, even computer instructions can be placed into memory with equal ease. Since the CPU does not differentiate between different types of information, it is up to the software to give significance to what the memory sees as nothing but a series of numbers. In almost all modern computers, each memory cell is set up to store binary numbers in groups of eight bits (called a byte). Each byte is able to represent 256 different numbers; either from 0 to 255 or -128 to +127. To store larger numbers, several consecutive bytes may be used (typically, two, four or eight). When negative numbers are required, they are usually stored in two's complement notation. Other arrangements are possible, but are usually not seen outside of specialized applications or historical contexts. A computer can store any kind of information in memory as long as it can be somehow represented in numerical form. Modern computers have billions or even trillions of bytes of memory. The CPU contains a special set of memory cells called registers that can be read and written to much more rapidly than the main memory area. There are typically between two and one hundred registers depending on the type of CPU. Registers are used for the most frequently needed data items to avoid having to access main memory every time data is needed. Since data is constantly being worked on, reducing the need to access main memory (which is often slow compared to the ALU and control units) greatly increases the computer's speed. Computer main memory comes in two principal varieties: random access memory or RAM and read-only memory or ROM. RAM can be read and written to anytime the CPU commands it, but ROM is pre-loaded with data and software that never changes, so the CPU can only read from it. ROM is typically used to store the computer's initial start-up instructions. In general, the contents of RAM is erased when the power to the computer is turned off while ROM retains its data indefinitely. In a PC, the ROM contains a specialized program called the BIOS that orchestrates loading the computer's operating system from the hard disk drive into RAM whenever the computer is turned on or reset. In embedded computers, which frequently do not have disk drives, all of the software required to perform the task may be stored in ROM. Software that is stored in ROM is often called firmware because it is notionally more like hardware than software. Flash memory blurs the distinction between ROM and RAM by retaining data when turned off but being rewritable like RAM. However, flash memory is typically much slower than conventional ROM and RAM so its use is restricted to applications where high speeds are not required.[13] In more sophisticated computers there may be one or more RAM cache memories which are slower than registers but faster than main memory. Generally computers with this sort of cache are designed to move frequently needed data into the cache automatically, often without the need for any intervention on the programmer's part. Input/output (I/O) Main article: Input/output

Hard disks are common I/O devices used with computers. I/O is the means by which a computer receives information from the outside world and sends results back. Devices that provide input or output to the computer are called peripherals. On a typical personal computer, peripherals include input devices like the keyboard and mouse, and output devices such as the display and printer. Hard disk drives, floppy disk drives and optical disc drives serve as both input and output devices. Computer networking is another form of I/O. Often, I/O devices are complex computers in their own right with their own CPU and memory. A graphics processing unit might contain fifty or more tiny computers that perform the calculations necessary to display 3D graphics. Modern desktop computers contain many smaller computers that assist the main CPU in performing I/O. Registers are fast memory, almost always connected to circuitry that allows various arithmetic, logical, control, and other manipulations, as well as possibly setting internal flags. Most early computers had only one data register that could be used for arithmetic and logic instructions. Data registers are used for temporary scratch storage of data, as well as for data manipulations (arithmetic, logic, etc.). In some processors, all data registers act in the same manner, while in other processors different operations are performed are specific registers. Address registers store the addresses of specific memory locations. Often many integer and logic operations can be performed on address registers directly (to allow for computation of addresses). Personal computer: It can be defined as a small, relatively inexpensive computer designed for an individual user. In price, personal computers range anywhere from a few hundred pounds to over five thousand pounds. All are based on the microprocessor technology that enables manufacturers to put an entire CPU on one chip. Businesses use personal computers for word processing, accounting, desktop publishing, and for running spreadsheet and database management applications. At home, the most popular use for personal computers is for playing games and recently for surfing the Internet. Personal computers first appeared in the late 1970s. One of the first and most popular personal computers was the Apple II, introduced in 1977 by Apple Computer. During the late 1970s and early 1980s, new models and competing operating systems seemed to appear daily. Then, in 1981, IBM entered the fray with its first personal computer, known as the IBM PC. The IBM PC quickly became the personal computer of choice, and most other personal computer manufacturers fell by the wayside. P.C. is short for personal computer or IBM PC. One of the few companies to survive IBM' s onslaught was Apple Computer, which remains a major player in the personal computer marketplace. Other companies adjusted to IBM' s dominance by building IBM clones, computers that were internally almost the same as the IBM PC, but that cost less. Because IBM clones used the same microprocessors as IBM PCs, they were capable of running the same software. Over the years, IBM has lost much of its influence in directing the evolution of PCs. Therefore after the release of the first PC by IBM the term PC increasingly came to mean IBM or IBMcompatible personal computers, to the exclusion of other types of personal computers, such as Macintoshes. In recent years, the term PC has become more and more difficult to pin down. In general, though, it applies to any personal computer based on an Intel microprocessor, or on an Intel-compatible microprocessor. For nearly every other component, including the operating system, there are several options, all of which fall under the rubric of PC

Today, the world of personal computers is basically divided between Apple Macintoshes and PCs. The principal characteristics of personal computers are that they are single-user systems and are based on microprocessors. However, although personal computers are designed as single-user systems, it is common to link them together to form a network. In terms of power, there is great variety. At the high end, the distinction between personal computers and workstations has faded. High-end models of the Macintosh and PC offer the same computing power and graphics capability as low-end workstations by Sun Microsystems, Hewlett-Packard, and DEC.

III, Personal Computer Types Actual personal computers can be generally classified by size and chassis / case. The chassis or case is the metal frame that serves as the structural support for electronic components. Every computer system requires at least one chassis to house the circuit boards and wiring. The chassis also contains slots for expansion boards. If you want to insert more boards than there are slots, you will need an expansion chassis, which provides additional slots. There are two basic flavors of chassis designs–desktop models and tower models– but there are many variations on these two basic types. Then come the portable computers that are computers small enough to carry. Portable computers include notebook and subnotebook computers, hand-held computers, palmtops, and PDAs. Tower model The term refers to a computer in which the power supply, motherboard, and mass storage devices are stacked on top of each other in a cabinet. This is in contrast to desktop models, in which these components are housed in a more compact box. The main advantage of tower models is that there are fewer space constraints, which makes installation of additional storage devices easier. Desktop model A computer designed to fit comfortably on top of a desk, typically with the monitor sitting on top of the computer. Desktop model computers are broad and low, whereas tower model computers are narrow and tall. Because of their shape, desktop model computers are generally limited to three internal mass storage devices. Desktop models designed to be very small are sometimes referred to as slimline models. Notebook computer An extremely lightweight personal computer. Notebook computers typically weigh less than 6 pounds and are small enough to fit easily in a briefcase. Aside from size, the principal difference between a notebook computer and a personal computer is the display screen. Notebook computers use a variety of techniques, known as flat-panel technologies, to produce a lightweight and non-bulky display screen. The quality of notebook display screens varies considerably. In terms of computing power, modern notebook computers are nearly equivalent to personal computers. They have the same CPUs, memory capacity, and disk drives. However, all this power in a small package is expensive. Notebook computers cost about twice as much as equivalent regular-sized computers. Notebook computers come with battery packs that enable you to run them without plugging them in. However, the batteries need to be recharged every few hours. Laptop computer A small, portable computer -- small enough that it can sit on your lap. Nowadays, laptop computers are more frequently called notebook computers. The Five Generations of Computers The history of computer development is often referred to in reference to the different generations of computing devices. Each generation of computer is characterized by a major technological development that fundamentally changed the way computers operate, resulting in increasingly smaller, cheaper, more powerful and more efficient and reliable devices. Read about each generation and the developments that led to the current devices that we use today.

First Generation 1940-1956: Vacuum Tubes The first computers used vacuum tubes for circuitry and magnetic drums for memory, and were often enormous, taking up entire rooms. They were very expensive to operate and in addition to using a great deal of electricity, generated a lot of heat, which was often the cause of malfunctions. First generation computers relied on machine language to perform operations, and they could only solve one problem at a time. Input was based on punched cards and paper tape, and output was displayed on printouts. The UNIVAC and ENIAC computers are examples of first-generation computing devices. The UNIVAC was the first commercial computer delivered to a business client, the U.S. Census Bureau in 1951. Second Generation 1956-1963: Transistors Transistors replaced vacuum tubes and ushered in the second generation of computers. The transistor was invented in 1947 but did not see widespread use in computers until the late 50s. The transistor was far superior to the vacuum tube, allowing computers to become smaller, faster, cheaper, more energy-efficient and more reliable than their first-generation predecessors. Though the transistor still generated a great deal of heat that subjected the computer to damage, it was a vast improvement over the vacuum tube. Secondgeneration computers still relied on punched cards for input and printouts for output. Second-generation computers moved from cryptic binary machine language to symbolic, or assembly, languages, which allowed programmers to specify instructions in words. High-level programming languages were also being developed at this time, such as early versions of COBOL and FORTRAN. These were also the first computers that stored their instructions in their memory, which moved from a magnetic drum to magnetic core technology. The first computers of this generation were developed for the atomic energy industry. Third Generation 1964-1971: Integrated Circuits The development of the integrated circuit was the hallmark of the third generation of computers. Transistors were miniaturized and placed on silicon chips, called semiconductors, which drastically increased the speed and efficiency of computers. Instead of punched cards and printouts, users interacted with third generation computers through keyboards and monitors and interfaced with an operating system, which allowed the device to run many different applications at one time with a central program that monitored the memory. Computers for the first time became accessible to a mass audience because they were smaller and cheaper than their predecessors. Fourth Generation 1971-Present: Microprocessors The microprocessor brought the fourth generation of computers, as thousands of integrated circuits were built onto a single silicon chip. What in the first generation filled an entire room could now fit in the palm of the hand. The Intel 4004 chip, developed in 1971, located all the components of the computer - from the central processing unit and memory to input/output controls - on a single chip. In 1981 IBM introduced its first computer for the home user, and in 1984 Apple introduced the Macintosh. Microprocessors also moved out of the realm of desktop computers and into many areas of life as more and more everyday products began to use microprocessors. As these small computers became more powerful, they could be linked together to form networks, which eventually led to the development of the Internet. Fourth generation computers also saw the development of GUIs, the mouse and handheld devices. Fifth Generation Present and Beyond: Artificial Intelligence Fifth generation computing devices, based on artificial intelligence, are still in development, though there are some applications, such as voice recognition, that are being used today. The use of parallel processing and superconductors is helping to make artificial intelligence a reality. Quantum computation and molecular and nanotechnology will radically change the face of computers in years to come. The goal of fifth-generation computing is to develop devices that respond to natural language input and are capable of learning and selforganization. An Introduction to DOS

Introduction

With the advent of graphical user interfaces (GUIs) like Microsoft Windows, the idea of actually using a command line prompt and typing in commands at the keyboard strikes many people as quite old-fashioned. Why go to the trouble to memorise commands and their syntax when you can just select them from menus, fill in dialog boxes with parameters, or drag files onto application icons? In fact, there are many things that are easier to do from a command prompt than in a GUI; how easy is it in a GUI to rename all files with a ".cxx" extension so that they have a ".cpp" extension instead? Anyway, let' s begin at the beginning. DOS stands for "Disk Operating System", and is a generic name for the basic IBM PC operating system. Several variants of DOS are available, including Microsoft' s version of DOS (MS-DOS), IBM' s version (PC-DOS), and several others. There' s even a free version of DOS called OpenDOS included on this CD. There are actually several levels to DOS. At the lowest level is the BIOS (Basic Input/Output System) which is responsible for managing devices like the keyboards and disk drives at the simplest possible level (e.g. the BIOS lets you say things like "get me sector 5 of track 3 from disk drive 1"). This is done partly by software in ROM (read-only memory) and partly by BIOS extensions which are loaded when the system first starts up (with MS-DOS, these are in a file called IO.SYS; on PC-DOS they' re in IBMBIO.COM). The second layer provides a set of higher level services implemented using the low-level BIOS services; you can now refer to disk drive 1 as "drive A:" and instead of referring to specific sectors or tracks you can refer to files by name (e.g. LETTER.TXT). You can also treat devices as if they were named files, so that for example you can use the name PRN: to refer to the printer. In other words, this level provides a file system (you can refer to files by name and let DOS worry about translating the name into a physical location) as well as some device independence (you don' t have to differentiate storing text in a file from sending it to the printer). This layer of the system is implemented by another file which is loaded when the system first starts up (the file is called MSDOS.SYS on MS-DOS systems, and IBMDOS.COM on PC-DOS systems). The third layer is the command interpreter (or shell), which is what most people think of as DOS (it' s not, but it' s what you interact with when you use the computer, so it' s an understandable confusion). This is contained in another file called COMMAND.COM, which is just an ordinary program that is started automatically (and you can replace it with something better, for example 4DOS, a shareware shell included on this CD). The shell' s job is to display a command prompt on the screen to let you know you' re supposed to type something, then to read a line of text that you type, and to interpret it as a command, which usually involves loading another program into memory and running it. When it' s finished doing this, it displays another prompt and waits for you to type in another command. The file system Before we go any further, it would be a good idea to look at the DOS file system. The file system lets us store information in named files. You can call a file anything you like which might help you remember what it contains as long as you follow certain basic rules: 1. File names can be up to 8 characters long. You can use letters and digits but only a few punctuation marks (! $ % # ~ @ - ( ) _ { }). You can' t exceed 8 characters or use spaces or characters like * or ? or +. Names are case-insensitive, i.e. it doesn' t matter whether you use capitals or lowercase letters; "A" and "a" are treated as the same thing. 2. File names can also have an extension of up to three characters which describes the type of file. There are some standard extensions, but you don' t have to use them. Examples include COM and EXE for executable programs, TXT for text files, BAK for backup copies of files, or CPP for C++ program files. The extension is separated by a dot from the rest of the filename. For example, a file called FILENAME.EXT has an 8-character name (FILENAME) followed by a threecharacter extension (.EXT). You could also refer to it as filename.txt since case doesn' t matter, but I' m going to use names in capitals for emphasis throughout this document. Files are stored in directories; a directory is actually just a special type of file which holds a list of the files within it. Since a directory is a file, you can have directories within directories. Directory names also follow the same naming rules as other files, but although they can have an extension they aren' t normally given one (just an 8-character name). The system keeps track of your current directory, and if you just refer to a file using a name like FILENAME.EXT it' s assumed you mean a file of that name in the current directory. You can specify a pathname to identify a file which includes the directory name as well; the directory is separated from the

rest of the name by a backslash ("\"). For example, a file called LETTER1.TXT in a directory called LETTERS can be referred to as LETTERS\LETTER1.TXT (assuming that the current directory contains the LETTERS directory as a subdirectory). If LETTERS contains a subdirectory called PERSONAL, which in turn contains a file called DEARJOHN.TXT, you would refer to this file as LETTERS\PERSONAL\DEARJOHN.TXT (i.e. look in the LETTERS directory for PERSONAL\DEARJOHN.TXT, which in turn involves looking in the PERSONAL subdirectory for the file DEARJOHN.TXT). Every disk has a root directory which is the main directory that everything else is part of. The root directory is called "\", so you can use absolute pathnames which don' t depend on what your current directory is. A name like \LETTERS\LETTER1.TXT always refers to the same file regardless of which directory you happen to be working in at the time; the "\" at the beginning means "start looking in the root directory", so \LETTERS\LETTER1.TXT means "look in the root directory of the disk for a subdirectory called LETTERS, then look in this subdirectory for a file called LETTER1.TXT". Leaving out the "\" at the beginning makes this a relative pathname whose meaning is relative to the current directory at the time. If you want to refer to a file on another disk, you can put a letter identifying the disk at the beginning of the name separated from the rest of the name by a colon (":"). For example, A:\LETTER1.TXT refers to a file called LETTER1.TXT in the root directory of drive A. DOS keeps track of the current directory on each disk separately, so a relative pathname like A:LETTER1.TXT refers to a file called LETTER1.TXT in the currently-selected directory on drive A. For convenience, all directories (except root directories) contain two special names: "." refers to the directory itself, and ".." refers to the parent directory (i.e. the directory that contains this one). For example, if the current directory is \LETTERS\PERSONAL, the name ".." refers to the directory \LETTERS, "..\BUSINESS" refers to \LETTERS\BUSINESS, and "..\.." refers to the root directory "\". Simple commands If you start up a computer running DOS (or select the "MS-DOS Prompt" icon in Windows), after a bit of initialisation you will end up with a prompt to let you know that the command interpreter is waiting for you to type in a command. The prompt might look like this: C> This prompt consists of the name of the current disk that you' re using (A for the main floppy disk drive, B for the secondary floppy disk, C for the primary hard disk drive, and so on) followed by ">". You can get a list of the files in the current directory on that disk by typing the command DIR (short for "directory"): C>DIR (The text in bold above indicates what you type in.) When you press the ENTER key, a list of files will be displayed on the screen, together with their sizes and the dates when they were last modified. If you want to see a list of the files on disk in the main floppy drive (drive A), you can do it by first selecting A as the current drive: C>A: Just type the letter of the drive you want to select followed by a colon, and then press ENTER. The prompt will then appear like this: A> and you can then type DIR as before: A>DIR Alternatively, you can specify the directory you want to list as a parameter separated by one or more spaces from the command name: C>DIR A: which lists the contents of the current directory on drive A, or C>DIR A:\ which lists the root directory of drive A, or C>DIR .. which lists the directory above the one you' re currently in. Note that for convenience you can arrange matters so the prompt tells you the current directory as well as the currently-selected disk drive, so that it might appear like this: C:\WINDOWS>

meaning that C:\WINDOWS is the current directory. Now imagine that you type "DIR ..": C:\WINDOWS>DIR .. You should be able to see that this will list the contents of C:\, i.e. the root directory on drive C. (From now on I won' t show the prompt in my examples, only what you need to type in.) The trouble with a command like DIR is that the list of files scrolls off the screen if there are more than a few files in the directory. Most commands have a set of options that you can use to modify their behaviour, which are specified after the command name and separated from it by a slash "/"; the DIR command has a /P (pause) option which makes it pause after each full screen of output, and waits for you to press a key before displaying the next screenful. Most commands support a "help" option called "/?"; typing DIR/? will give you a brief list of the options that DIR recognises, for instance. Some common commands Here' s a list of some common commands and what they do: X: -- select X: as the current drive DIR -- list the current directory DIR directory -- list the specified directory CLS -- clear the screen CD directory -- change current directory to directory TYPE file -- display specified file on the screen COPY file1 file2 -- copy the first file to the second COPY file directory -- copy the file to the specified directory DEL file -- delete the specified file EDIT file -- edit the specified file REN file newname -- rename file to newname FORMAT drive -- format the disk in the specified drive MD directory -- make a new directory called directory RD directory -- remove the specified directory (which must be empty) In the list above, file (or file1 or file2) is the pathname of a file, directory is the pathname of a directory and drive is the name of a disk drive (e.g. A: or C:). In the case of the REN (rename) command, newname is the new file name (not a path name because this just renames the file, it can' t move the file to a new directory). Wildcards In some situations it' s useful to be able to specify sets of files to be operated on by a single command. For example, you might want to delete all files with the extension ".TXT". You can do this like so: DEL *.TXT The star "*" matches any name at all. You can read it as "anything .TXT", although if I had to read this command out loud I' d probably say "del star-dot-text". Anyway, what it means is that any file whose name matches the pattern *.TXT (any file with a .TXT extension) will be deleted. You can do more sophisticated things: COPY NOTE*.TXT NOTES will copy any file whose name begins with NOTE (i.e. NOTE followed by anything) and has a .TXT extension to the NOTES subdirectory. The star is referred to as a wildcard by analogy with the role of a Joker in some card games, where the Joker can be used as any other card. The command DEL *.* will delete all the files in the current directory (all files with any name and any extension). Since this is obviously risky, you' ll be prompted with a message that says "Are you sure (Y/N)?". If you are sure, type Y for "yes"; if not type N for "no". A non-obvious use of this technique is allowed by the REN (rename) command: REN *.TXT *.LST will rename all files with a .TXT extension to files with the same name but a .LST extension instead. A limitation of this technique is that you can only use a star as a wildcard at the end of the name or extension part of a filename; you might think that you could delete all files whose name ends with X like this: DEL *X.*

Unfortunately this has the same effect as DEL *.* since the star matches everything up to the end of the name, and the X after that is just ignored. You can use a question mark to match a single character: DEL ?X.* This will match any file whose name consists of any single character followed by an X with any extension. To delete any files whose name ends with X would actually require a whole sequence of commands: DEL X.* DEL ?X.* DEL ??X.* DEL ???X.* DEL ????X.* DEL ?????X.* DEL ??????X.* DEL ???????X.* This deletes all files whose name is X, then all files whose name is any one character followed by X, then all files whose name is any two characters followed by X, and so on up to any seven characters followed by X. Redirecting input and output One nice thing about using a command prompt rather than a GUI is that it' s much simpler to capture the output of a program in a file, or take the input for a program from somewhere other than the keyboard. All programs have a number of standard input/output channels, of which the most important are the standard input (normally the keyboard) and the standard output (normally the screen). There is also a standard error output which is also associated with the screen (and is intended for displaying error messages). A few programs write their output directly to the screen (or elsewhere) but in many cases they will write results to the standard output. If you don' t do anything unusual, this will be the screen. However, you can associate the standard output with a file instead of the screen so that when the program writes anything to the standard input, it' ll end in the file you' ve specified rather than being displayed on the screen. All you have to do is specify "> filename" on the command line and the standard output will be routed to the file filename instead of the screen. For example, DIR displays a directory listing on the screen, but DIR >DIRLIST.TXT puts the directory listing in a file called DIRLIST.TXT, and doesn' t display anything on the screen. (Read the ">" out loud as "to"; "dir to dirlist-dot-text".) If the file already exists, doing this will overwrite the existing contents. If you don' t want this to happen, use ">>" instead of ">". This will append the program' s output to the existing contents of the file rather than destroying it: DIR >>DIRLIST.TXT This has the same effect as before, except that if the file DIRLIST.TXT already exists, the program' s output will be tacked on to the end of it rather than replacing it. The standard input can be redirected using "
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF