Ever wanted to get the best discounts? Get up to 20% off. View offers


Disclosure: Hackr.io is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.

Download Windows Command Line Cheat Sheet PDF

Posted in Commands
Windows Command line Cheat Sheet

Windows is the world’s most commonly used operating system, providing several features and applications to ease your work. One important yet sometimes overlooked built-in feature is the command prompt. With it, you can manage your entire system from a single interface with the help of commands.

Windows cmd commands are abundant, allowing you to perform various useful tasks without navigating through the system. But it’s tricky to remember every single one. That’s why we curated a Windows command line cheat sheet with Windows terminal commands – to help experienced and beginner programmers make the best use of Windows commands.

You can keep this Windows command prompt cheat sheet handy and refer to it when you want to perform any task.

Click here to download Windows Command Line Cheat Sheet PDF.

Let’s get started with the list of commands.

Windows Command Line Cheat Sheet

Scroll through this cheat sheet to see Windows command line commands by category.

Net Users

Net user allows you to add, remove, and alter the user accounts via command prompt. You can simply execute the command on various systems, such as Windows, including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server Operating Systems, and some older versions of Windows.


net user [username [password | *] [/add] [options]] [/domain]] [username [/delete] [/domain]] [/help] [/?]


  • net user: You can run “net user” alone without the option to check the list of every active or inactive user for that specific computer.
  • username: A username can be 20 characters long, and you can add or remove the username.
  • password: You can use this option to change an existing password or assign a new one while creating a new username. This command will also tell you the minimum characters required for a password.
  • *: You can use this instead of a password that forces you to enter the password in the Command Prompt window once you hit the net user command.
  • /add: This command adds a new username on the system.
  • options: These are the additional Net User Command Options that you can use while executing net user. The next table displays the list of several options available.
  • /domain: You can run the command on the current domain controller rather than on the local computer.
  • /delete: This command will remove the specified username.
  • /help: You will get detailed information about the net user command.
  • /?: This is the standard help command for displaying the command options, mentioned in the below table.

Additional Net User Command Options



/active:{yes | no}

Activates or deactivates the specified user account; default value is yes


Takes a maximum of 48 characters; text is viewable in the Description field


Sets a country code for the user to determine the language used for error and help messages (default, value is 000)

/expires:{date | never}

Sets a specific date when the account should expire (default is no expiry)

date (with /expires only)

Sets or displays the current date in mm/dd/yy or mm/dd/yyyy format


Mentions the real name of the person using the account


Sets a pathname if you want a home directory other than the default

/passwordchg:{yes | no}

Specifies whether the user can change their password (default is yes)

/passwordreq:{yes | no}

Specifies whether this user is required to have a password at all (default is yes)

/logonpasswordchg:{yes | no}

Forces user to change their password at the next login


Sets a pathname for the user's login profile


Sets a pathname for the user's login script

/times:[timeframe | all]

Specifies a timeframe for which the user can log on

timeframe (with /times only)

Specifies a timeframe

The format is as follows:

  • Days of the week - MTWThFSaSu.
  • Times-24-hour or 12-hour format using AM and PM or A.M. and P.M.
  • Periods of time should use dashes; date and time should be separated by commas and day/time groups by semicolons.


Adds or changes the User Comment for the specified account.

Master Windows CLI 
Windows Command Line Course


The Windows system organizes every file and folder. Windows also allows you to perform tasks on your files and directories, such as copying, creating, removing, etc. This section lists some commands that will help you to perform directory tasks.


dir [drive:][path][filename] [/a[[:]attributes]] [/b] [/c] [/d] [/l] [/n] [/o[[:]sortorder]] [/p] [/q] [/r] [/s] [/t[[:]timefield]] [/w] [/x] [/4]

Dir Command Options



drive:, path, filename

Specifies the drive, path, and filename that you want to check. You can even run the command alone without options, and Wildcards are allowed.


You can use /a with the following attributes to show specific results within all file and folder types:

a = archive files

d = directories

h = hidden files

i = not content indexed files

l = reparse points

r = read-only files

s = system files

v = integrity files

x = no scrub files

You must use (-) as a prefix to the above attributes for excluding some items with those file attributes from the results.


Shows directory information in the "bare" format (only directory name or file name and extension)


Displays file sizes(to disable, use /-c)


Displays the folders and file names with their extensions.


Displays all folder and file names in lowercase


Provides you a result with columns in the date > time > directory > file size > file or folder name column structure. Being the default behavior, you need to use /-n to create columns in the file or folder name > directory > file size > date > time order.


