Cheat Sheet of MSDOS DOS Command

Description

Equivalent LINUX Commands (Case sensitive)

Sample Code Snippet

ASSOC ATTRIB BREAK BCDEDIT

Displays or modifies file extension associations. Displays or changes file attributes. Sets or clears extended CTRL+C checking. Sets properties in boot database to control boot loading.

N/A chmod N/A grub*

assoc attrib -s -r -h BREAK [ON | OFF] bcdedit /export

CACLS CALL CD/CHDIR CHCP CHKDSK CHKNTFS CLS CMD

Displays or modifies access control lists (ACLs) of files. Calls one batch program from another. Displays the name of or changes the current directory. Displays or sets the active code page number. Checks a disk and displays a status report. Displays or modifies the checking of disk at boot time. Clears the screen. Starts a new instance of the Windows command interpreter.

chmod and chown exec cd N/A fsck fsck clear bash/tcsh/zsh/ksh

cacls /g :f call cd chcp chkdsk : chkntfs : cls cmd

COLOR

Sets the default console foreground and background colors.

COMP COMPACT

Compares the contents of two files or sets of files. Displays or alters the compression of files on NTFS partitions.

diff N/A

comp compact

CONVERT

Converts FAT volumes to NTFS. You cannot convert the current drive.

N/A

CONVERT : /FS:NTFS

COPY DATE DEL DIR DISKCOMP

Copies one or more files to another location. Displays or sets the date. Deletes one or more files. Displays a list of files and subdirectories in a directory. Compares the contents of two floppy/removable disks.

cp date rm –iv ls –l N/A

copy date /T del dir diskcomp a: b:

DISKCOPY

Copies the contents of one floppy disk to another.

N/A

diskcopy a: b:

color A

Prepared by Shuvradeb Barman Srijon (iamsrijon)

DISKPART DOSKEY

Displays or configures Disk Partition properties. Edits command lines, recalls Windows commands, and create marcos.

fdisk/parted N/A

DOSKEY ls=dir

DRIVERQUERY ECHO

Displays current device driver status and properties. Displays messages, or turns command echoing on or off.

N/A echo

driverquery echo %SomeVariable%

ENDLOCAL

Ends localization of environment changes in a batch file.

N/A

endlocal

ERASE EXIT FC

Deletes one or more files. Quits the CMD.EXE program (command interpreter). Compares two files or sets of files, and displays the differences between them.

rm exit diff

erase

FIND FOR

Searches for a text string in a file or files. Runs a specified command for each file in a set of files.

grep for/while/foreach

find For /f "tokens=2-4 delims=/ " %%a in ('date /T') do (set mydate=%%b-%%a-%%c)

FORMAT FSUTIL FTYPE

Formats a disk for use with Windows. Displays or configures the file system properties. Displays or modifies file types used in file extension associations.

GOTO

Directs the Windows command interpreter to a labeled line in a batch program.

GPRESULT GRAFTABL

Displays Group Policy information for machine or user. Enables Windows to display an extended character set in graphics mode.

HELP ICACLS IF

N/A

fc

format : /Q /FS:NTFS fsutil volume diskfree : ftype goto SomeLabel

N/A N/A

gpresult /R graftabl

Provides Help information for Windows commands. Display, modify, backup, or restore ACLs for files and directories.

chmod and chown

help icacls /grant :(D,WDAC)

Performs conditional processing in batch programs.

If

Prepared by Shuvradeb Barman Srijon (iamsrijon)

IF EXIST filename ( del filename ) ELSE ( echo filename missing. )

LABEL

Creates, changes, or deletes the volume label of a disk.

N/A

label :

MD MKDIR MKLINK MORE MOVE

Creates a directory. Creates a directory. Creates Symbolic Links and Hard Links Displays output one screen at a time. Moves one or more files from one directory to another directory.

mkdir mkdir ln more mv

md mkdir mklink more move /Y

NET OPENFILES

Manipulate a windows service Displays files opened by remote users for a file share.

service rsync

net start Openfiles /query /s /u /p

PATH PAUSE

Displays or sets a search path for executable files. Suspends processing of a batch file and displays a message.

PRINT PROMPT

Prints a text file. Changes the Windows command prompt.

RECOVER

Recovers readable information from a bad or defective disk.

REM

Records comments (remarks) in batch files or CONFIG.SYS.

#

rem some comment

REN/RENAME REPLACE RMDIR/RD ROBOCOPY

Renames a file or files. Replaces files. Removes a directory. Advanced utility to copy files and directory trees

mv cp –f rmdir rsync

SET

Displays, sets, or removes Windows environment variables.

set

ren replace rd ROBOCOPY \\Computer1\reports \\Computer2\backup *.doc /S SET variable=value echo %variable%

SETLOCAL

Begins localization of environment changes in a batch file.

SC

Displays or configures services (background processes).

service

sc start

SCHTASKS

Schedules commands and programs to run on a computer.

crontab

schtasks /create /sc hourly /st /tn /tr

N/A

path pause

lpr Change the prompt to Cruuent Time: prompt $T recover :[path]filename

Prepared by Shuvradeb Barman Srijon (iamsrijon)

SHIFT

Shifts the position of replaceable parameters in batch files.

SHUTDOWN

Allows proper local or remote shutdown of machine.

shutdown now/init 0

To shutdown: shutdown /s /t 0 To restart: shutdown /r /t 0

SORT START

Sorts input. Starts a separate window to run a specified program or command.

sort

sort start

SUBST SYSTEMINFO

Associates a path with a drive letter. Displays machine specific properties and configuration.

mount dmidcode

subst : systeminfo

TASKLIST TASKKILL TIME TITLE TREE

Displays all currently running tasks including services. Kill or stop a running process or application. Displays or sets the system time. Sets the window title for a CMD.EXE session. Graphically displays the directory structure of a drive or path.

ps -ef kill date ls -R

tasklist taskkill /ID time /T title tree

TYPE VER VERIFY

Displays the contents of a text file. Displays the Windows version. Tells Windows whether to verify that your files are written correctly to a disk.

cat uname -a N/A

type ver verify [ON | OFF]

VOL XCOPY WMIC

Displays a disk volume label and serial number. Copies files and directory trees. Displays Windows Management Instrumentation (WMI) information inside interactive command shell.

vol_id --uuid cp -R N/A

vol : xcopy It starts a CLI which accept multiple commands, for help /?

Prepared by Shuvradeb Barman Srijon (iamsrijon)

Some Useful Code Blocks To set a variable from user input set /p =

To go back to the drive root CD\

To read and print a file line by line FOR /F "tokens=*" %i IN () DO @echo %i

To move one level up CD..

For fast help /?

To remove a Directory and Subdirectory RD /S

To create/trunk and write into a file echo >

To print special characters ( >, >

To format a drive to NTFS format : /FS:NTFS

To redirect input from file (Ex. to set date from file) date <

Prepared by Shuvradeb Barman Srijon (iamsrijon)

To run FTP scripts ftp -s: Sample FTP Script content ftpuser ftppass SomeFTPCommands Technique to apply sleep (as there is no sleep command) ping -n 1 -w > nul To set IP and DNS to Ethernet port (Ex. Interface Name = Local Area Connection) netsh interface ip set address name="Local Area Connection" static netsh interface ip set dns "Local Area Connection" static netsh interface ip set wins "Local Area Connection" static To view IP Configurations ipconfig /all To view all entries of ARP table arp –a To view Network Connections netstat To view routing configurations route print To add a persistent route route add mask -p

Prepared by Shuvradeb Barman Srijon (iamsrijon)