List of DOS commands
From Wikipedia, the free encyclopedia
A partial list of the most common commands for Microsoft's MS-DOS operating system follows. In versions 5 and later only, the user can get help by typing HELP at the shell prompt. (Before version 6, the help displayed by this command is very basic and not interactive.) In the interactive help of versions 6 and later, square brackets indicate optional parameters, while italicized items should be replaced with specific values.
In DOS version 5 or later, to get help on a dos command, at the dos prompt, type /? after the command name. For example, to get help for the xcopy command, type the following at the dos prompt:
xcopy /?
The operating system will not execute the command but instead display a help page on the command, in this case xcopy. To view this help page, see the xcopy entry on this page or click here.
In the list below, when a command can accept more than one filename, or a filename including wildcards (* and ?), it is said to accept a filespec parameter. Commands that can accept only a single filename are said to accept a filename parameter.
For most of the commands, the Unix equivalent is given. It should be noted that Unix commands typically provide ranges of functionality and flexibility that are not approached by the equivalent DOS command, so all comparisons are approximate. For example, the DOS commands copy
and xcopy
are said to be equivalent to the Unix cp
command, but in reality cp
has much greater power than both copy
and xcopy
combined. On the other hand, move
and ren
have much more power in DOS.
More than 100 other commands are available in different releases of DOS, all of which are described in the last reference; the most useful not described here are call, debug, doskey, edit, fc, findstr, mode, pause, and subst.
[edit] Commands
[edit] attrib
- Change or view the attributes of one or more files. It defaults to displaying the attributes of all files in the current directory.
Options:
- To add an attribute attach a '+' in front of it.
- To remove an attribute attach a '-' in front of it
- Attributes include
- A - Archived (used mainly by file archiving software)
attrib [+|-ahrs] [filespec]
- Roughly equivalent to the Unix command
chmod
. In Linux, the commandchattr
also performs similar functions.
[edit] cd or chdir
- Change current directory.
cd directory
- Equivalent to the Unix command
cd
(with parameters), orpwd
(without parameters). (cd .. descends a directory.)
[edit] chkdsk
- Verifies a hard disk or a floppy disk for file system integrity.
Options:
- /F : Fixes errors on the disk
- /V : Displays the full path and name of every file on the disk
chkdsk drive [[path]filename] [/F] [/V]
- Equivalent to the Unix command
fsck
[edit] cls
- Clears the screen.
cls
- Equivalent to the Unix command
clear
.
[edit] copy
- 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.
copy filespec [destination]
- Equivalent to the Unix command
cp
.
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. Which is just like the "cat" command.
[edit] copy device
copy device filename
- In this usage, data is written from the given device to the file until the end-of-file character (ASCII character 26, which may be typed as ctrl-Z) is encountered. The most commonly used device is named con, which is short for "console"; thus,
copy con filename
would allow the user to type directly into a file, and press ctrl-Z when finished.
- In Unix, this functionality is provided by the
cat
command.cat > filename
(with ctrl+D to finish) would be equivalent to the DOS commandcopy con filename
.
[edit] defrag
- Defragments disk drive
defrag driveletter
- No Unix equivalent.
- DR DOS equivalent was the diskopt command.
[edit] del or erase
- Deletes files.
del filename erase filename
- To delete files in Quiet mode
del /Q filename
- Equivalent to the Unix command
rm
.
[edit] deltree
- Deletes a directory along with all of the files and subdirectories that it contains. Normally, it will ask for confirmation of such a drastic action.
deltree [/y] directory
The /y parameter if present tells the deltree
command to carry out without first prompting for confirmation.
The deltree
command is not included in recent Microsoft Windows operating systems. Deleting a non-empty directory in those versions of Windows where the command is not included, can be achieved by the use of the rmdir
command as in the following example:
rmdir /s directory
In Unix, the functionality of deltree
is provided by the rm
command with the parameter -r
(or -rf
for the /y
switch).
[edit] dir
Main article: Dir (DOS Command)
- Displays contents of a directory.
Options :
- /w : Wide list format
- /p : Pause at every page
- /s : Also look in subdirectories
- /a[xx] : Display files with the specified attributes only
- /o[xx] : Modifies sort order
- /b : Uses bare format (no heading information or summary)
dir [options] [filespec]
- Equivalent to the Unix command
ls
(the option-l
is "long" list format, it works the opposite way from/w
.)
more options:
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.
/A Displays files with specified attributes. attributes: D Directories R Read-only files
H Hidden files
A Files ready for archiving S System files - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order. sortorder: N By name (alphabetic) S By size (smallest first) E By extension (alphabetic) D By date/time (oldest first) G Group directories first - Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting. timefield C Creation A Last Access W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place.
/4 Displays four-digit years
[edit] echo
- Prints its own arguments back out to the DOS equivalent of the standard output stream. Usually, this means directly to the screen, but the output of echo can be redirected like any other command. Often used in batch files to print text out to the user.
echo this is text Outputs 'this is text' echo. Outputs a blank line
- Another important use of the echo command is to toggle echoing of commands on and off in batch files.
echo on turns on echoing of commands echo off turns off echoing of commands
- Traditionally batch files begin with the
@echo off
statement. This says to the interpreter that echoing of commands should be off during the whole execution of the batch file thus resulting in a "tidier" output. The@
symbol declares that this particular command (echo off) should also be executed without echo. For example the following 2 batch files are equivalent: - Batch1.bat:
@echo off echo The files in your root directory: dir /b /a-d c:\
- Batch2.bat:
@echo The files in your root directory: @dir /b /a-d c:\
- Echo can be used to write to files directly from the console, by redirecting the output stream:
echo text > filename
- Echo can also be used to append to files directly from the console, again by redirecting the output stream:
echo text >> filename
- To type more than one line from the console into a file, use
copy con
(above). - Equivalent to the Unix command
echo
.
[edit] exit
- Exits the current batch script or the controlling thread. When running from Windows this will close the command prompt.
EXIT [/B] [exitcode] /B Exit the current batch script and set ERRORLEVEL to exitcode Without this option, the controlling thread and any intermediate batch files are immediately exited, and the process return code is set to exitcode.
[edit] fdisk
- Manipulates hard disk partition tables. The name derives from IBM's habit of calling hard drives fixed disks. When run from the command line, it displays a menu of various partitioning operations:
1. Create DOS partition or Logical DOS Drive 2. Set active partition 3. Delete partition or Logical DOS Drive 4. Display partition information 5. Change current fixed disk drive
[edit] find
- A filter to find lines in the input data stream that contain or don't contain a specified string and send these to the output data stream.
- Find may also be used as a pipe.
find "keyword" < ''inputfilename'' > ''outputfilename'' Searches for a text string in a file or files. FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]] /V Displays all lines NOT containing the specified string. /C Displays only the count of lines containing the string. /N Displays line numbers with the displayed lines. /I Ignores the case of characters when searching for the string. "string" Specifies the text string to find. [drive:][path]filename Specifies a file or files to search. If a pathname is not specified, FIND searches the text typed at the prompt or piped from another command.
- Equivalent to the Unix command
grep
. The Unix commandfind
performs an entirely different function; see tree.
[edit] format
- Delete all the files on the disk and reformat it for MS-DOS
- In most cases, this should only be used on floppy drives or other removable media. This command can potentially erase everything on a computer's hard disk.
- /autotest and /backup are undocumented features. Both will format the drive without a confirmation prompt.
format [options] drive FORMAT drive: [/V[:label]] [/Q] [/F:size] [/B | /S] [/C] FORMAT drive: [/V[:label]] [/Q] [/T:tracks /N:sectors] [/B | /S] [/C] FORMAT drive: [/V[:label]] [/Q] [/1] [/4] [/B | /S] [/C] FORMAT drive: [/Q] [/1] [/4] [/8] [/B | /S] [/C] /V[:label] Specifies the volume label. /Q Performs a quick format. /F:size Specifies the size of the floppy disk to format (such as 160, 180, 320, 360, 720, 1.2, 1.44, 2.88). /B Allocates space on the formatted disk for system files. /S Copies system files to the formatted disk. /T:tracks Specifies the number of tracks per disk side. /N:sectors Specifies the number of sectors per track. /1 Formats a single side of a floppy disk. /4 Formats a 5.25-inch 360K floppy disk in a high-density drive. /8 Formats eight sectors per track. /C Tests clusters that are currently marked "bad."
Known as a joke among UNIX users of that time since every user on the machine could easily cause damage with just one command. Therefore, it was known in the UNIX community as "The big DOS timesaver".
- Equivalent to the Unix command
mkfs
.
[edit] help
- Gives help about DOS.
- help 'command' would give help on a specific command, in MS-DOS 6 a HELP program was started which would give more details and examples, earlier versions basically gave the same information as command/? would give.
- Partially equivalent to the Unix command man.
[edit] InterSvr
- MS-DOS 6 and above command used to network PCs using a null modem cable or LapLink cable. The server-side version of InterLnk, it also immobilizes the machine it's running on as it's an active app (As opposed to a TSR) which must be running for any transfer to take place.
- No Unix equivalent.
- DR DOS equivalent is filelink, which is executed on both the client and server.
[edit] label
- Changes the label on a logical drive, such as a hard disk partition or a floppy disk.
[edit] md or mkdir
- Makes a new directory. The parent of the directory specified must already exist.
md directory
- Equivalent to the Unix command
mkdir
.
[edit] mem
- Displays memory usage.
mem
- Equivalent to the Unix command
free
.
[edit] memmaker
- Starting from version 6, MS-DOS included the external program MemMaker which was used to free system memory (especially Conventional memory) by automatically reconfiguring Autoexec.bat and Config.sys files. This was usually done by moving TSR Programs to the Upper memory. The whole process required 3 system restarts. Before the first restart the user was asked whether he wanted to enable EMS Memory or not.
- The use of MemMaker was popular among gamers who wanted to enable or disable Expanded memory in order to run a game which required EMS or not. The result would however not be as good as someone changing the settings themself.
Options :
- /BATCH Runs MemMaker in batch (unattended) mode. In batch mode, MemMaker takes the default action at all prompts.
- /UNDO Instructs MemMaker to undo its most recent changes.
[edit] more
- Pages through the output so that you can view more than one screen of text.
command | more
- More may also be used as a filter.
more < inputfilename
[edit] move
- Moves or renames a file.
move filename newfilename
- Equivalent to the Unix command
mv
.
[edit] msd
Main article: Microsoft Diagnostics
- Provides detailed technical information about the computer's hardware and software.
msd
- No Unix Equvivalent, however in GNU/Linux similar type of information may be obtained from various text files in /proc directory.
[edit] pcpark
- Parks the hard disk(s) (stops their turning) in order to enable safe shutdown; only used on early versions.
pcpark
- No Unix equivalent.
- MS-DOS 3.2 (and possibly others) used the command HHSET
[edit] rd or rmdir
- Remove a directory, which must be empty of files for the command to succeed.
rd directory
- Equivalent to the Unix command
rmdir
.
[edit] rem
- Remark statement, normally used within a batch file. However on the command line, rem can also be used to create a zero length file by redirecting an empty remark statement to a filename.
rem > newfilename
An alternative way to not run a specific statement in a batch file is creating a label that will never be used, ::.
- In Unix, the
#
sign can be used to start a comment; the zero-length file can be achieved using various methods, such as the touch command or dd.
[edit] ren
- Renames a file. Unlike the
move
command, this command cannot be used to rename subdirectories, or rename files across drives.
ren filename newname
A more useful function of this command is to mass rename files by the use of wildcards. For example, the following command will change the extension of all files in the current directory from htm to html:
ren *.htm *.html
- In Unix, this functionality of a simple move is provided by the
mv
command, but changing extension of all files is not as simple.
[edit] scandisk
- Disk diagnostic utility
scandisk driveletter
Scandisk is a replacement for the chkdsk
utility. Its primary advantages over chkdsk
is that it is more reliable and has the ability to run a surface scan which finds and marks bad clusters on the disk. It is present on 16/32-bit MS-DOS-based versions of Windows like Windows 95, 98, 98SE, and Me. chkdsk
has surface scan and bad cluster detection functionality built in on Windows NT based operating systems.
- Equivalent to the Unix command
fsck
.
[edit] set
- Sets environmental variables. See Environment variable.
[edit] sort
- A filter to sort lines in the input data stream and send them to the output data stream.
sort < inputfilename > outputfilename
- Equivalent to the Unix command
sort
.
[edit] time and date
- Set/display the date and time
date time
- Equivalent to the Unix command
date
with the important difference that calling this from the command line or a bat script will cause the program to halt requesting a new time until RETURN is pressed. The command 'time /t' will bypass this set feature.
[edit] tree
- Shows the directory tree of the current directory
- Options:
- /F (Displays the names of the files in each folder.)
- /A (Use ASCII instead of the extended characters.)
tree [options] [directory]
- Equivalent to the Unix command
find
.
[edit] truename
truename filename
- Outputs the entire path (full directory and filename) of a file. For example, if the working drive and directory were C:\PROGRAMS and one typed
truename fish
<HARDDRIVE>, the output would be C:\PROGRAMS\FISH.
- This command was rarely, if ever, documented in DOS manuals.
- This command is similar to the Unix which command, which, given an executable found in $PATH, would give a full path and name. The C library function
realpath
performs this function.
[edit] type
- Display a file. The more command is frequently used in conjunction with this command, e.g. type long-text-file | more.
type filename
- Equivalent to the Unix command
cat
.
[edit] undelete
- Restores file previously deleted with del. By default all recoverable files in the working directory are restored. The options are used to change this behaviour. If the MS-DOS mirror TSR program is used, then deletion tracking files are created and can be used by undelete.
Options :
- /list : lists the files that can be undeleted.
- /all : Recovers all deleted files without prompting. Uses a number sign for missing first character.
- /dos : Recover only MS-DOS aware files, ignore deletion tracking file.
- /dt : Recover only deletion tracking file aware files.
undelete [filespec] [/list|/all][/dos|/dt]
[edit] ver
- Shows the version of MS-DOS you are using.
- Some versions of MS-DOS support an undocumented /r switch, which will show the revision as well as the version.
ver [/r]
- Equivalent to the Unix command
uname
. However, in Linuxuname
may simply refer to the version of the kernel rather than the operating system itself, which is sometimes stored in a text file in /etc/name_version, or commandlsb_release -a
.
[edit] xcopy
- Copy entire directory trees.
xcopy directory [destination-directory]
Copies files and directory trees. XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/W] [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U] [/K] [/N] source Specifies the file(s) to copy. destination Specifies the location and/or name of new files. /A Copies files with the archive attribute set, doesn't change the attribute. /M Copies files with the archive attribute set, turns off the archive attribute. /D:date Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. /P Prompts you before creating each destination file. /S Copies directories and subdirectories except empty ones. /E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T. /W Prompts you to press a key before copying. /C Continues copying even if errors occur. /I If destination does not exist and copying more than one file, assumes that destination must be a directory. /Q Does not display file names while copying. /F Displays full source and destination file names while copying. /L Displays files that would be copied. /H Copies hidden and system files also. /R Overwrites read-only files. /T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories. /U Updates the files that already exist in destination. /K Copies attributes. Normal Xcopy will reset read-only attributes. /Y Overwrites existing files without prompting. /-Y Prompts you before overwriting existing files. /N Copy using the generated short names.
- In Unix, this functionality is provided by the
cp
command.
[edit] External links
- The MS-DOS 6 Technical Reference on TechNet contains the official Microsoft MS-DOS 6 command reference documention.
There are several guides to DOS commands available that are licenced under the GNU Free Documentation License:
- The FreeDOS HTML Help at fdos.org is a fully hypertext help system for FreeDOS commands, written in 2003/2004
- The FreeDOS Spec at SourceForge is a plaintext specification, written in 1999, for how DOS commands should work in FreeDOS
Wikibooks also has a guide to Microsoft Windows (as opposed to DOS) commands.