Specifies the sort order for the results. Without any option, /o will list the directories first, followed by files, in alphabetical order. You can use this option with one or more of the following values:

  • d = sort by date/time (oldest first)
  • e = sort by an extension (alphabetical)
  • g = group directory first, followed by files
  • n = sort by name (alphabetical)
  • s = sort by size (smallest first)
  • You must use (-) as a prefix with any of the above values to reverse the order.


Shows one result page at a time, as well as this prompt: “you can press any key to continue”


Shows the owner of the file or folder


Shows alternate data streams (ADS)


Shows all the files and folders in the specified directory including in subdirectories


Specifies a time field to sort and display the results:

a = last access

c = created

w = last written


Shows the results in "wide format" that are limited to just folders and file names with their extensions


Shows the "short name" equivalent for files whose long names don't comply with non-8dot3 rules


Changes format to 4-digit years

Below are some more commands that will let you move through the directories and perform actions.




Takes you to the top of the directory tree


Takes you one folder up


Lists all the files and content, including folders contained along with some details about each of them

mkdir [folder_name]

Creates a new folder in the current directory

mkdir folder_name\sub_folder1\sub_folder2

Creates a folder with subfolders at the same time in a tree-like structure

ren [old_folder] [new_folder]

Renames an old folder name with a new folder name



cd /d d:

Changes the drive

cd Folder

cd %VAGRANT_HOME% ← cmd

cd $env:VAGRANT_HOME ← powerhsell

Changes the current directory


Displays the directory structure of a path or of the disk

  • rd DIRECTORY ← empty directory
  • rd Folder1\Folder2 ← Delete only Folder2
  • rd DIRECTORY /s ← including all files
  • rd DIRECTORY /s /q ← quiet mode

Deletes the directory

File management




syntax- attrib [+a|-a] [+h|-h] [+i|-i] [+r|-r] [+s|-s] [+v|-v] [+x|-x] [drive:][path][filename] [/s [/d] [/l]]

These commands list file attributes:

  • +a Sets the archive file attribute to the file or directory
  • -a Clears the archive attribute
  • +h Sets the hidden file attribute to the file or directory
  • -h Clears the hidden attribute
  • +i Sets the 'not content indexed' file attribute to the file or directory
  • -i Clears the 'not content indexed' file attribute
  • +r Sets the read-only file attribute to the file or directory
  • -r Clears the read-only attribute
  • +s Sets the system file attribute to the file or directory
  • -s Clears the system attribute
  • +v Sets the integrity file attribute to the file or directory
  • -v Clears the integrity attribute
  • +x Sets the no scrub file attribute to the file or directory
  • -x Clears the no scrub attribute
  • drive: path, filename: Specifies the file, directory, or drive for which you want to change the attributes. You can also use the wildcard.
  • /s Execute the file attribute display or changes you're making on the subfolders within a specific drive and/or path
  • /d Includes directories in execution; only works with /d with /s.
  • /l Applies whatever you're doing with the attrib command to the Symbolic Link itself instead of the target of the Symbolic Link


syntax- comp Data1 Data2 [/d] [/a] [/l] [/n=Number] [/c] [/?]

These commands compare file contents:

  • D  Changes display output from hexadecimal encoded to decimal format
  • a  Displays differences as characters instead of hexadecimal or decimal codes
  • n  Compares the number of lines specified in each file, even if the files are different sizes
  • c  Performs a case insensitive search as opposed to the default case-sensitive search
  • /? Displays help for the command


syntax- compact filename

Compresses or uncompresses files on an NTFS file system

copy file_name folder

copy /y file1 file2 (supress the prompt to overwrite an existing destination)

Copies files


Compares the content of two floppy disks


Copies floppy disc to another one

del FILE

del /Q FILE

← /Q : Quiet mode, do not give a Yes/No Prompt before deleting.

del /S FILE

← /S Delete from all Subfolders (DELTREE)

del /F FILE

← /F : Ignore read-only setting and delete anyway (FORCE)

erase FILE

Deletes one or more files


syntax- expand source [destination] [/r] [/i] [/d] [/f [:filespec]] [/y]

/r Decompresses the compressed file

I  Ignores the directory structure

d  Lists the files contained in the source but doesn't extract them

/f:filespec Extracts selected file from the source file

y  Prevents the command from informing you


Creates a new directory


syntax- MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

MOVE  Moves/renames files

/Y Suppresses the prompt to confirm you want to overwrite an existing destination file

/-Y  Causes the prompt to confirm you want to overwrite an existing destination file


rename SRC DES

Renames files


