MS-DOS or Microsoft Disk Operating System was a 16-bit command user interface operating system used between 1981 and 2000. Following are its features:
- It runs from a disk drive rather than a paper-based medium like a punch card.
- It was a common foundation for all Windows 9x operating systems such as Windows 95, 98, and 98SE.
- The NT kernel completely replaced it in Windows 2000 on the desktop.
- It doesn’t support multimedia.
Is the Command Prompt in our Machine the Same as MS-DOS?
Command prompt is a command-line interpreter available in all Windows operating systems. It is not the same as MS-DOS but an emulator which can run almost all the commands of MS-DOS. Use the following command to get started with the Command Prompt (CMD):
- Press the Windows button to open the start menu.
- Enter CMD.
- Search results will show the command prompt.
How Many Types of DOS Commands Exist?
There are two broad categories of DOS commands as follows:
- Internal Commands : They perform basic operations on files and directories and do not need any external file support.
E.g., CLS, CLEAR
- External Commands : They are for performing advanced tasks and need external file support as they are not stored in COMMAND.COM .
E.g., DISKCOMP, DIR
List of all MS-DOS Commands
Here is a list of all basic MS-DOS commands, along with their syntax and examples.
1. append
This command triggers events for MS-DOS to look over other directories during file editing. It gives the user a way to set the search path for the files.
Type: External
Syntax
APPEND Drive: \Path /X /E Path:on or off
Example
append c:\cards;c:\letters
2.arp
This command displays/adds/modifies/removes the address resolution protocol information from all the devices.
Type: External
Syntax: The following syntax is available as taken from PowerShell
-a
|
Displays current ARP entries by interrogating the current protocol data. If inet_addr is specified, the IP and Physical addresses for only the specified computer are displayed. If more than one network interface uses ARP, entries for each ARP table are displayed.
|
-g
|
Same as -a.
|
-v
|
Displays current ARP entries in verbose mode. All invalid entries and entries on the loop-back interface will be shown.
|
inet_addr
|
Specifies an internet address.
|
-N if_addr
|
Displays the ARP entries for the network interface specified by if_addr.
|
-d
|
Deletes the host specified by inet_addr. inet_addr may be wildcarded with * to delete all hosts.
|
-s
|
Adds the host and associates the Internet address inet_addr with the Physical address eth_addr. The Physical address is given as 6 hexadecimal bytes separated by hyphens. The entry is permanent.
|
eth_addr
|
Specifies a physical address.
|
if_addr
|
If present, this specifies the Internet address of the interface whose address translation table should be modified. If not present, the first applicable interface will be used.
|
Example
3. assign
This command assigns or routes a drive request to a different drive. An assign command with no switches cancels redirected drive assignments and returns them to their original drives.
Type: External
Syntax
ASSIGN Source = Target /status
Example
assign c: = b:
4. assoc
This command displays the association of a file related to each different extension available in the machine. Without any parameter, this command displays the current file association.
Type: Internal
Syntax
ASSOC [.ext[=[fileType]]]
Example
assoc .exe
5. at
This command allows the user to schedule a fixed time and date to execute a set of programs.
Type: External
Syntax
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
Example
at 7:00AM "c:\morning.bat"
This will execute morning.bat file at 7:00AM.
Deprecated
This command is now deprecated and now replaced with `schtasks.exe`. If it is run without any parameter, it will show all the scheduled tasks for the future time.
Example
6. attrib
This command allows the user to change the attributes of files. With the help of this command, the user can easily hide/display or do any other change in a file.
Type: External
Syntax
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+X | -X] [+P | -P] [+U | -U] [drive:][path][file name] [/S [/D]] [/L]
+
|
Sets an attribute. |
- | Clears an attribute. |
R | Read-only file attribute. |
A | Archive file attribute. |
S | System file attribute. |
H | Hidden file attribute. |
O | Offline attribute. |
I | Not content indexed file attribute. |
X | No scrub file attribute. |
V | Integrity attribute. |
P | Pinned attribute. |
U | Unpinned attribute. |
B |
SMR Blob attribute. |
[drive:][path][filename] | Specifies a file or files for attrib to process. |
/S | Processes matching files in the current folder and all subfolders. |
/D | Processes folders as well. |
/L |
Work on the attributes of the Symbolic Link versus the target of the Symbolic Link. |
Example
Here when we first typed the attrib command, it displayed the A attribute of file.txt. A means archive.
Afterward, we set the read-only attribute to the file and hit the attrib command again. Now it displays A and R
7. break
This command enables/disables the keyboard shortcuts for copying and pasting in the command prompt. In other words, Ctrl + C and Ctrl + V.
Type: Internal
Syntax
BREAK [ON | OFF]
Example
It enables the ctrl + C function.
8. bcdedit
Boot Configuration Datastore Editor. This command modifies the boot configuration data store. It also contains information that is required by the system to boot up.
Type: External
Syntax
bcdedit
Example
The content is directly taken from Powershell.
Following are the commands that operate on a store.
/store | Used to specify a BCD store other than the current system default |
/createstore | Creates a new and empty boot configuration data store. |
/export |
Exports the contents of the system store to a file. This file can be used later to restore the state of the system store. |
/import | Restores the state of the system store using a backup file created with the /export command. |
/sysstore | Sets the system store device (only affects EFI systems, does not persist across reboots, and is only used in cases where the system store device is ambiguous). |
Following are the commands that operate on entries in a store:
/copy | Makes copies of entries in the store. |
/create | Creates new entries in the store. |
/delete | Deletes entries from the store. |
/mirror | Creates mirror of entries in the store. |
9. bootcfg
This command is part of the recovery console and cannot be run directly. It helps users to do editing in the boot.ini file.
Type: Recovery
Syntax
BOOTCFG /parameter [arguments]
/parameter can include the following:
/copy | Makes a copy of an existing boot entry. |
/delete | Deletes an existing boot entry from the BOOT.INI file. |
/query | Displays the current boot entries and their settings. |
/raw | Allows the user to specify any switch to be added. |
/timeout | Allows the user to change the Timeout value. |
/default | Allows the user to change the Default boot entry. |
/EMS | Allows the user to configure the /redirect switch for headless support. |
/debug | Allows the user to specify the port for remote debugging. |
/addsw | Allows the user to add predefined switches. |
/rmsw | Allows the user to remove predefined switches. |
/dbg1394 | Allows the user to configure 1394 port for debugging. |
/? | Display a summary of parameters |
Example
BOOTCFG /Copy /D "Edit" /ID 8
This command means
/copy | This command makes a copy of the existing boot entry. |
/D | The description that has to be provided. |
/ID | It specifies the ID to be copied in the boot.ini. |
10. call
This command is used to run a script from within another script. This command cannot be used outside any script or in DOS.
Type: Internal
Syntax
CALL [drive:][path]file name [batch-parameters]
Example
call techgeekbuzz.bat
This command will execute the batch file techgeekbuzz and this command can only be run from inside of another batch file. l
11. cd
This command is the most used command of DOS. Its full form is C hange D irectory. It is used to browse inside any directory. This is shorthand for chdir command.
Type : Internal
Syntax
CD [/D] [drive:][path]
Example
cd | It displays the current directory. |
cd d:/ | It moves into D drive. |
cd .\techgeekbuzz | It will move inside the techgeekbuzz folder. |
cd.. | It will come out from the current folder. |
12. chcp
Before understanding what this command does, we must understand what is an active code page. An active code page is a page which contains character codes and their corresponding characters.
For example, Active code page 437, mostly used in India, contains character code 161 as “b”.
The chcp command helps the user by giving her the option to configure the active code page number. It can be further used to implement the international keyboard allowing DOS to be used in different languages.
Type: External
Syntax
CHCP [nnn]
Example
13. chdir
This command is the same as the cd command. It is used to change the directory.
Type: Internal
Syntax
CHDIR[..]
Example
chdir windows - It will move to the windows directory (Given that the windows directory should be available in the current directory)
Most of the commands are the same as we use with cd. But as we can see, the last command chdir.. is not running
14. chkdsk
This command is an abbreviation of check disk. It is used to identify and resolve errors on the hard disk. It opens a utility that checks the hard disk for any errors.
Type: External
Syntax
CHKDSK [volume[[path]file name]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B] [/scan] [/spotfix]
volume | Specifies the drive letter (followed by a colon), mount point, or volume name. |
file name | FAT/FAT32 only: Specifies the files to check for fragmentation. |
/F | Fixes errors on the disk. |
/V |
On FAT/FAT32: Displays the full path and name of every file on the disk. |
On NTFS | Displays cleanup messages if any. |
/R | Locates bad sectors and recovers readable information (implies /F). |
/L:size | NTFS only: Changes the log file size to the specified number of kilobytes. If size is not specified, displays current size. |
/X | Forces the volume to dismount first if necessary. All opened handles to the volume would then be invalid (implies /F). |
/I |
NTFS only: Performs a less vigorous check of index entries. |
/C | NTFS only: Skips checking of cycles in the folder structure. |
/B | NTFS only: Re-evaluates bad clusters on the volume (implies /R). |
/scan | NTFS only: Runs an online scan on the volume. |
/forceofflinefix |
NTFS only: (Must be used with "/scan") bypass all online repair; all defects found are queued for offline repair (i.e., "chkdsk /spotfix"). |
/perf | NTFS only: (Must be used with "/scan") uses more system resources to complete a scan as fast as possible. This option may have a negative performance impact on other tasks running on the system. |
/spotfix |
NTFS only: (Must be used with "/scan") uses more system resources to complete a scan as fast as possible. This option may have a negative performance impact on other tasks running on the system. |
/sdcleanup | NTFS only: Garbage collect unneeded security descriptor data (implies /F). |
/offlinescanandfix | Runs an offline scan and fix on the volume. |
/freeorphanedchains | FAT/FAT32/exFAT only: Frees any orphaned cluster chains instead of recovering their contents. |
/markclean | FAT/FAT32/exFAT only: Marks the volume clean if no corruption was detected, even if /F was not specified. |
/I or /C switch | Reduces the time required to run Chkdsk by skipping certain volume checks |
Example
15. choice
This command is used by a user inside a batch file only. This provides a list of choices available to the user and also returns the index of the selected choice.
Type: External
Syntax
CHOICE [/C choices] [/N] [/CS] [/T timeout /D choice] [/M text]
Parameter List:
/C choices |
Specifies the list of choices to be created.
The default list is "YN". |
./N |
Hides the list of choices in the prompt. The message before the prompt is displayed and the choices are still enabled. |
/CS | Enables case-sensitive choices to be selected. By default, the utility is case-insensitive. |
/T timeout | The number of seconds to pause before a default choice is made. Acceptable values are from 0 to 9999. If 0 is specified, there will be no pause and the default choice is selected. |
/D choice |
Specifies the default choice after nnnn seconds. The character must be in the set of choices specified by /C option and must also specify nnnn with /T. |
M text |
Specifies the message to be displayed before the prompt. If not specified, the utility displays only a prompt. |
/? | Displays this help message. |
Example
16. clip
This command is used to copy the content to the clipboard. The copied item can further be pasted into other files.
Type: External
Syntax
CLIP < FILE.TXT
It places the content of file.txt onto the windows clipboard?
Example
It copies the current directory listing to the Windows clipboard.
17. cls
This command clears the screen.
Type: Internal
Syntax
cls
clear
Example
18. comp
This command is used to compare two files present in a given directory.
Type: External
Syntax
COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]] [/M]
data1 | Specifies location and name(s) of first file(s) to compare. |
data2 | Specifies location and name(s) of second files to compare. |
/D | Displays differences in decimal format. |
/A | Displays differences in ASCII characters. |
/L | Displays line numbers for differences. |
/N=number | Compares only the first specified number of lines in each file. |
/C | Disregards case of ASCII letters when comparing files. |
/OFF[LINE] | Do not skip files with offline attribute set. |
/M | Do not prompt for compare more files. |
Example
19. compact
This command is used to compress files for utility purposes. It is also used to uncompress so that users can use it.
Type: External
Syntax
COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [/EXE[:algorithm]][/CompactOs[:option] [/WinDir:dir]] [filename [...]]
/C | Compresses the specified files. Directories will be marked so that files added afterward will be compressed unless /EXE is specified. | |
/U | Uncompresses the specified files. Directories will be marked so that files added afterward will not be compressed. If /EXE is specified, only files compressed as executables will be uncompressed; if this is omitted, only NTFS compressed files will be uncompressed. | |
/S |
Performs the specified operation on files in the given directory and all subdirectories. Default "dir" is the current directory. |
|
/A |
Displays files with the hidden or system attributes. These files are omitted by default. |
|
/I | Continues performing the specified operation even after errors have occurred. By default, COMPACT stops when an error is encountered. | |
/F | Forces the compress operation on all specified files, even those which are already compressed. Already-compressed files are skipped by default. | |
/Q | Reports only the most essential information. | |
/EXE |
Use compression optimized for executable files which are read frequently and not modified. Supported algorithms are:
|
|
/CompactOs |
Set or query the system's compression state. Supported options are:
|
|
never | Uncompress all OS binaries and set the system state to non Compact which remains unless administrator changes it | |
/WinDir | Used with /CompactOs:query, when querying the offline OS. Specifies the directory where Windows is installed. | |
filename | Specifies a pattern, file, or directory. |
Example
This will compress the file.txt available in the directory.
20. convert
This command is used to change the FAT volume to NTFS volume.
Type: External
Syntax
CONVERT volume /FS:NTFS [/V] [/CvtArea:filename] [/NoSecurity] [/X]
volume |
Specifies the drive letter (followed by a colon), mount point, or volume name. |
/FS:NTFS | Specifies that the volume will be converted to NTFS. |
/V |
Specifies that Convert will be run in verbose mode. |
/CvtArea:filename | Specifies a contiguous file in the root directory that will be the place holder for NTFS system files. |
/NoSecurity |
Specifies that the security settings on the converted files and directories allow access by all users. |
/X |
Forces the volume to dismount first if necessary. All open handles to the volume will not be valid. |
Example
convert d: /fs:ntfs
This command will convert the FAT volume D into NTFS volume.
21. date
This command is used to display or allow the user to change the current date.
Type: Internal
Syntax
date
Example
22. defrag
This command is used for defragmenting of drives.
Type: Internal
Syntax
Defrag <Volumes> <Operations> [<Options>]
Volumes:
/C | /AllVolumes | On each volume run only the preferred operations from the given list of operations. |
/E | /VolumesExcept <volume paths> | Perform all the given operations on each volume except. those specified. If the exception list is empty, this behaves as /AllVolumes. |
volume paths |
Specifies the drive letter followed by a colon, mount point or volume name. More than one volume can be specified. Run all the given operations on each specified volume. |
Operations:
/A | /Analyze | Perform analysis. |
/B | /BootOptimize | Perform boot optimization to increase boot performance. |
/D | /Defrag | Perform traditional defrag (this is the default). On a tiered volume, traditional defrag is performed only on the Capacity tier. |
/G | /TierOptimize |
On tiered volumes, optimize files to reside on the appropriate storage tier. |
/K | /SlabConsolidate |
On thinly provisioned volumes, perform slab consolidation to increase slab usage efficiency. |
/L | /Retrim | On thinly provisioned volumes, perform retrim to release free slabs. On SSDs perform retrim to improve write performance. |
/O | /Optimize | Perform the proper optimization for each media type. |
/T | /TrackProgress | Track progress of a running operation for a given volume. An instance can show progress only for a single volume. To see progress for another volume launch another instance. |
/U | /PrintProgress | Print the progress of the operation on the screen. |
/V | /Verbose | Print verbose output containing the fragmentation statistics |
/X | /FreespaceConsolidate | Perform free space consolidation, moves free space towards the end of the volume (even on thin provisioned volumes). On tiered volumes consolidation is performed only on the Capacity tier |
Options:
/H | /NormalPriority |
Run the operation at normal priority (default is low). |
/I | /MaxRuntime n |
Available only with TierOptimize. Tier optimization would run for at most n seconds on each volume. |
/LayoutFile <file path> | Available only with BootOptimize. This file contains the list of files to be optimized. The default location is %windir%\Prefetch\layout.ini. |
/M | /MultiThread [n] |
Run the operation on each volume in parallel in the background. For TierOptimize, at most n threads optimize the storage tiers in parallel. Default value of n is 8. All other optimizations ignore n. |
/OnlyPreferred | When volumes are specified explicitly, defrag performs all the given operations on each specified volume. This switch lets defrag run only the preferred operations, from the given list of operations, on each specified volume. |
Example
|
23. del / delete
This command is used to delete one or more files from the current directory.
del command is the same as erase command.
Type:
Internal
Syntax
del filename
Example
In this example above, we have first looked into the available files in the current working directory.
After that, we run the del command to delete one file.
The following command shows that the file is deleted.
24.dir
This command displays the content(which includes files and folders) of the directory we are currently in. It also displays the file's attributes like last updated, mode and size.
Type: Internal
Syntax
dir
Example
25. diskcomp
This command is hardly used now. This command is to compare the content of two floppy disks. But as floppies are hardly used now, we will not go into the details of these commands.
Type: External.
Syntax
DISKCOMP [drive1: [drive2:]]
26. diskcopy
Similarly, this command is used to copy the content of one floppy to another.
Type: External.
Syntax
DISKCOPY [drive1: [drive2:]]
27. doskey
This command is used to edit command lines or use the commands the user has previously executed.
Type:
External
Syntax
DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS[:ALL | :exename]][/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename][macroname=[text]]
/REINSTALL | Installs a new copy of Doskey. |
/LISTSIZE=size | Sets size of command history buffer. |
/MACROS | Displays all Doskey macros. |
/MACROS:ALL | Displays all Doskey macros for all executables which have Doskey macros. |
/MACROS: exename | Displays all Doskey macros for the given executable. |
/HISTORY | Displays all commands stored in memory. |
/INSERT | Specifies that new text you type is inserted in old text. |
/OVERSTRIKE | Specifies that new text overwrites old text. |
/EXENAME=exename | Specifies the executable. |
/MACROFILE=filename | Specifies a file of macros to install. |
macroname | Specifies a name for a macro you create. |
text | Specifies commands you want to record. |
Example
doskey /history
It will show the history of commands that have been run in the MSDOS.
28. driverquery
This command displays the list of drivers installed in the system.
Type: External
Syntax
DRIVERQUERY [/S system [/U username [/P [password]]]][/FO format] [/NH] [/SI] [/V]
Parameter List:
/S system |
Specifies the remote system to connect to. |
/U [domain\]user |
Specifies the user context under which the command should execute. |
/P [password] | Specify the password for the given user context. |
/FO format |
Specifies the type of output to display. Valid values to be passed with the switch are "TABLE", "LIST", "CSV". |
/NH |
Specifies that the "Column Header" should not be displayed. Valid for "TABLE" and "CSV" format only. |
/SI |
Provides information about signed drivers. |
/V | Displays verbose output. Not valid for signed drivers. |
/? |
Displays this help message. |
Example
echo
This command displays any, especially from a batch file.
Type: Internal
Syntax
echo “content”
Example
Here, we have first displayed a message.
In the next command, we have inserted a text into the intro.txt file.
30. edit
This command is used to edit and view files.
Type: External
Syntax
EDIT [/B] [/H] [/R] [/S] [/<nnn>] [/?] [FileName...]
/B | Forces monochrome mode. |
/H | Displays the maximum number of lines possible for your hardware. |
/R | Load file(s) in read-only mode. |
/S | Forces the use of short file names. |
/<nnn> |
Load binary file(s), wrapping lines to <nnn> characters wide. |
/? | Display a summary of command line options. |
[FileName...] | Specifies initial files(s) to load. Wildcards and multiple file specs can be given. |
Example
edit C:\techgeekbuzz\intro.txt
31. exit
This command is used to close the command interpreter. There is no particular syntax for the same. Use the command exit to close the command prompt.
32. expand
This command is used to compress the windows files and extract the files available in the CAB files.
Type: External
Syntax
EXPAND [-R] Source Destination
-R | Rename expanded files. |
-I | Rename expanded files but ignore directory structure |
-D | Display list of files in source. |
Source |
Source file specification. Wildcards may be used. |
-F:Files | Name of files to expand from a .CAB file. |
Destination | Destination file | path specification. Destination may be a directory. If Source is multiple files and -r is not specified, Destination must be a directory |
Example
expand d:\udd\file.dl_ c:\windows\system32\check.dll
33. fasthelp
This command explains the details of any other dos command.
Type: External
Syntax
FASTHELP [command]
Example
fasthelp cd
34. fc
This command accepts two files and displays the difference in them. This can be used to compare two files with the help of DOS thoroughly.
Type: External
Syntax
FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2
/A | Displays only first and last lines for each set of differences. |
/B | Performs a binary comparison. |
/C | Disregards the case of letters. |
/L | Compares files as ASCII text. |
/LBn |
Sets the maximum consecutive mismatches to the specified number of lines. |
/N | Displays the line numbers on an ASCII comparison. |
/OFF[LINE] |
Do not skip files with offline attribute set. |
/T | Does not expand tabs to spaces. |
/U | Compare files as UNICODE text files. |
/W | Compresses white space (tabs and spaces) for comparison. |
/nnnn | Specifies the number of consecutive lines that must match after a mismatch. |
Example
fc techgeekbuzzscript.bat techgeekbuzzbatch.bat
35. find
This command is used to search a text inside a given file. The set of files can be more than one.
Type: External
Syntax
FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "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. |
/OFF[LINE] | Do not skip files with offline attribute set. |
"string" | Specifies the text string to find. |
[drive:][path]filename | Specifies a file or files to search. |
Example
find /N "this" c:\techgeekbuzz\intro.txt
This command will display the line number of the selected text.
36. findstr
This command locates a file that contains the provided text. This is different from find as that searches for a text inside a file, and this searches for the file of that text.
Type: External
Syntax
FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file][/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]] strings [[drive:][path]filename[ ...]]
/B | Matches pattern if at the beginning of a line. |
/E | Matches pattern if at the end of a line. |
/L |
Uses search strings literally. |
/R | Uses search strings as regular expressions. |
/S | Searches for matching files in the current directory and all subdirectories. |
/I | Specifies that the search is not to be case-sensitive. |
/X | Prints lines that match exactly. |
/V | Prints only lines that do not contain a match. |
/N | Prints the line number before each line that matches. |
/M | Prints only the filename if a file contains a match. |
/O | Prints character offset before each matching line. |
/P | Skip files with non-printable characters. |
/OFF[LINE] | Do not skip files with offline attribute set. |
/A:attr | Specifies color attribute with two hex digits. See "color /?" |
/F:file | Reads file list from the specified file(/ stands for console). |
/C:string | Uses specified string as a literal search string. |
/G:file | Gets search strings from the specified file(/ stands for console). |
/D:dir | Search a semicolon delimited list of directories |
strings |
Text to be searched for. |
[drive:][path]filename | Specifies a file or files to search. |
Example
findstr "this" *.txt
This command will print all the lines that contain the text “this” in all available text files.
37. for
This command is a variable that is used inside batch files to run specific commands.
Type: Internal
Syntax
FOR %variable IN (set) DO command [command-parameters]
%variable | An arbitrary parameter. |
(fileset) | Specifies a set of one or more files. Wildcards may be used. |
command | Specifies the command to carry out for each file. |
command-parameters | Specifies parameters or switches for the specified command. |
Example
for /F %%A in ("intro.txt") do If %%~zA equ 10 del intro.txt
The above command will execute over intro.txt. If the file is found in the current directory and the size is 10, it will be deleted.
38. format
This command is used to format a disk with windows
Type: External
Syntax
FORMAT volume [/FS:file-system] [/V:label] [/Q] [/L[:state]] [/A:size] [/C] [/I:state] [/X] [/P:passes] [/S:state]
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, exFAT, NTFS, UDF, ReFS). |
/V:label | Specifies the volume label. |
/Q | Performs a quick format. Note that this switch overrides /P. |
/C |
NTFS only: 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.
|
/R:revision | UDF only: Forces the format to a specific UDF version(1.02, 1.50, 2.00, 2.01, 2.50). The default revision is 2.01. |
/D |
UDF 2.50 only: Metadata will be duplicated.
|
/L[:state] | NTFS Only: Overrides the default size of file record. By default, a non-tiered volume will be formatted with small size file records and a tiered volume will be formatted with large size file records. |
/L and /L | Enable forces format to use large size file records and /L:disable forces format to use small size file records. |
Example
39. ftp
FTP is a file transfer protocol. This command is used to transfer files to and from a computer running an FTP server service.
Type: External
Syntax
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuffer] [-b:asyncbuffers] [-w:windowsize] [host]
-v | Suppresses display of remote server responses. |
-n | Suppresses auto-login upon initial connection. |
-i |
Turns off interactive prompting during multiple file transfers. |
-d | Enables debugging. |
-g | Disables filename globbing (see GLOB command). |
-s:filename | Specifies a text file containing FTP commands; the commands will automatically run after FTP starts. |
-a |
Use any local interface when binding data connection. |
-A | login as anonymous. |
-x:send sockbuf | Overrides the default SO_SNDBUF size of 8192. |
-r:recv sockbuf | Overrides the default SO_RCVBUF size of 8192. |
-b:async count |
Overrides the default async count of 3 |
-w:windowsize | Overrides the default transfer buffer size of 65535. |
host |
Specifies the host name or IP address of the remote host to connect to. |
Example
This command will enable the debugging for all the next commands.
40. goto
This command moves a file to a specified location.
Type: Internal
Syntax
GOTO label
label Specifies a text string used in the batch program as a label.
Example
GOTO start
41. help
This command displays detailed information of any other command. If you type help in PowerShell, it will display help about PowerShell cmdlets and concepts. A more precise way to use this is with the shortcut “/?”
Type: External
Syntax
[Any command] /?
Example
42. if
This command is a conditional expression inside a batch file.
Type: Internal
Syntax
IF [NOT] ERRORLEVEL number command
NOT Specifies that Windows 2000 or XP should carry out the command only if the condition is false.
ERRORLEVEL number Specifies a true condition if the last program run returned an exit code equal to or greater than the number specified.
Example
IF EXIST intro.txt. (
del intro.txt.
)
ELSE(
echo intro.txt. missing.
)
43. ipconfig
This command displays the network setting that includes the IP address associated with all ethernet adapters in the machine.
Type: External
Syntax
ipconfig [/allcompartments] [/? | /all |
/renew [adapter] | /release [adapter] |
/renew6 [adapter] | /release6 [adapter] |
/flushdns | /displaydns | /registerdns |
/showclassid adapter |
/setclassid adapter [classid] |
/showclassid6 adapter |
/setclassid6 adapter [classid] ]
where,
adapter Connection name (wildcard characters * and ? allowed, see examples)
Options :
/? | Display this help message. |
/all | Display full configuration information |
/release |
Release the IPv4 address for the specified adapter. |
/release6 | Release the IPv6 address for the specified adapter. |
/renew | Renew the IPv4 address for the specified adapter. |
/renew6 | Renew the IPv6 address for the specified adapter. |
/flushdns | Purges the DNS Resolver cache. |
/registerdns | Refreshes all DHCP leases and re-registers DNS names |
/displaydns | Display the contents of the DNS Resolver Cache. |
/showclassid | Displays all the dhcp class IDs allowed for adapter. |
/setclassid | Modifies the dhcp class id. |
/showclassid6 | Displays all the IPv6 DHCP class IDs allowed for adapter. |
/setclassid6 |
Modifies the IPv6 DHCP class id. |
Example
44. label
This command is used to manage the label of existing drives in the machine. It can create, change or delete the label of a disk.
Type: External
Syntax
LABEL [drive:][label]
LABEL [/MP] [volume] [label]
drive: | Specifies the drive letter of a drive. |
label | Specifies the label of the volume. |
/MP | Specifies that the volume should be treated as a mount point or volume name. |
volume | Specifies the drive letter (followed by a colon), mount point, or volume name. If volume name is specified, the /MP flag is unnecessary. |
Example
45. logoff
This command is used to terminate the current session.
Type: External
Syntax
LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V] [/VM]
sessionname | The name of the session. |
sessionid | The ID of the session. |
/SERVER:servername | Specifies the Remote Desktop server containing the user session to log off (default is current). |
/V | Displays information about the actions performed. |
/VM | Logs off a session on server or within virtual machine. The unique ID of the session needs to be specified |
Example
logoff
46. logon
This command is a recovery console command to enable administrator login.
Type: External
47. map
This is a recovery console command to display the device name of a drive.
Type : Internal
Syntax
map [arc]
arc is an option to provide information to map command about the device names.
48. md/ mkdir
This command is used to create a directory.
Type: Internal
Syntax
md [folder name]
We see that a new folder name dosCheatSheet is created.
49. mode
This command is used to configure system devices or display the settings of the machine.
Type: External
Syntax
Serial port: MODE COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s]
[to=on|off] [xon=on|off] [odsr=on|off]
[octs=on|off] [dtr=on|off|hs]
[rts=on|off|hs|tg] [idsr=on|off]
Device Status | MODE [device] [/STATUS] |
Redirect printing | MODE LPTn[:]=COMm[:] |
Select code page | MODE CON[:] CP SELECT=yyy |
Code page status | MODE CON[:] CP [/STATUS] |
Display mode | MODE CON[:] [COLS=c] [LINES=n] |
Typematic rate |
MODE CON[:] [RATE=r DELAY=d] |
Example
Typing just mode will print all the ports
50. more
This command is used to display the content of a file, one page at a time.
Type: External
Syntax
more [filename]
51. move
This command is used to move a file from one directory to another.
Type: External
Syntax
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
[drive:][path]filename1 | Specifies the location and name of the file or files you want to move. |
destination |
Specifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a filename if you want to rename the file when you move it. |
[drive:][path]dirname1 | Specifies the directory you want to rename. |
dirname2 | Specifies the new name of the directory. |
/Y | Suppresses prompting to confirm you want to overwrite an existing destination file. |
/-Y | Causes prompting to confirm you want to overwrite an existing destination file. |
Example
As seen in the image above, we have moved the dos.txt from dosCheatSheet folder to techgeekbuzz
52. nbtstat
NBT stands for NETBIOS over TCP. This command is used to display protocol statistics and TCP connections.
Type: External
Syntax
NBTSTAT [ [-a RemoteName] [-A IP address] [-c] [-n][-r] [-R] [-RR] [-s] [-S] [interval] ]
-a (adapter status) | Lists the remote machine's name table given its name. |
-A (Adapter status) |
Lists the remote machine's name table given its IP address. |
-c (cache) | Lists NBT's cache of remote [machine] names and their IP addresses. |
-n (names) | Lists local NetBIOS names. |
-r (resolved) | Lists names resolved by broadcast and via WINS. |
-R (Reload) | Purges and reloads the remote cache name table. |
-S (Sessions) | Lists sessions table with the destination IP addresses. |
-s (sessions) | Lists sessions table converting destination IP addresses to computer NETBIOS names. |
-RR (ReleaseRefresh) | Sends Name Release packets to WINS and then, starts Refresh. |
Example
53. net
This command is used to update and fix the network settings.
Type: External
Syntax
NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
STATISTICS | STOP | TIME | USE | USER | VIEW ]
Example
net send tgb "Hi"
This command will send “Hi” message to remote host named tgb.
54. netsh
This command is used to set dynamic and static network information.
Type: External
Syntax
Usage: C:\Windows\system32\netsh.exe [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]UserName] [-p Password | *] [Command | -f ScriptFile]
Example
This command helps user to see network configuration.
55. netstat
This command helps the user to see the TCP/IP network protocol information.
Type: External
Syntax
NETSTAT [-a] [-b] [-e] [-f] [-i] [-n] [-o] [-p proto] [-r] [-s] [-t] [-x] [-y] [interval]
-a | Displays all connections and listening ports. |
-b | Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions. |
-e | Displays Ethernet statistics. This may be combined with the -s option. |
-f | Displays Fully Qualified Domain Names (FQDN) for foreign addresses. |
-i | Displays the time spent by a TCP connection in its current state |
-n | Displays addresses and port numbers in numerical form. |
-o | Displays the owning process ID associated with each connection. |
-p proto | Shows connections for the protocol specified by proto; proto may be any of: TCP, UDP, TCPv6, or UDPv6. If used with the -s option to display per-protocol statistics, proto may be any of: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6. |
-q | Displays all connections, listening ports, and bound nonlistening TCP ports. Bound nonlistening ports may or may not be associated with an active connection. |
-r | Displays the routing table. |
-s | Displays per-protocol statistics. By default, statistics are shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6; the -p option may be used to specify a subset of the default. |
-t |
Displays the current connection offload state. |
-x | Displays NetworkDirect connections, listeners, and shared endpoints. |
-y | Displays the TCP connection template for all connections.Cannot be combined with the other options. |
interval | Redisplays selected statistics, pausing interval seconds between each display. Press CTRL+C to stop redisplaying statistics. If omitted, netstat will print the current configuration information once. |
Example
56. nslookup
This command is used to lookup an IP address on a network.
Type: External
Syntax
Usage:
nslookup [-opt ...]
nslookup [-opt ...] - server
nslookup [-opt ...] host
nslookup [-opt ...] host server
Example
57. path
This command is used to display or set the search path for any executable file.
Type: Internal
Syntax
PATH [[drive:]path[;...][;%PATH%]
PATH ;
path=c:\windows\command
The command above would set the path to c:\windows\command. For all the future commands, this will be the executable path.
58. pause
This command is used to suspend the processing of a batch command and display any message.
Type: Internal
59. ping
This command is used to test and send information packets to another network.
Type: External
Syntax
Ping [hostaddress]
60. popd
This command is used to change to a directory stored by the PUSHD command.
Type: Internal
Syntax
popd [OPTIONS] [DIRECTORY]
61. prompt
This command is used to change the DOS prompt.
Type: Internal
Syntax
PROMPT [text]
prompt $t $d$_$p$g
Display the time and the date above your prompt when in DOS
62. rd
This command is used to remove an empty directory.
Type: External
Syntax
RD [directory]
63. ren/rename
This command is used to rename a directory or a file.
Type: External
Syntax
RENAME [drive:][path][directory name1 | file name1] [directory name2 | file name2]
REN [drive:][path][directory name1 | file name1] [directory name2 | file name2]
Example
64. rmdir
This command is used to remove an empty directory.
Type: External
Syntax
rmdir [directory]
65. route
This command is used to manipulate network routing tables.
Type: External
Syntax
ROUTE [-f] [-p] [-4|-6] command [destination][MASK netmask] [gateway] [METRIC metric] [IF interface]
-f | Clears the routing tables of all gateway entries. If this is used in conjunction with one of the commands, the tables are cleared prior to running the command. |
-p | When used with the ADD command, makes a route persistent across boots of the system. By default, routes are not preserved when the system is restarted. Ignored for all other commands, which always affect the appropriate persistent routes. |
-4 | Force using IPv4. |
-6 | Force using IPv6. |
Example
66. runas
This command enables a user to run a file as a different user.
Type: External
Syntax
RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ] /user:<UserName> program
RUNAS [ [/noprofile | /profile] [/env] [/savecred] ] /smartcard [/user:<UserName>] program
RUNAS /trustlevel:<TrustLevel> program
/noprofile | Specifies that the user's profile should not be loaded. This causes the application to load more quickly, but can cause some applications to malfunction. |
/profile |
Specifies that the user's profile should be loaded. This is the default. |
/env |
To use current environment instead of user's. |
/netonly |
Use if the credentials specified are for remote access only. |
/savecred | To use credentials previously saved by the user. |
/smartcard | Use if the credentials are to be supplied from a smartcard. |
/user |
<UserName> should be in form USER@DOMAIN or DOMAIN\USER. |
/showtrustlevels | Displays the trust levels that can be used as arguments to /trustlevel. |
/trustlevel | <Level> should be one of levels enumerated in /showtrustlevels. |
program | Command line for EXE. |
Example
67. sc
This command is used to communicate with the service manager.
Type: External
Syntax
sc <server> [command] [service name] <option1> <option2>...
Example
sc delete abc.exe
68. scandisk
This command is used to scan the hard drives.
Type: External
Syntax
scandisk [ drive: | volume_name | /all] [/checkonly | /autofix [/nosave] | /custom] [/fragment] [/surface] [/mono] [/nosave] [/nosummary]
.
drive: | The drive letter you want to scan. |
volume_name | The name of the unmounted compressed volume. |
/all | Checks and repairs all the local drives at once. |
/checkonly | Checks drive for errors but will not make repairs. |
/autofix | Fixes errors without asking you first. Saves lost clusters by default as files in the drive's root directory. Cannot be used with /checkonly or /custom. |
/custom |
Runs ScanDisk using the settings in the [custom] section of the scandisk.ini file. Cannot be used with /autofix or /checkonly. |
/surface | Automatically checks surface after other areas are tested without prompting you first. When used with /custom, overrides any /surface setting in the [Custom] section of scandisk.ini. |
/fragment | Checks individual files for fragmentation. Must specify a drive, path, and file name; cannot use any other switches. |
/mono | Uses a monochrome display instead of color. |
/nosave | Deletes all lost clusters found by ScanDisk. Can be used with /autofix. |
/nosummary | Prevents display of full-screen summary after each drive. Use with /autofix to prevent prompts for undo diskette |
69. set
This command is used to display, set, or remove cmd.exe environment variable.
Type: Internal
Syntax
SET [variable=[string]]
variable Specifies the environment-variable name.
string Specifies a series of characters to assign to the variable.
Example
70. setlocal
This command is used to begin localization of environment changes in a batch file.
Type: Internal
Syntax
SETLOCAL
If Command Extensions are enabled SETLOCAL changes as follows:
SETLOCAL batch command now accepts optional arguments:
ENABLEEXTENSIONS / DISABLEEXTENSIONS : enable or disable command processor extensions. These arguments takes precedence over the CMD /E:ON or /E:OFF switches. See CMD /? for details.
ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION : enable or disable delayed environment variable expansion. These arguments takes precedence over the CMD /V:ON or /V:OFF switches. See CMD /? for details.
71. shift
This command is used to change the position of replaceable parameters in a batch file.
Type: External
Syntax
SHIFT [/n]
72. shutdown
This command is used to shut down the machine.
shutdown
72. start
This command is used to start a separate window to run a specified program.
Type: External
Syntax
START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B] [command/program] [parameters]
"title" | Title to display in window title bar. |
path | Starting directory. |
B | Start application without creating a new window. The application has ^C handling ignored. Unless the application enables ^C processing, ^Break is the only way to interrupt the application. |
I | The new environment will be the original environment passed to the cmd.exe and not the current environment. |
MIN | Start window minimized. |
MAX | Start window maximized. |
SEPARATE | Start 16-bit Windows program in separate memory space. |
SHARED | Start 16-bit Windows program in shared memory space. |
LOW | Start application in the IDLE priority class. |
NORMAL | Start application in the NORMAL priority class. |
HIGH | Start application in the HIGH priority class. |
REALTIME | Start application in the REALTIME priority class. |
ABOVENORMAL | Start application in the ABOVENORMAL priority class. |
BELOWNORMAL |
Start application in the BELOWNORMAL priority class. |
NODE |
Specifies the preferred Non-Uniform Memory Architecture (NUMA) node as a decimal integer. |
AFFINITY | Specifies the processor affinity mask as a hexadecimal number. |
Example
74. subst
This command is used to associate a path to a drive letter.
Type: External
Syntax
SUBST [drive1: [drive2:]path]
SUBST drive1: /D
drive1: Specifies a virtual drive to which you want to assign a path.
75. time
This command displays the time.
Example
76. title
This command is used to change the title of the DOS window.
Example
77. type
This command is used to display the contents of a text file or files.
Type: External
Syntax
TYPE [drive:][path]filename
78. ver
This command tells the version of the current operating system.
Example
79. verify
This command is used to verify whether the files are written correctly on a disk or not.
Type: Internal
Syntax
VERIFY [ON | OFF]
80. vol
This command is used to display the disk volume label and its serial number.
Type: Internal
Syntax
vol
Example
81. xcopy
This command copies the file and directory.
Type: External
Syntax
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B] [/J]
[/EXCLUDE:file1[+file2][+file3]...] [/COMPRESS]
source |
Specifies the file(s) to copy. |
destination | Specifies the location and/or name of new files. |
/A | Copies only files with the archive attribute set, doesn't change the attribute. |
/M | Copies only files with the archive attribute set, turns off the archive attribute. |
/D:m-d-y | 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. |
/EXCLUDE:file1[+file2][+file3]... |
Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the.obj extension respectively. |
/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. |
/V | Verifies the size of each new file. |
/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. |
/G | Allows the copying of encrypted files to destination that does not support encryption. |
/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 |
Copies only files that already exist in destination |
/K | Copies attributes. Normal Xcopy will reset read-only attributes. |
/N | Copies using the generated short names. |
/O | Copies file ownership and ACL information. |
/X | Copies file audit settings (implies /O). |
/Y |
Suppresses prompting to confirm you want to overwrite an existing destination file. |
/-Y | Causes prompting to confirm you want to overwrite an existing destination file. |
/Z | Copies networked files in restartable mode. |
/B | Copies the Symbolic Link itself versus the target of the link. |
/J | Copies using unbuffered I/O. Recommended for very large files. |
/COMPRESS | Request network compression during file transfer where applicable. |
Example
This command copies all the content of the current folder to the temp folder.
Conclusion
Most of the DOS commands mentioned above have a screenshot of their execution to help you out more effectively. Although we have tried to mention the syntax of each command, there exist some commands which don’t have any specific syntax. For example, time. Users can just write that command in the command prompt to execute it.
There are possibilities that the commands mentioned above will get updated with a new OS release. If you find any update or have any command in mind, which is essential and not mentioned in the article, then feel free to mention that in the comment below. Also, please comment below if you have any questions and find this article vague/helpful/excellent!
People are also reading
Leave a Comment on this Post