Basic DOS Commands
DOS (Disk Operation System) is a tool which allows you to control the operation of the IBM PC. DOS is software which was written to control hardware. Here is a summary of some essential DOS commands.
Change Drive
To change the default drive indicated at the DOS prompt, type the letter of the drive followed by a colon (:). For example, to change the drive from "X" to "Y":
X:\> Y: [enter]
Change Directory
Use the CHDIR (CD) command to change the directory. For example, to change the directory from "C:\Programs\folder" to "D:\arcade\folder":
C:\Programs\folder> cd D:\arcade\folder [enter]
Then, to navigate to "digdug", a subdirectory of "D:\arcade\folder":
D:\arcade\folder> cd digdug [enter]
Likewise, "cd .." navigates to the parent directory (i.e., up one level), while "cd \" navigates to the root directory (typically the C drive).
Copy Something
To copy a files or directories in DOS, it is necessary to use the "copy" command. The default drive indicated in the DOS propmpt is of no concern when copying an item. Files or folders may be copied from anywhere to anywhere, regardless of the prompt drive. For example, to copy the file, "pacman.exe" from the directory "D:\arcade" to the directory "C:\programs" (notice that the location indicated for the DOS prompt is different from both the source directory and the copy directory):
C:\different\> copy D:\arcade\pacman.exe C:\programs [enter]
Here, we repeat the previous copy command, while simultaneously renaming the file to "ms-pacman.exe":
C:\different\> copy D:\arcade\pacman.exe C:\programs\ms-pacman.exe [enter]
The copy command may be generalized as follows:
[prompt location]\> copy [source item] [target location][\optional rename] [enter]
List Directory Contents
Use the dir (directory) command to list the contents of a directory. File names and their corresponding sizes will be displayed. For example, to list the contents of the C drive:
X:\> dir C: [enter]
Similarly, to list the contents of any directory, "\any\dir":
X:\> dir C:\any\dir [enter]
Likewise, to list the contents of any subdirectory of X (i.e., the current location as indicated in the DOS prompt):
X:\> dir \sub\dir [enter]
Here are some more hot dir tips:
X:\> dir [enter] (lists contents of current directory, X)
X:\> dir /w [enter] (lists contents of current directory in wide format)
X:\> dir /w /p [enter] (lists contents of current directory in wide format, one screen at a time)
X:\> dir Y:*.txt [enter] (lists all .txt files on drive Y)
X:\> dir Y:*.t?? [enter] (lists all files with extension beginning with "t")
Erase Something
To delete an item, use the deadly "erase" command. For example, if you want to delete the file, "terminated.jpg", located on the Y drive:
X:\> erase Y:terminated.jpg [enter]
To delete a file within the directory indicated in the DOS prompt, no additional directory information is needed:
X:\> erase terminated.jpg [enter]
If you would like to erase all of the contents of a directory, say, Y:
X:\> erase Y:*.* [enter]
Format Something
To format a drive, use the "format" command. Formatting a disk involves error checking and directory creation. For example, if you want to format the floppy disk in drive A (note: disk formatting requires user input regarding several options presented during the process):
X:\> format A: [enter]
Create a Directory
To create a new directory, use the "mkdir" command. For example, to create a directory called "rygar" within the Y:\arcade directory:
X:\> mkdir Y:\arcade:rygar [enter]
This is even easier if you wish to create a directory within the current directory (i.e., the directory listed in the DOS prompt). For example, to create a rygar directory within the Y:\arcade directory while in Y:\arcade:
Y:\arcade> mkdir rygar [enter]
Rename Something
To rename an item, use the "ren" command. For example, to rename the file "atari.exe" to "nintendo.exe":
X:\> ren Y:\arcade\atari.exe nintendo.exe [enter]
Reboot the Computer
To reboot the computer while in DOS, use everybody’s favorite command: [ctrl] + [alt] + [del] (control-alt-delete). For example, to reboot your system after making a mess of things, simultaneously press the three keyboard buttons, Ctrl, Alt, and Del.
Remove a Directory
To remove any empty directory, use the "rd" command. For example, let’s remove the empty directory, rygar, located within the directory, Y:\arcade:
X:\> rd Y:\arcade\rygar [enter]
Likewise, to remove rygar when the current directory is the parent directory:
Y:\arcade> rd rygar [enter]
Terminate a Command
To stop the execution of a command before it has completed, press [Ctrl] + [Break] (control-break) simultaneously. The somewhat-obscure Break key is typically located near the Scroll Lock and Print Screen keys. Who knew it.
Change the Date
To change the system date simply type "date" and enter the desired date according to the format specified at the prompt.
Change the Time
To change the system time simply type "time" and enter the desired time according to the format specified at the prompt.
Return to Windows
To exit DOS mode and return to Windows, type "windows" at the DOS command prompt.
Exit DOS
To exit DOS, type "exit" at the DOS prompt.
Related articles
- Computer Flashback: Windows 98 Run Commands
- Fun with the DOS Command Prompt
- DOS Fundamentals
- Monitoring Internet Activity for Windows and Mac
- Hide Content on Windows 98SE
- Delete index.dat on Windows 98SE
- Amazing Keyboard Shortcuts
About this article
This is article #215, posted by Jeff Starr on Monday, October 09, 2006 @ 08:05am. Categorized as Technology, and tagged with code, commands, dos, notes, plus, windows. Updated on November 07, 2007. Visited 34714 times. 2 Responses »
Bookmark • Subscribe • Explore
« One Link to Open Them All • Up • Folder Background Images in WinXP »
1 • October 23, 2006 at 2:48 am — Mehdi says:
Hi,
this is good but I wish more command about DOS and if exm have more detail then good.
TC