syntax- REPLACE [Drive:][path]SourceFiles [Drive:][path2] [/A] [/P] [/R] [/W]

REPLACE [Drive:][path]SourceFiles [Drive:][path2] [/S] [/P] [/R] [/W] [/U]

Replaces files

Path/files– Indicates the source files, accepts wildcards.

path2– Provides the destination folder, default current drive, and directory as the destination

/A– Includes all the missing files

/P– Provides the prompt for confirmation for each file

/R– Replaces even “read-only: file

/S– Includes all subfolders of the destination

/W– Waits/pauses, or Inserts a floppy disk

/U– Updates only files that are older than the source

rmdir / rd

syntax- RMDIR [/S] [/Q] [drive:]path

RD [/S] [/Q] [drive:]path

rmdir / rd deletes a directory

/S  Removes all directories and files in the specified directory in addition to the directory itself

/Q Specifies the quiet mode. There is not need to ask whether to delete a specific directory tree with /S


syntax- TREE [d:][path] [/A][/F]

Shows the folder structure graphically (tree-like)

type file_name

more file_name

Shows the content of text files


robocopy "C:\data" "\\\C$\data" /mir

robocopy d: g: /mir

robocopy more

Mirrors a directory tree


Prompts file editing


syntax- FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2

FC /B [drive1:][path1]filename1 [drive2:][path2]filename2

These commands compare two or more files:

/A Displays only the first and last lines for each set of differences.

/B Perform a binary comparison

/C Disregards the case of letters

/L Compares the files as ASCII text

/LBn Sets the maximum consecutive mismatches to the specified number of lines

/N Displays the line numbers (ASCII comparison)

/OFF[LINE] Does not skip files with an offline attribute set

/T Doesn’t expand tabs to spaces

/U Compares files as UNICODE text files

/W Compresses the white space for comparison

/nnnn Mentions the number of consecutive lines that must match after a mismatch

[drive1:][path1]filename1 Mentions the first file or set of files to compare

[drive2:][path2]filename2 Mentions the second file or set of files to compare


syntax- PRINT [/D:device] [[drive:][path]file name[...]]

Allows you to print a text file to a line printer, in the background





syntax- ipconfig [/(all/release/renew/flushdns/registerdns/displaydns/showclassid/setclassid]

/all  Shows the complete information about the network configuration

/release [adapter] Releases the IP address for the mentioned adapter

/renew [adapter]  Renews the IP address for the mentioned adapter

/flushdns Purges the DNS Resolver cache

/registerdns Refreshes all DHCP leases and re-register DNS names.

/displaydns Shows contents of the DNS Resolver Cache

/showclassid adapter  Shows all the DHCP class IDs allowed for the adapter

/setclassid adapter [classid] Modifies the DHCP class id.


syntax- ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [-w timeout] [-R] [-S srcaddr] [-p] [-4] [-6] target [/?]

The ping command allow you to test the ability of the source computer if it is reachable to the specified destination computer.

t Pings the target

a Resolves the hostname of an IP address target

n Sets ICMP Echo Requests number to send, from 1 to 4294967295

-l Sets the size of the echo request, in bytes from 32 to 65,527

-f Prevents ICMP Echo Requests from being fragmented by routers before reaching the target

-i TTL  Sets the Time to Live (TTL) value, 255 (maximum)

-v TOS  Sets a Type of Service (TOS) value

-r count Mentions the number of hops between source and destination.

-s count  Reports the time, in Internet Timestamp format received by each echo request

-w timeout Specifies the timeout value while executing the ping command and adjusts the amount of time, in milliseconds

-R Tells the ping command to trace the round trip path.

-S srcaddr Specifies the source address

-p Pings a Hyper-V Network Virtualization provider address.

-4 Forces the ping command to use IPv4 only

-6 Forces the ping command to use IPv6 only

target specifies the destination to ping, either an IP address or a hostname


syntax- tracert [-d] [-h MaxHops] [-w TimeOut] [-4] [-6] target [/?]

The tracert command show the complete information about a packet’s path from the computer or device:

-d Prevents the tracert from resolving IP addresses to hostnames,

-h maxhops Mentions the maximum number of hops in the search for the target

-w timeout Specifies the time, in milliseconds, before each reply timeouts

-4 Forces tracert to use IPv4 only

-6 Forces tracert to use IPv6 only

target Specifies the destination, either an IP address or hostname


syntax- nslookup [exit | finger | help | ls | lserver | root | server | set | view] [options]

The NSLOOKUP command display the information for diagnosing the Domain Name System (DNS) infrastructure.

nslookup exit Exits from the nslookup command-line tool

nslookup finger Connects with the finger server on the current computer

nslookup help  Displays a short summary of subcommands

nslookup ls Shows the information for a DNS domain

nslookup lserver Changes the default server to the DNS domain

nslookup root Changes the default server to the server for the root of the DNS domain namespace

nslookup server  Changes the default server to the mentioned DNS domain.

nslookup set Changes the configuration settings that affect how lookups function.

nslookup set all  Displays the current values of the configuration settings.

nslookup set class  Changes the query class that specifies the protocol group of the information

nslookup set d2 Turns the exhaustive Debugging mode on or off. All fields of every packet are printed

nslookup set debug  Turns the Debugging mode on or off

nslookup set domain Changes the default DNS domain name to the name specified.

nslookup set port  Changes the default TCP/UDP DNS name server port to the value specified

nslookup set querytype Changes the resource record type for the query

nslookup set recurse Specifies the DNS name server to query other servers if it doesn't have the information

nslookup set retry Specifies the number of retries

nslookup set root Changes the name of the root server used for queries

nslookup set search Appends the DNS domain names in the DNS domain search list to the request until an answer is received

nslookup set srchlist Changes the default DNS domain name and search list

nslookup set timeout Changes the initial number of seconds to wait for a reply to a request

nslookup set type Changes the resource record type for the query

nslookup set vc Prompts you to use or not use a virtual circuit when sending requests to the server

nslookup view Displays and lists the output of the previous subcommand or commands


syntax- ROUTE [-f] [-p] [-4|-6] command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]

ROUTE helps you to manually configure the routes in a routing table

-f  Clears all the routing tables of all gateway entries

-p  Creates a route consistent with system boots. By default, routes are not preserved once the system is restarted.

-4 Forces you to use IPv4

-6 Forces you to use IPv6

PRINT  Prints a route

ADD  Adds a route

DELETE  Deletes a route

CHANGE  Alters an existing route destination

Destination  Specifies the host

MASK Specifies that the next parameter is the 'netmask' value

Netmask  Specifies a subnet mask value for this route entry. Default value is

gateway Specifies a gateway

interface Specifies the interface number for the specified route

METRIC Mentions the metric, i.e., the cost for the destination


syntax- arp [/a [<inetaddr>] [/n <ifaceaddr>]] [/g [<inetaddr>] [-n <ifaceaddr>]] [/d <inetaddr> [<ifaceaddr>]] [/s <inetaddr> <etheraddr> [<ifaceaddr>]]

Th ARP command can list and alter all the entries in the Address Resolution Protocol (ARP) cache, containing one or more tables that stores IP addresses and their resolved Ethernet or Token Ring physical addresses.

[/a [<inetaddr>] [/n <ifaceaddr>] Specifies the current arp cache tables for all interfaces. The /n parameter is case-sensitive that displays the arp cache entry for a specific IP address

[/g [<inetaddr>] [/n <ifaceaddr>] Works similar to /a, the above command

[/d <inetaddr> [<ifaceaddr>] Deletes an entry with a specific IP address, where inetaddr is the IP address

[/s <inetaddr> <etheraddr> [<ifaceaddr>] Adds a static entry to the arp cache that resolves the IP address inetaddr to the physical address etheraddr.


syntax- netsh[ -a AliasFile] [ -c Context ] [-r RemoteComputer] [ -u [ DomainName\ ] UserName ] [ -p Password | *] [{NetshCommand | -f ScriptFile}]

You can use these commands to display or modify the network configuration of a currently running computer either locally or remotely.

-a Returns you to the netsh prompt after running AliasFile.

AliasFile Specifies the name of the text file with one or more netsh commands.

-c Specifies that netsh enters the specified netsh context.

Context Specifies the netsh context that you want to enter.

-r  Specifies the command that you want to run on a remote computer.

RemoteComputer Specifies the remote computer to configure.

-u  Specifies the netsh command to run under a user account.

DomainName\\ Specifies the domain where the user account is located. The default is the local domain if DomainName\.

UserName Specifies the user account name.

-p  Specifies a password that you want to provide for the user account.

Password Specifies the password for the user account that you want to use with -u UserName.

NetshCommand Specifies the netsh command that you can run.

-f  Exits the netsh after running the script that you designate with ScriptFile.

ScriptFile  Specifies the script to run.


GETMAC /s computername – Get MAC Address remotely by Computer Name

GETMAC /s – Get MAC Address by IP Address

GETMAC /s localhost – Get local MAC Address

These commands provide the MAC Address of your local computer along with the query remotely by computer name or IP Address.


syntax- tftp [-i] [<host>] [{get | put}] <source> [<destination>]

The TFTP command will transfer the files to and from a remote computer, typically a computer running UNIX, that is running the Trivial File Transfer Protocol (tftp) service or daemon.

-i Mentions the binary image transfer mode, where the file is transferred in one-byte units. Without using the -i option, the file is transferred in ASCII mode.

<host> Mentions the local or remote computer

get Transfers the file destination on the remote computer to the file source on the local computer

put Transfers the file source on the local computer to the file destination on the remote computer

<source> Specifies the file to transfer

<destination> Specifies where to transfer the file




syntax- DATE

DATE mm-dd-yy

Shows current date settings and allows you to reset the date


syntax- time [/t | [<HH>[:<MM>[:<SS>]] [am|pm]]]

time lets you show or edit the system time. Without any parameters, time displays the current system time and prompts you to enter a new time.

<HH>[:<MM>[:<SS>[.<NN>]]] [am | pm] allows you to set the system time to the new time specified, where HH hours (required), MM minutes, and SS seconds. NN specifies the hundredths of a second. Use (:) to separate values for HH, MM, and SS. SS and NN must be separated with a period (.).If am or pm isn't specified, time uses the 24-hour format by default.

/t Displays the current time without prompting you for a new time

/? Displays help at the command prompt


syntax- DRIVERQUERY [/S system [/U username [/P [password]]]] [/FO format] [/NH] [/SI] [/V]

DRIVERQUERY is used by an administrator to display a list of installed device drivers.

/S system Specifies the remote system of where to connect

/U [domain\]user Specifies user context under which the command should execute

/P [password] Specifies the password for the given user context

/FO format Specifies the type of output to display

/NH Specifies that the "Column Header" should be hidden. Valid for "TABLE" and "CSV" format only

/SI Displays the information about signed drivers

/V Displays the verbose output. Not valid for signed drivers


Shows the host name of the full computer name of the computer


syntax- systeminfo [/s <computer> [/u <domain>\<username> [/p <password>]]] [/fo {TABLE | LIST | CSV}] [/nh]

SYSTEMINFOlists detailed configuration information about a computer and its operating system

/s <computer> Mentions the name or IP address of a remote computer

/u <domain>\<username> Runs the command with the account permissions of the specified user account. With this, the command will consider the permissions of the user issuing the command

/p <password> Specifies the password of the user account that is specified in the /u parameter

/fo <format> Mentions the output format with one of the following values:

TABLE - to show the output in a table

LIST - to show the output in a list

CSV - to show the output in comma-separated values (.csv) format.

/nh to suppress the column headers in the output. Valid when the /fo parameter is set to TABLE or CSV


Displays the version of MS-DOS or Windows


syntax- gpresult [/s <system> [/u <username> [/p [<password>]]]] [/user [<targetdomain>\]<targetuser>] [/scope {user | computer}] {/r | /v | /z | [/x | /h] <filename> [/f] }

GPRESULTshows the Resultant Set of Policy information for a remote user and computer.

/s <system> Specifies the name or IP address of a remote computer

/u <username> Uses specified user credentials to run the command.

/p [<password>] Specifies the password of the user account provided in the /u parameter. Without this parameter, gpresult prompts for the password. You cannot use the /p parameter with /x or /h.

/user [<targetdomain>\]<targetuser>] Specifies the remote user whose RSoP data is to be displayed

/scope {user | computer} Shows the RSoP data for either the user or the computer. Without it, gpresult will show the RSoP data for both the user and the computer.

[/x | /h] <filename> Saves the report in either XML (/x) or HTML (/h) format at the location with the name mentioned in the filename parameter. You cannot use this option with /u, /p, /r, /v, or /z

/f Forces the gpresult to overwrite the file name mentioned in the /x or /h option

/r Shows the RSoP summary data

/v Shows the verbose policy information providing the detailed settings that were applied with a precedence of 1

/z Shows all the available information about Group Policy including detailed settings that were applied with a precedence of 1 and higher


These commands will update the Group Policy settings. You can use the following parameters with this command.

/target:{computer|user} Specifies that only User or only Computer policy settings are updated

/force Reapplies all policy settings. By default, only changed policy settings are reapplied

/wait:<VALUE> Sets the number of seconds to wait for policy processing to finish before returning to the command prompt. If the time limit exceeds, the command prompt appears, but policy processing continues. The default value is 600 seconds.

/logoff Logs off once the Group Policy settings are updated

boot Restarts a computer after the Group Policy settings are applied /sync Synchronizes the next foreground policy application

/? Shows the Help at the command prompt

Disk Management




syntax- chkdsk [volume:] [/F] [/V] [/R] [/X] [/I] [/C] [/L:size] [/perf] [/scan] [/spotfix]

CHKDISK gets details of a specified disk and repairs or recovers data on the drive if required.

volume: This is the drive letter of the partition for which you want to check for errors.

/F Fixes any errors found on the disk

/V Displays the full path and name of every file on the disk. If used on an NTFS volume, it will show any cleanup messages

/R Locates bad sectors and recover any readable information from them. This option implies /F when /scan is not specified

/X Implies /F and will force a dismount of the volume if necessary

/I Performs a less vigorous chkdsk command and instructs the command to run faster by skipping over certain regular checks

/C Same as /I but skips over cycles within the folder structure to reduce the amount of time that the chkdsk command runs

/L:size Changes the size (in KB) of the log file. The default log file size for chkdsk is 65536 KB.

/perf Runs faster by using more system resources. It must be used with /scan

/scan  Runs an online scan on an NTFS volume without repairing it. Here, "online" means that the volume does not need to be dismounted, but can instead remain online/active.

/spotfix Dismounts the volume only briefly to fix issues sent to the log file.



syntax- chkntfs <volume> [...]

chkntfs [/d]

chkntfs [/t[:<time>]]

chkntfs [/x <volume> [...]]

chkntfs [/c <volume> [...]]

CHKNTFS displays and alters automatic disk checking when the computer is started

<volume> [...] Specifies one or more volumes to check when the computer starts. Valid volumes include drive letters, mount points, or volume names.

/d Restores all chkntfs default settings, except the countdown time for automatic file checking. By default, all volumes are checked when the computer is started, and chkdsk runs on those that are dirty.

/t [:<time>] Changes the Autochk.exe initiation countdown time to the amount of time specified in seconds. Without the time parameter, /t will show the current countdown time.

/x <volume> [...] Specifies one or more volumes that you want to exclude from checking when the computer is started, even if the volume is marked as requiring chkdsk

/c <volume> [...]  Sets the schedules one or more volumes to be checked when the computer is started, and runs chkdsk on those that are dirty


syntax- compact [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [/EXE[:algorithm]] [/CompactOs[:option] [/windir:dir]] [filename [...]]

COMPACT displays and alters the compression of files or directories on NTFS partitions.

/c Compresses the specified directory or file

/u Uncompresses the specified directory or file

/s[:<dir>] Performs the chosen operation on files in the specified directory and all subdirectories. By default, the current directory is used as the <dir> value.

/a Shows the hidden or system files. By default, these files aren't included.

/i Continues the specified operation and ignores all errors. By default, this command stops when an error is encountered.

/f Forces the compression or decompression of the specified directory or file. It will skip the already-compressed files. The /f parameter is used in the case of a file that was partly compressed when the operation was interrupted by a system crash.

/q Reports only the most essential information

/EXE Uses the compression optimized for executable files that are read frequently, but not modified. Supported algorithms are:

  • XPRESS4K (fastest and default value)
  • LZX (most compact)

/CompactOs Sets or queries the system's compression state. It supports the following options.

  • query  queries the system's Compact state
  • always  compresses all the operating system binaries and sets the system state to Compact, which remains unless administrator changes it
  • never   Uncompressed all the operating system binaries and sets the system state to non-Compact, which remains unless the administrator changes it
  • <filename> Mentions a pattern, file, or directory. You can use multiple file names, and the * and ? wildcard characters.


syntax- convert basic

convert dynamic

convert gpt

convert mbr

These commands will let you convert a disk from one disk type to another.

convert basic command Converts an empty dynamic disk into a basic disk

convert dynamic command Converts a basic disk into a dynamic disk

convert gpt command Converts an empty basic disk having master boot record partition style into a basic disk with the GUID partition table (GPT) partition style

convert mbr command Converts an empty basic disk with the GUID Partition Table (GPT) partition style into a basic disk with the master boot record (MBR) partition style


syntax- diskpart <parameter>

The DISKPART command help you manage your computer's drives. It comes with the following parameters:

active Marks the disk's partition with focus, as active

add Lets you mirror the simple volume with focus to the specified disk.

assign Lets you assign a drive letter or mount point to the volume with focus

attach vdisk Lets you attach a virtual hard disk (VHD) so that it appears on the host computer as a local hard disk drive

attributes Lets you display, set, or clear the attributes of a disk or volume

automount Allows you to enable or disable the automount feature

break Breaks the mirrored volume with focus into two simple volumes.

clean Removes any and all partition or volume formatting from the disk with focus

compact vdisk Compacts the physical size of a dynamically expanding virtual hard disk (VHD) file

convert Converts the file allocation table (FAT) and FAT32 volumes to the NTFS file system, leaving existing files and directories intact

create you can create a partition on a disk, a volume on one or more disks, or a virtual hard disk (VHD)

Delete Lets you delete a partition or a volume

detach vdisk Lets you stop the selected virtual hard disk (VHD) from appearing as a local hard disk drive on the host computer

detail Shows you the information about the selected disk, partition, volume, or virtual hard disk (VHD)

exit Exits the diskpart command interpreter

expand vdisk Lets you expand a virtual hard disk (VHD) to the size that you specify

extend- Lets you expand the volume or partition with focus, along with its file system, into free (unallocated) space on a disk

filesystems Shows the information about the current file system of the volume with focus and lists the file systems that are supported for formatting the volume

Format Lets you format a disk to accept Windows files

gpt Lets you assign the gpt attribute(s) to the partition with focus on basic GUID partition table (gpt) disks

help Shows a list of the available commands or detailed help information on a specified command

import Imports a foreign disk group into the disk group of the local computer

inactive Lets you mark the system partition or boot partition with focus as inactive on basic master boot record (MBR) disks

list Shows a list of disks, of partitions in a disk, of volumes in a disk, or of virtual hard disks (VHDs)

merge vdisk Merges a differencing virtual hard disk (VHD) with its corresponding parent VHD

offline Takes an online disk or volume to the offline state

online Takes an offline disk or volume to the online state

recover Lets you refresh the state of all disks in a disk group, attempt to recover disks in an invalid disk group, and resynchronize mirrored volumes and RAID-5 volumes that have stale data

Rem Adds comments to a script

Remove-  Lets you remove a drive letter or mount point from a volume

Repair-  Lets you repair the RAID-5 volume with focus by replacing the failed disk region with the specified dynamic disk

rescan- Lets you scan the new disks that may have been added to the computer

retain Prepares an existing dynamic simple volume to be used as a boot or system volume

san Shows or sets the storage area network (san) policy for the operating system

select Lets you shift the focus to a disk, partition, volume, or virtual hard disk (VHD)

set id Lets you change the partition type field for the partition with focus

shrink Lets you reduce the size of the selected volume by the amount you specify

uniqueid Shows or sets the GUID partition table (GPT) identifier or master boot record (MBR) signature for the disk with focus


syntax- format volume [/FS:file-system] [/V:label] [/Q] [/L[:state]] [/A:size] [/C] [/I:state] [/X] [/P:passes] [/S:state]

format volume [/V:label] [/Q] [/F:size] [/P:passes]

format volume [/V:label] [/Q] [/T:tracks /N:sectors] [/P:passes]

format volume [/V:label] [/Q] [/P:passes]

format volume [/Q]

FORMATLets you format a disk to accept Windows files. You must be in the Administrators group to format a hard drive.

<volume> Mentions the mount point, volume name, or drive letter (followed by a colon) of the drive that you want to format

/FS:filesystem Mentions the type of file system (FAT, FAT32, NTFS, exFAT, ReFS, or UDF)

/V:<label> Mentions the volume label. Without /V command-line option, format prompts you for the volume label after the formatting is complete.

/A:<size> Specifies the allocation unit size to use on FAT, FAT32, NTFS, exFAT, or ReFS volumes

/Q Performs a quick format. Deletes the file table and the root directory of a previously formatted volume.

/F:<size> Mentions the size of the floppy disk to format. When possible, use this command-line option instead of the /T and /T command-line options.

/T:<tracks> Mentions the number of tracks on the disk. When possible, use the /F command-line option instead.

/N:<sectors> Specifies the number of sectors per track. When possible, use the /F command-line option instead of /N. If you use /N, you must also use /T.

/P:<count> Zero every sector on the volume

/C NTFS only.

/X Forces the volume to dismount, if necessary, before it's formatted

/R NTFS only. Files will be compressed by default

/D UDF 2.50 only. Metadata will be duplicated.

/L:<state> NTFS only. Overrides the default size of file record. /S:<state> Mentions the support for short filenames. State is either enable or disable. Short names are disabled by default.

/TXF:<state> Mentions the TxF is enabled/disabled. TxF is enabled by default

/I:<state> ReFS only. Specifies whether integrity should be enabled on the new volume. State is either enable or disable.

/DAX:<state> NTFS only. Enables the direct access storage (DAX) mode for this volume. In DAX mode, the volume is accessed via the memory bus, boosting IO performance.

/LogSize::<size> NTFS only. Specifies the size for NTFS log file in kilobytes. The minimum supported size is 2MB, so specifying a size smaller than 2MB will result in a 2MB log file. Zero indicates the default value, which generally depends on the volume size.

/NoRepairLogs NTFS only. Disables the NTFS repair logs. If the spotfix flag for chkdsk is specified (i.e. chkdsk /spotfix), this will not work.


Lets you perform tasks that are related to file allocation table (FAT) and NTFS file systems, such as managing reparse points, managing sparse files, or dismounting a volume.


syntax- label [/mp] [<volume>] [<label>]

You can create, change, or delete the volume label (that is, the name) of a disk. Without parameters, the label command changes the current volume label or deletes the existing label.

/mp Mentions that the volume should be treated as a mount point or volume name.

<volume> Specifies a drive letter, mount point, or volume name. If a volume name is specified, the /mp parameter is unnecessary

<label> Specifies the label for the volume


syntax- recover [<drive>:][<path>]<filename>

RECOVER will let you recover the readable information from a bad or defective disk.

[<drive>:][<path>]<filename> Specifies the file name (and the location of the file if it is not in the current directory) you want to recover. Filename is required and wildcards aren't supported.


syntax- vol [<drive>:]

VOL Shows the disk volume label and serial number

<drive>: Specifies the drive with the disk for which you want to display the volume label and serial number.

Applications and Processes




syntax- SCHTASKS /parameter [arguments]

parameter- create, delete, query, change, run, end, showid

Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote system


synatx- shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/f] [/m \\computername] [/t xxx] [/d [p:|u:]xx:yy] [/c "comment"] [/?]

Lets you power off, restart, log off, or hibernate your computer


syntax- TASKLIST [/S system [/U username [/P [password]]]] [/M [module] | /SVC | /V] [/FI filter] [/FO format] [/NH]

Shows a list of currently running processes on the local computer or on a remote computer.


syntax- TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]

Lets you end one or more tasks or processes. Processes can be ended by process ID or image name.


syntax- RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]

/user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/savecred] ]

