Celebrating 20 years online :)
Web Dev + WordPress + Security

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:

list contents of current directory, X
X:\> dir [enter]
list contents of current directory in wide format
X:\> dir /w [enter]
list contents of current directory in wide format
X:\> dir /w /p [enter]
list all .txt files on drive Y
X:\> dir Y:*.txt [enter]
list all files with extension beginning with "t"
X:\> dir Y:*.t?? [enter]

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 resources

About the Author
Jeff Starr = Creative thinker. Passionate about free and open Web.
Banhammer: Protect your WordPress site against threats.

2 responses to “Basic DOS Commands”

  1. Hi, this is good but I wish more command about DOS and if exm have more detail then good. TC

  2. Mehdi,

    Thank you for the feedback concerning this post. Although my EXM skills are a little rusty, I will definitely look into it and report any significant or otherwise useful findings..

Comments are closed for this post. Something to add? Let me know.
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
BBQ Pro: The fastest firewall to protect your WordPress.
Crazy that we’re almost halfway thru 2024.
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Note to self: encrypting 500 GB of data on my iMac takes around 8 hours.
Getting back into things after a bit of a break. Currently 7° F outside. Chillz.
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.