Sections:
Updated: 4/16/2012
Learning objective: Identify common DOS commands
As you go through this unit, keep in mind that we are not learning MS-DOS but the command line interface of Windows which is *based* on MS-DOS. The commands and concepts of the command line interface (CLI) of Windows are based on the use of MS-DOS commands for backwards compatibility. The more you know about MS-DOS, the better prepared you will be to understand the CLI of Windows.
In the personal computer operating systems MS-DOS and PC DOS, a number of standard system commands were provided for common tasks such as listing files on a disk or moving files. Some commands were built-in to the command interpreter, others existed as transient commands loaded into memory when required. Over the several generations of MS-DOS, commands were added for the additional functions of the operating system. In the current Microsoft Windows operating system a text-mode command prompt window can still be used. Some DOS commands carry out functions equivalent to those in a UNIX system but always with differences in details of the function. [Wikipedia]
NOTE: In the CLI mode, any command can be used anytime anywhere if you know the correct drive and path! If the command is executed correctly, there will be no message presented on the command line for most commands. The CLI is like many jobs I have had, if you do good, no comments, if you do bad, you get yelled at. The CLI is similar, it will give error messages if a command is unsuccessful or not recognized.
Mark's top ten DOS commands.
In general, most commands do one simple thing, like copy a file. The trick to using the CLI is thinking about what you want to accomplish and then using the right commands in the right sequence with the best possible paths. Should they be relative or absolute? It is not uncommon to get "writer's block" when first starting with CLI since most ideas will be a collection of CLI commands and paths.
FORMAT, CHKDSK
For storage management, I suggest you study FORMAT and CHKDSK. FORMAT prepares a storage device for use and CHKDSK verifies the integrity of the storage device.
MD, CD, RD
For path management, I suggest you study MD, CD, and RD. MD creates directories, CD allows you to change your working directory, and RD allows you to delete a directory.
DIR, COPY, REN, DEL, TYPE
And for file management, I suggest you study DIR, COPY, REN, DEL, and TYPE. These commands allow you to view what files are available, copy then to another location, rename them, delete them, and view their contents.
Thinking: Why limit it to 10 commands?
Key terms: commands, file, path, storage device
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
DOS Commands @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
DOS Commands @ Wikipedia |
Reload page
Notes:
Learning objective: Explain basic DOS conventions
Basic DOS conventions on using commands include: "COMMAND [object] [/switch]" or "COMMAND object [/switch]". Any object or option are optional when inside [ ]. Mutually exclusive: either a or b, but not both when a | b. Concatenation allows you to add objects together using the plus sign, like "COPY file1+file2+file3 newfile", and Repeatable sequence use the dot dot dot like "file1+file2+..."
COMMAND [object] [/switch]
The object of the command, like a file or drive, is optional. The use of a switch is optional. The DIR command can be used without an object or switch. The default action is a list of the current directory. To see the parent directory with a pause between a screen, the command would be [ DIR .. /P ].
COMMAND object [/switch]
The object of the command, like a file or drive, is required. The use of a switch is optional. The COPY command requires the source object, it is not optional. If the destination is not given, the destination is the working directory.
| : a | b
The "|" pipe represents a mutually exclusive event. You can use only one of a given set. The COPY commands provides a switch for either ASCII or binary copying. You can not use both if you choose to use one.
+ : COPY file1+file2+file3 newfile
The "+" plus suggests concatenation of several files to be combined into one file. The COPY commands allow you to concatenate multiple files into one new one. For example, you could use concatenation to combine the header, body, navigation, and footer files to create a Web page if the body file is the only file changing between pages. This would be done by the developer or just-in-time on the server for each page.
... : file1+file2+...
The "..." ellipse suggests the repetition of a pattern.
Thinking: Is DOS help helpful?
Key terms: /switch, command, concatenate, ellipse, mutually exclusive, object, syntax
Notes:
Learning objective: Explain the purpose of the FORMAT command
The FORMAT command formats a disk with FAT and sectors. In most cases, this should only be used on floppy drives or other removable media. This command can erase everything on the storage device. A unique serial number will be created for storage device after formatting.
Format is a command-line utility included in Microsoft DOS, IBM OS/2 and Microsoft Windows operating systems to produce disk formatting. The command will perform the following actions by default on a floppy drive, hard drive, solid-states (USB), or other magnetic medium. It will not perform this function on optical media.
Optionally, (by adding /S, for "system") it can also install a volume boot record. When this option is included, bootstrap code is written to the first sector of the volume (and possibly elsewhere as well). FORMAT always writes a BIOS Parameter Block to the first sector, with or without the /S option. Another option ( /Q) allows for what Microsoft calls "Quick Format". With this option the command will not do the 2nd and 3rd step, above. Data previously written to the media will not be altered by the command. [Wikipedia]
/V:label give volume a name
This option will allow you to give a meaningful name to a storage device. If a label is not given, a random name/number is generated. Example: FORMAT D: /V:My_DATA
/Q quick format
This option resets the FAT as empty and leaves the sectors alone. As new data is added to the device, existing sectors are rewritten with new data. Example: FORMAT D: /Q
/A:size change the size of the sectors
This option will allow you to change how large the sectors are to be set. The default size is 512 bytes. If you are using a system primarily for video editing, a sector size of 4096 bytes may be a better fit to increase I/O speeds. Example: FORMAT D: /A:4096
Thinking: Why would you want to format a storage device other than the default 512 bytes per secotr?
Key terms: FAT, FORMAT, root, sector, sector, serial number
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
FORMAT @ EasyDOS
FORMAT @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
FORMAT @ EasyDOS |
Reload page
FORMAT @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the FORMAT command
Example of how to use the FORMAT command. The most common switches are "/V" switch to give the disk a name and "/Q" switch to perform a quick format which usually just erases the file allocation table.
FORMAT E: /V:My_Data
This command will format the "E:" drive with a name of "My_Data".
Serial number
Note the serial number of the device gives each device a unique identification number. If you switch devices without mounting/unmounting the device, like a USB drive, the system will recognize that serial number in memory managing the FAT doesn't match the serial number of the storage device and system will ask you to place the correct device into the port before engaging in any more activity. Removing a storage device without unmounting it will also generate a warning message since the device serial number is no longer available to the OS for managing the FAT. In some situations, data may be lost if the data in memory has not been written to drive and the FAT updated for future use.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the CHKDSK command
The CHKDSK command checks the health of a disk depending on what version of Windows you are using. It is useful for troubleshooting storage device errors. CHKDSK has surface scan and bad cluster detection functionality built in on Windows NT based operating systems. If a user is experiencing issues with a storage device, like a USB drive, the first thing you may want to do is check the viability of the device with CHKDSK or SCANDISK.
CHKDSK (short for "check disk") is a command on computers running DOS, OS/2 and Microsoft Windows operating systems that displays the file system integrity status of hard disks and floppy disk and can fix logical file system errors. It is similar to the fsck command in Unix. The command is implemented as an executable program file, CHKDSK.EXE. Different operating systems all use the same filename, but the files are not necessarily compatible between operating systems. On computers running NT-based versions of Windows, CHKDSK can also check the disk surface for physical errors or bad sectors, a task previously done by SCANDISK. This version of CHKDSK can also handle some physical errors and recover data that is still readable. [Wikipedia]
CHKDSK /F (fix errors)
Fixes errors on the volume. The volume must be locked. If CHKDSK cannot lock the volume, it offers to check it the next time the computer starts. [Wikipedia] Example: CHKDSK D: /F
CHKDSK /R (recovers readable information)
Locates bad sectors and recovers readable information (implies /F and /P). Unreadable data is lost. If CHKDSK cannot lock the volume, it offers to check it the next time the computer starts. [Wikipedia] Example: CHKDSK D: /R
Thinking: If there are issues with a storage device, should CHKDSK be used first or as a last resort?
Key terms: FAT, sector, volume
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
CHKDSK @ EasyDOS
CHKDSK @ Wikipeda
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
CHKDSK @ EasyDOS |
Reload page
CHKDSK @ Wikipeda |
Reload page
Notes:
Learning objective: Demonstrate the use of the CHKDSK command
If you specify the /F option, the program will correct non-contiguous errors when it finds them. These errors can be accidentally created due to the fact that DOS does not always store files in one continuous block on the disk. If space is limited on the disk (especially if you have previously erased and replaced files), DOS may store the file in two or more pieces in whatever spaces are available on the disk. If the links between the clusters (blocks of data) are lost, CHKDSK will discover the error and report it. By using the /F option, you tell CHKDSK to find any of these parts of files or programs that have become separated from the rest of the file, to create a new file for each, and to write the lost segment to these files. These new files will all start with the letters FILE and will end with four numbers (starting with 0000) plus a .CHK extension. The first file created will be labeled FILE0000.CHK. [EasyDOS]
CHKDSK E: /F
This command will test the integrity of the E: drive and try to fix any errors it encounters.
Thinking:
Key terms:
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
CHKDSK @ EasyDOS
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
CHKDSK @ EasyDOS |
Reload page
Notes:
Learning objective: Explain the difference between relative or absolute paths
Path commands can be either relative or absolute. If the path starts with a "\" backslash then it's absolute path since it automatically starts from the root. If the path does not start with a "\" backslash then it is relative path based on the location of the current working directory. Thus, it is important that you know and use the existing path. In MS CLI, the current path is usually displayed on the promt. In Linux, the "pwd" will print the current working path to the screen.
Absolute path \ (root)
The path starts at the root when the path starts with a "\" backslash.
Relative path (working directory)
A path is based relative to the working directory. The path does not begin with a "\" backslash. It can use the ".." parent reference to up the tree or the provide a path to continue to go down the tree. You can use them in a combination as long as the paths are available to the tree.
TREE command
The TREE command show the tree structure from the working directory. You can also use relative and absolute references to get a sense of the tree structure of your current location. The command [ TREE \ ] will list all the paths from the root of the current drive. On large storage devices, this can be a long list. The command [ TREE .. ] will show the siblings to your current directory.
Thinking: When should you use either absolute or relative references to manipulate a file or folder?
Key terms: absolute path, parent, path, relative path, root, sibling, tree
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
TREE @ EasyDOS
TREE @ Wikipedia
Naming Files, Paths, and Namespaces @ MSDN
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
TREE @ Wikipedia |
Reload page
Naming Files, Paths, and Namespaces @ MSDN |
Reload page
Notes:
Learning objective: Explain the purpose of the MD command
The MD or MKDIR command creates a directory if one does not already exist on that path with that name. The parent of the directory specified must already exist in older systems. MKDIR is a carryover from the UNIX environment.
MD [x:]path
You can create a new directory on another drive, reference the working directory, or the root.
Thinking: What are some good guidelines in creating folder structures to pass on to users?
Key terms: , directory, path
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
MKDIR @ EasyDOS
MKDIR @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
MKDIR @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the MD command
This example shows how to create a series of nested directories. In XP and Windows 7, you can create a series of directories with one command instead of a series of commands. Note the succession in the creation of the paths.
MD \111
Create the "111" directory from the root. Note the "\" backslash at the start of the path.
MD \111\stuff
The "stuff" directory is created under the existing "111" directory.
MD \111\stuff\backup
The "backup" directory is created under the existing "111\stuff" path.
MD \111\demo
The "demo" directory is created under the existing "111" directory. It is a sibling to the "stuff" directory.
MD \111\demo\backup
The "backup" directory is created under the existing "111\demo" path. Note that both paths end with a "backup" directory. Since the parent paths are different, each absolute path to "backup" is different. Thus, you can have multiple directories with the same name as long as they are not on the same path.
TREE \111
This command will show you the directory structure of the "\111" path.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the CD command
The CD command changes default path to another path or working directory, every drive will always have a working directory. The default working directory is often the root when a drive is mounted. CHDIR is a carryover from the UNIX environment.
CD \ (root)
If a CD command begins with a "\" backslash, the working directory is changed to the root.
CD path
If a CD command does not begin with a "\" backslash, the working directory change to a path below the current working directory assuming the paths are available.
CD .. (parent)
The ".." dot-dot changes the working directory to the parent directory.
CD [drive:][path:] (another drive and/or path)
The CD command will also allow you to change the working directory on another drive without affect the working directory of the drive you are currently using.
Tab key
The tab key will fill out unique names of files and folders once a name has been started. For example, if there is a filename called "Please send Money.doc" and "Pl" is unique to the file, pressing the tab key will complete the file on the command line.
Thinking: Does use the tab key help in targeting files and folders?
Key terms: parent, path, root, working directory
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
CHDIR @ EasyDOS
CHDIR @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
CHDIR @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the CD command
Examples of how to use this command is based on the activities of the MD example in the previous section.
TREE \111
This command will show you the directory structure of the "\111" path.
CD \111
This command will change the working directory to the "111" directory using an absolute reference. No matter what the previous working directory, the new working directory will be the "111" directory.
CD stuff\backup
This command will change the working directory to the "backup" directory using a relative reference assuming the current working directory is the "\111" location.
CD ..
This command will change the working directory to the parent directory. If done from the "\111\stuff\backup" directory, the new working directory will be the "stuff" directory.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the RD command
The RD or RMDIR command deletes an empty directory. The directory must be empty of both files and directories when used without the "/S" switch.
Examples of how to use this command. Before you delete a directory, it must be empty of files and folders. Embedded versions of DOS support the /S switch to delete all the files and folder below the working directory. Doing this from the root can be very dangerous! RMDIR is a carryover from the UNIX environment.
RD path
The command will remove the target directory if the target directory is empty of *all* files and directories. The reference can either be absolute or relative.
RD path /S (removes all files and directories!)
The "/S" switch will remove all the files and directories beneath the target directory. The reference can either be absolute or relative. You will be asked to verify your actions since this switch can be very destructive. This switch is not found on earlier versions of DOS.
RD path /Q (quiet mode!)
The "/Q" switch will assume you want complete an action like "/S" switch without verification. Consider the power of the command [ RM \ /S /Q ]! Delete all files and directories from the root of the current drive without question. (Do *NOT* try this at home or other systems!)
RD [drive:] another drive
The RD command will also allow you to remove a directory on another drive without affect the working directory of the drive you are currently using.
Thinking: How destructive can the RD command be? What are the implications?
Key terms: directory, path, quiet mode
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
RMDIR @ EasyDOS
RMDIR @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
RMDIR @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the RD command
Examples of how to use this command are based on the activities of the RD example above.
RD \111\demo
This command will fail since the "demo" directory is not empty. It contains the "backup" directory. To complete this command the old fashioned way, you would have to delete the "backup" directory first.
RD \111\demo /S
The /S switch allows you deletes all the subdirectories below the target directory. Note the confirmation from the operating system. This command can be very destructive with the "/S" switch!
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the DIR command
The DIR command list the contents of a directory on any drive or path. You can also use wild cards, like "DIR *.txt" to list all the .txt files. The "/W" switch will list the contents in multiple columns if possible. The "/P" switch will pause the screen if needed. There are many other options associated with the DIR command.
* ? (wildcards)
DIR command supports wildcards like "*" asterisk and "?" question mark. The "*" asterisk substitutes for any group of characters. The "?" question mark substitutes for a single character. For example, a pattern of "mo*.com" will display all the file start with "mo" and have an extension of ".com". A pattern of "mo??.com" will display all the file start with "mo" that are four characters in length and have an extension of ".com".
DIR /B (just filename)
This switch will list just filenames in alphabetical order. Try [ DIR c:\windows /B ]
DIR /AD (just directories)
This switch will list just directories. Try [ DIR c:\windows /AD ]
DIR /Ox (name, size, extension)
This switch will list order (sort) by name "/ON", size "/OS", or extension "/OE". There are several other options. If a "-" dash is used, like "/O-N", the results will be in revers order. Try [ DIR c:\windows /O-S ]
DIR /X (short filenames)
This switch will list both the long and short names of files in the directory in most versions of Windows. Try [ DIR c:\windows /X ]
DIR /P (pause display)
This switch will pause the listing on the screen until a key is pressed. Try [ DIR c:\windows /P ]
Thinking: How would an understanding of wildcards help in naming files and folders?
Key terms: bare bones, directory, file, short filename, wildcard
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
DIR @ EasyDOS
DIR @ Wikipedia
Asterisk as wildcard @ Wikipedia
Question mark as wildcard @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
Asterisk as wildcard @ Wikipedia |
Reload page
Question mark as wildcard @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the DIR command
Examples of how to use this command. DIR has many switches! Most of the time you will only use a few like "/P" switch to pause the listing, "/W" switch to display multiple columns, "/B" switch for bare bones or just filenames, or "/ON" switch to sort files by name. Use the ones you need to. Remember, they are all optional!
DIR \111
This command will list all files and directories in the "111" directory.
. (working directory)
The working directory is represented by a single "." dot.
.. (parent directory)
The parent directory is represented by a two ".." dots to let you know you are not at the root.
DIR c:\windows\system32\*.com /P /W
This command will list all the ".com" files with the "*" asterisk in the "system32" directory with the "/W" switch and "/P" switch options. The "/W" switch will show only file names in as many columns as can be displayed. Since there are fewer files that fill the screen, the "/P" switch to pause the screen is not invoked.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the COPY command
The COPY command copies files from one location to another. The destination defaults to the current directory. If multiple source files are indicated, the destination must be a directory, or an error will result. Files may be copied to devices (e.g. "COPY file lpt1") would send the file to the printer on lpt1. "COPY file con" would output to screen, which would be the same as type. Most useful to note that "COPY file.txt+file2.txt file-cat.txt" will concatenate the files and output them as "file-cat.txt".
* ? (wildcards)
COPY command supports wildcards like "*" asterisk and "?" question mark. The "*" asterisk substitutes for any group of characters. The "?" question mark substitutes for a single character. For example, a pattern of "mo*.com" will display all the file start with "mo" and have an extension of ".com". A pattern of "mo??.com" will display all the file start with "mo" that are four characters in length and have an extension of ".com".
+ (concatenate files)
The "+" plus will allow you to concatenate or add two or more files together as indicated by the "..." dot-dot-dot to create a new file. Best to use with the "/A" ASCII switch or "/B" binary depending the type of files being aggregated.
COPY /A (ASCII file)
This copies the text content of the file, stopping when it reaches the EOF character. Use with concatenating text file. Example: "COPY /A doc1.txt+doc2.txt new.txt"
COPY /B (binary file)
This concatenates files in their entirety, ignoring EOF characters. Use with concatenating binary files. Example: "COPY /B image1.jpg+image2.jpg new.png"
CON (console)
CON or console is default input/output device of the CLI. You can also copy to and from the console. If used as the output device, contents will be sent to the monitor. If used as input, the contents will come from the keyboard.
"COPY file con" will copy the contents of a file to the monitor.
"COPY con file" will copy the keyboard entries into memory. When the "Ctrl+Z" is pressed, the keyboard buffer is flushed to file and a end-of-line marker is added. A message of "One file copied" should be seen and then control is passed back to the prompt.
Thinking: What are some instances you may want to concatenate files?
Key terms: concatenation, console, destination, source
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
COPY @ EasyDOS
COPY @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
COPY @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the COPY command
An example of how to use this command. In general, you will most likely use the COPY command without any options. You can also use wild cards to copy a group of files. What you do need to focus on is what this the source and destination. Is it best to use relative paths or absolute paths or a combination? The answer is what works best for you or the situation. (This example assumes you are using the "C:" drive for these activities.)
\ (absolute reference)
Note the path starts with a "\" backslash to reference the root.
*.com (wild card)
The wildcard "*" asterisk is used to copy all the ".com" files
file(s) copied
This will list the files copied which can be used to log an automated event. (More in next unit.) This is one of the few times messages will be posted that are not an error message.
CD \111
Return to your "\111" directory if you not already there.
DIR
Use the DIR command to verify the copied files.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the REN command
The REN or RENAME command renames current filename to a new filename. A common error for new users is to forget the provide an extension for the new filename even if you want the extension to remain the same. To rename a long filename, try putting it in quotes as a delimiter.
REN [drive:][path:]old.txt new.txt (another drive and/or path)
The option allows you to rename a file on another drive and/or path. When renaming a file outside the working directory, you do not need to give the location of the new filename since you are not changing the location of the file, just renaming it.
Thinking: Why should you use delimiters when renaming long filenames?
Key terms: delimiter, extension
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
REN @ EasyDOS
REN @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
Notes:
Learning objective: Demonstrate the use of the REN command
An example of how to use this command. Note that only the current file needed to be referenced using relative or absolute referencing. Notice the quotes around the long filename, which are not required for the short filename.
COPY file
As a safety precaution, copy the file into your "\111" directory.
DIR
Use the DIR command to verify the copied files.
CD \111
Return to your "\111" directory if you not already there.
"long filename"
Note the long filename is inside quotes to delineate the spaces inside the quotes form the spaces used on the command line as object separators.
DIR
Use the DIR command to verify the copied files.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the DEL command
The DEL or ERASE command deletes files. It can be used with wild cards to delete multiple files, so BE CAREFUL!
* ? (wildcards)
DEL command supports wildcards like "*" asterisk and "?" question mark. The "*" asterisk substitutes for any group of characters. The "?" question mark substitutes for a single character. For example, a pattern of "mo*.com" will display all the file start with "mo" and have an extension of ".com". A pattern of "mo??.com" will display all the file start with "mo" that are four characters in length and have an extension of ".com".
DEL *.* (delete all files in directories)
If you try to delete all the files in a directory with the "*.*" option, you will be asked if you want to continue.
DEL /S (removes files in directories)
The "/S" with will remove *all* files in *all* the directories below the target directory starting at the target directory.
DEL *.* /Q (quiet mode)
The "/Q" switch will suspend the "yes/no" questions when used with the "*.*" or the "/S" switch. Consider the command "DEL c:\*.* /S /Q" that will delete all files and folders from the root of the "C:" drive! NOTE: Do *not* try this at home!
Thinking: How much differences it here between the DEL and the RD command?
Key terms: directory, file, quiet mode, wildcard
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
DEL @ EasyDOS
DEL @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
Notes:
Learning objective: Demonstrate the use of the DEL command
An example of how to use this command. It is based on the previous COPY example when "*.com" files were copied to your "\111" directory.
DIR
Use the DIR command to verify the files present.
DEL mo??.com (wildcard)
This command will delete all the files that start with "mo", are four characters long, and have an extension of ".com".
DIR
Use the DIR command to view changes to the files.
DEL *.* (wildcard)
This command will delete all the files. You will be asked to continue.
DIR
Use the DIR command to view changes to the files.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of the TYPE command
The TYPE command displays the contents of a file to the screen. You can not use wildcards with this command.
The TYPE command is actually a variation of the "COPY file con" command discussed above.
TYPE [drive:][path:] (another drive and/or path)
The TYPE command will also allow you to view the contents of a file outside the working directory on another drive without affect the working directory of the drive you are currently using.
Thinking: Why have a TYPE command at all?
Key terms: ASCII, binary, contents
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
TYPE @ EasyDOS
TYPE @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
TYPE @ Wikipedia |
Reload page
Notes:
Learning objective: Demonstrate the use of the TYPE command with an ASCII file
This example shows the content of a ASCII file.
ASCII filter
Since this file is an ASCII file, it is properly processed by the built-in ASCII CLI processor.
Thinking:
Key terms:
Notes:
Learning objective: Demonstrate the use of the TYPE command with an binary file
This example shows the content of a binary file. Note how CLI tries to convert the binary through the ASCII filter.
Binary through ASCII filter
Since this file is an binary file, it is properly processed by the built-in ASCII CLI processor but since it is not ASCII file, all we get is random ASCII conversions that are filtered through the ASCII chart.
Thinking:
Key terms:
Notes:
Learning objective: Explain the purpose of redirection
Redirection sends data to another device other than the console, the screen and keyboard. Redirection use devices like files, CON for console, COM for RS-232 post, and PRN for printer. Redirection is great way to make a log to record what happens during a command, especially in an automated environment. (More in next unit.)
CON (console)
CON or console is default input/output device of the CLI. Without redirection, the default input/output is the console. If used as the output device, contents will be sent to the monitor. If used as input, the contents will come from the keyboard.
> (create output file)
The ">" greater than character sends output to file or specified device, if a file, it will be create or be overwritten.
>> (append output file)
A double set of ">>" greater than characters appends a file, and it will create it if not found.
< (input file)
The "<" less than character sends data into a program from a device or file.
DIR /W > dir.txt (create file)
The output of the DIR command will be redirected to the "dir.txt" file instead of to to the console. You now have a copy of the output that can be printed or saved for future reference! Very helpful in taking a snapshot of the OS before updates or changes are made.
TYPE dir.txt (view file)
Use the TYPE command to view the contents of the file. It should be the same as if the redirection were not used.
Thinking: Why would you want to redirect the output of a command to a file?
Key terms: append, console, input, output
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
Redirection @ Wikipedia
Redirection @ Lagmonster
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
Redirection @ Wikipedia |
Reload page
Redirection @ Lagmonster |
Reload page
Notes:
Learning objective: Explain the purpose of pipes
Sends the output of one command as the input to another command using the "|" pipe character. Not to be confused the pipe used in the syntax of commands like the [ /A | /B ] in the COPY command.
process1 | process2
The output of one process becomes the input for another process by use of the "|" pipe instead of being sent to the console. This assumes the two applications are compatible with piping. Most CLI commands are.
FORMAT /? | MORE
Without the use of the MORE command, the output of "FORMAT /?" would scroll off the screen and you would not see the top portion of the help screen. The MORE command will pause a screen worth of output. Press the enter key to go down a screen and the space bar to go down line by line.
Thinking: Why create applications that are based on piping?
Key terms: CLI, console, process
Resources:
To maximize your learning, please visit these Web sites and review their content
to help reinforce the concepts presented in this section.
Quick links:
Pipe @ Lagmonster
MORE @ Wikipedia
Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.
Pipe @ Lagmonster |
Reload page
MORE @ Wikipedia |
Reload page
Notes: