Common DOS commands
Changing the Default Drive
To change the default drive, simply type the letter of your choice. The new default will be listed in
subsequent DOS prompts.
Example:
C:\> D: [enter]
Changes the default drive from C to D.
D:\> C: [enter]
Changes the default drive from D to C.
md or Make Directory Command
DOS allows you to create a folder or a directory as it is called in DOS using an md command.
Example:
C:\> md assets
Creates a directory or a folder named assets in drive C:
Changing Directory Command
This command allows you to move from one directory to another directory.
Example: Let’s say you are in C:\Docs directory
So to move up a directory named business (assuming there is directory name business) you issue the
following command:
C:\Docs> CD business <enter>
So to move to another directory that is not directly under your current directory (which has been so far the
C:\Docs\business\> ), let’s say for example you want to move to C:\Project\Completed directory – you
issue the following command:
C:\Docs> CD\Project\Completed <enter>
Tip: CD command followed by space and then a directory named like CD business moves you up from
your current directory. However, CD command followed by \ (or backslash) moves you any directory in
your current drive (C: or D: or E: drive).
Other special CD commands
CD.. – moves you one directory down
For example like in the above if you are in C:\Docs\business directory and you want to go back to Docs
directory you issue the following command:
C:\Docs\Business> CD..
CD\ - moves you back to the root directory
Again for example if you are in C:\Docs\business directory and you want to go back to root directory in
your current drive you issue the following command:
C:\Docs\Business> CD\
DIR (Directory) Command
The DIRECTORY command lists the names and sizes of all files located on a particular disk.
Example:
C:\> dir
Shows directory of drive C
C:\> dir d:
Shows directory of drive D
C:\> dir /w
Shows directory in wide format, as opposed to a vertical listing.
C:\> dir /p
Allows you to pause one screen at a time if there are many files to be shown in the screen.
DIR Options
Wildcard character: Using * (or asterisk) allows you to list files and directories according to a given
pattern:
Example:
C:\> dir w*
Lists all files that starts with letter w
C:\> dir win*
Lists all files that starts with the word win
C:\> dir *.exe
List all files that has a file extension name of .exe
Displaying files according to attributes:
Files have attributes, that is, it could be read-only, archive, hidden, system, folder or simply a regular file.
And to display files according to attributes you use the dir /a<attribute> command:
Example:
C:\> dir /ah
Lists all files that are hidden files
C:\> dir /ad
Lists only directories and does not include files
COPY Command
The COPY command allows you to copy file(s) to another file or drive.
Example:
C:\> copy golf.doc d:
Copies the file 'golf.doc’ from the C drive to the drive D and gives it the same name, that is,
golf.doc
C:\> copy golf.doc d:\golfback.doc
Creates a copy of 'golf.doc’ from drive C to drive D but with different name this time, namely,
golfback.doc
C:\> copy *.doc d:
Copies all files from drive C: that has file extension of .doc to drive D: as destination.
C:\> copy *.* d:
Copies all files from drive C: to drive D: as destination.