/smartcard [/user:<UserName>] program

RUNAS /trustlevel:<TrustLevel> program

It will let you enable a user to execute a program on another computer as a specified user.

/noprofile Specifies that the user's profile should not be loaded, which allows the application to load more quickly, but can cause some applications to malfunction.

/profile The default setting that specifies that the user's profile should be loaded

/env Uses the current environment instead of the user's

/netonly Use if the credentials specified are for remote access only

/savecred 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 the levels enumerated in /showtrustlevels.

program Command line for EXE.


As one of the most versatile operating systems, Windows allows you to execute as many tasks as you want with different commands.

This Windows command line cheat sheet gives you a detailed run-through of every possible command, helping you understand each one’s performance. To run them, all you need is a basic knowledge of Command Line and administrator access.

Click here to download our Windows Command Line Cheat Sheet PDF.

Interested in finding more cheat sheets to help you with work or school? Check out our Java Cheat Sheet!


  1. How Do I Learn Windows Command Line?

You can use online or offline resources and explore different tasks you’d like to perform. Each task will have a corresponding command line.

  1. What are Some Cool Commands in Command Prompt?

Our Windows command prompt cheat sheet lists plenty of commands, but we’ll list a few more below for your reference:

  • Encrypting Files: Cipher /E
  • Changing Command Line Window Color:

Right-click on the title bar -> Properties -> click on “Colors” -> choose the colors -> Click OK.

  • Changing the prompt text in cmd:

  • Changing the Title of the cmd Window: title title_name
  • Listing every driver installed on your Windows system: driverquery /FO list /v
  1. How Do I Get a List of Commands in Command Prompt?

Type “help” and hit enter to get a list of all available commands in command prompt.

  1. What are the Basic Commands in Command Prompt?

Here are some basic commands:

  • CLS: Clears screen
  • CMD: Displays another command prompt
  • COLOR: Sets the text and background color
  • PROMPT: Changes the command line prompt
  • TITLE: Assigns a title for the current session
  • HELP: Launches CMD help
  • EXIT: Exits the command line

People are also reading:

Sameeksha Medewar

Sameeksha Medewar

Sameeksha is a freelance content writer for more than half and a year. She has a hunger to explore and learn new things. She possesses a bachelor's degree in Computer Science. View all posts by the Author

Leave a comment

Your email will not be published

Select from the best sales here