Professional Documents
Culture Documents
Common DOS Commands
Common DOS Commands
1. Cd
CD (Change Directory) is a command used to switch directories in MS-DOS. For example,
if you needed to run Windows 3.11 from DOS, you would type:
Syntax
CHDIR [drive:][path]
CHDIR[..]
CD [drive:][path]
CD[..]
Examples
cd\
Goes to the highest level, the root of the drive.
cd..
Goes back one directory. For example, if you are within the C:\Windows\COMMAND>
directory, this would take you to C:\Windows>
cd windows
If present, would take you into the Windows directory. Windows can be substituted with
any other name.
cd\windows
If present, would first move back to the root of the drive and then go into the Windows
directory.
cd windows\system32
If present, would move into the system32 directory located in the Windows directory. If
at any time you need to see what directories are available in the directory you're
currently in use the dir command.
cd
Typing cd alone will print the working directory. For example, if you're in c:\windows>
and you type the cd it will print c:\windows
2. dir
The dir command allows you to see the available files in the current and/or parent
directories.
Syntax
Microsoft Windows 2000 and Windows XP syntax
Displays a list of files and subdirectories in a directory.
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]]
[/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
[drive:][path][filename] Specifies drive, directory, and/or files to list.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not
dir /w
If you don't need the info on the date / time and other information on the files, you
can use this command to list just the files and directories going horizontally, taking as
little as space needed.
dir /s /w /p
This would list all the files and directories in the current directory and the sub
directories after that, in wide format and one page at a time.
dir /on
List the files in alphabetical order by the names of the files.
dir /o-n
List the files in reverse alphabetical order by the names of the files.
3. Copy
Allows the user to copy one or more files to an alternate location.
Syntax
Copies one or more files to another location.
COPY source destination
source Specifies the file or files to be copied.
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
Suppresses prompting to confirm you want to overwrite an existing
/Y
destination file.
Causes prompting to confirm you want to overwrite an existing destination
/-Y
file.
Examples
Copy all files in the current directory to the floppy disk in drive a:
copy *.* a:
Copy the contents in myfile2.txt and combine it with the contents in myfile1.txt.
copy myfile1.txt+myfile2.txt
Finally, a user can create a file using the copy command. In the below example we
create the file called "test.txt".
copy con test.txt
Once the above command has been typed in, a user could type in whatever he or she
wishes. When you have completed creating the file, you can save and exit the file by
pressing CTRL+Z, which would create ^Z, and then press enter
4. del
Syntax
Notice: Users who are running Microsoft Windows and are used to deleted items going to
the recycle bin need to keep in mind that deleting files from MS-DOS does not send files to
the recycle bin.
del test.tmp = Deletes the test.tmp in the directory that you currently are in, if the file
exists.
del c:\windows\test.tmp = Delete the c:\windows\test.tmp in the windows directory if it
exists.
del c:\windows\temp\*.* = (* is for wild character(s)) *.* indicates that you would like to
delete all files in the c:\windows\temp directory.
del c:\windows\temp\?est.tmp = (? is a single wild character for one letter) This command
would delete any file ending with est.tmp such as pest.tmp or zest.tmp...
5. fdisk
Fdisk is one of the more commonly used MS-DOS commands, even today with Windows
95 and Windows 98. Fdisk allows the user to delete and/or create partitions on the hard disk
drive.
6. format
Format is used to erase all of the information off of a computer diskette or fixed drive.
Syntax
volume Specifies the drive letter (followed by a colon), mount point, or volume
name.
/FS:filesystem Specifies the type of the file system (FAT, FAT32, or NTFS).
/V:label Specifies the volume label.
/Q Performs a quick format.
/C Files created on the new volume will be compressed by default.
/X Forces the volume to dismount first if necessary. All opened handles to
the volume would no longer be valid.
Examples
When using the format command, remember all information on the drive you wish to
format will be completely erased.
format a:
Would erase all the contents off a disk. Commonly used on a diskette that has not
been formatted or on a diskette you wish to erase.
format a: /q
Quickly erases all the contents of a floppy diskette. Commonly used to quickly erase
all information on the diskette.
format c:
This would erase all the contents of your C: hard disk drive. In other words, unless
you wish to erase all your computer's information, this command should not be done
unless you're planning to start over.
7. Xcopy/xxcopy
Xcopy is a powerful version of the copy command with additional features; has
the capability of moving files, directories, and even whole drives from one
location to another.
Syntax
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C]
[/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]...]
Examples
xcopy c:\temp /e
The above example is the basic xcopy command to copy the files,
directories, and subdirectories to the directory you're currently in.
In the above example the xcopy command would copy all files and
directories in the user "hope" directory to the directory or drive you're
currently in.
xcopy h:\*.* /a /e /k
The above command would copy everything located on the H drive to the
drive you are currently on.
8. deltree
Short for delete tree, deltree is a command used to delete files and directories
permanently from the computer.
Syntax
To delete one or more files and directories: DELTREE [/Y] [drive:]path [[drive:]path[...]]
Note: Use DELTREE cautiously. Every file and subdirectory within the specified directory
will be deleted. Once deleted, you cannot recover the information.
Examples
deltree c:\fake010
Used to rename files and directories from the original name to a new name.
In earlier releases of MS-DOS instead of using ren or rename you need to use the move
command to rename your MS-DOS directories or files.
Syntax
Note that you cannot specify a new drive or path for your destination.
Examples
rename * 1_*
Rename all files to begin with 1_. The asterisk (*) in this example is an example of a
wild character; because nothing was placed before or after the first asterisk, this means all files
in the current directory will be renamed with a 1_ in front of the file. For example, if there was a
file named hope.txt it would be renamed to 1_pe.txt.
10. cls
Cls is a command that allows a user to clear the complete contents of the screen and
leave only a prompt.
Syntax
CLS