100% found this document useful (1 vote)
214 views

Windows Command Line Cheat Sheet PDF Hackr - Io

The document provides information on using the net user command in Windows to manage user accounts from the command line. It lists the syntax of the command and descriptions of its various options to add, remove, and modify users and user properties like passwords, comments, expiration dates. It also provides details on using dir to list directories and files and view their properties, and commands to navigate, create, delete and manage directories and files.

Uploaded by

Dawood Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
214 views

Windows Command Line Cheat Sheet PDF Hackr - Io

The document provides information on using the net user command in Windows to manage user accounts from the command line. It lists the syntax of the command and descriptions of its various options to add, remove, and modify users and user properties like passwords, comments, expiration dates. It also provides details on using dir to list directories and files and view their properties, and commands to navigate, create, delete and manage directories and files.

Uploaded by

Dawood Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

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.

Syntax:

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


[/delete] [/domain]] [/help] [/?]

Where:

● 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

Options Description
/active:{yes | no} Activates or deactivates the specified user account; default value is yes

/comment:"text" Takes a maximum of 48 characters; text is viewable in the Description field


/countrycode:nnn Sets a country code for the user to determine the language used for error
and help messages (default, value is 000)
/expires:{date | Sets a specific date when the account should expire (default is no expiry)
never}

date (with /expires Sets or displays the current date in mm/dd/yy or mm/dd/yyyy format
only)

/fullname:"name" Mentions the real name of the person using the account
/homedir:pathname Sets a pathname if you want a home directory other than the default
/passwordchg:{yes | Specifies whether the user can change their password (default is yes)
no}

/passwordreq:{yes | Specifies whether this user is required to have a password at all (default is
no} yes)

/logonpasswordchg: Forces user to change their password at the next login


{yes | no}

/profilepath:pathna Sets a pathname for the user's login profile


me
/scriptpath:pathnam Sets a pathname for the user's login script
e
/times:[timeframe | Specifies a timeframe for which the user can log on
all]

timeframe (with Specifies a timeframe


/times only)
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.
/usercomment:"text" Adds or changes the User Comment for the specified account.
Directory
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.

Syntax
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


Options Explanation
drive:, path, Specifies the drive, path, and filename that you want to check. You can even
filename run the command alone without options, and Wildcards are allowed.
/a 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.
/b Shows directory information in the "bare" format (only directory name or file
name and extension)
/c Displays file sizes(to disable, use /-c)
/d Displays the folders and file names with their extensions.
/l Displays all folder and file names in lowercase
/n 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.
/o 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.
/p Shows one result page at a time, as well as this prompt: “you can press any
key to continue”
/q Shows the owner of the file or folder
/r Shows alternate data streams (ADS)
/s Shows all the files and folders in the specified directory including in
subdirectories
/t Specifies a time field to sort and display the results:
a = last access
c = created
w = last written

/w Shows the results in "wide format" that are limited to just folders and file
names with their extensions
/x Shows the "short name" equivalent for files whose long names don't comply
with non-8dot3 rules
/4 Changes format to 4-digit years

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

Command Description
cd\ Takes you to the top of the directory tree
cd.. Takes you one folder up
dir 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 Creates a folder with subfolders at the same time in a


folder_name\sub_folder1\sub_f tree-like structure
older2
ren [old_folder] [new_folder]
Renames an old folder name with a new folder name
c: Changes the drive
d:
cd /d d:
Changes the current directory
cd Folder
cd %VAGRANT_HOME% ←
cmd
cd $env:VAGRANT_HOME ←
powerhsell
tree Displays the directory structure of a path or of the disk
rd DIRECTORY ← empty Deletes the directory
directory
rd Folder1\Folder2 ← Delete
only Folder2
rd DIRECTORY /s ← including
all files
rd DIRECTORY /s /q ← quiet
mode

File management

Command Description
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
attrib want to change the attributes. You can also use the wildcard.
syntax- attrib [+a|-a] /s Execute the file attribute display or changes you're making on the
[+h|-h] [+i|-i] [+r|-r] subfolders within a specific drive and/or path
[+s|-s] [+v|-v] [+x|-x] /d Includes directories in execution; only works with /d with /s.
[drive:][path][filenam /l Applies whatever you're doing with the attrib command to the
e] [/s [/d] [/l]] Symbolic Link itself instead of the target of the Symbolic Link
These commands compare file contents:

D Changes display output from hexadecimal encoded to decimal format


comp a Displays differences as characters instead of hexadecimal or
syntax- comp Data1 decimal codes
Data2 [/d] [/a] [/l] n Compares the number of lines specified in each file, even if the files
[/n=Number] [/c] [/?] are different sizes
c Performs a case insensitive search as opposed to the default
case-sensitive search
/? Displays help for the command
compact
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
diskcomp Compares the content of two floppy disks
diskcopy 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
/r Decompresses the compressed file
expand
syntax- expand I Ignores the directory structure
source [destination] d Lists the files contained in the source but doesn't extract them
[/r] [/i] [/d] [/f /f:filespec Extracts selected file from the source file
[:filespec]] [/y] y Prevents the command from informing you
mkdir Creates a new directory

move MOVE Moves/renames files


syntax- MOVE [/Y | /Y Suppresses the prompt to confirm you want to overwrite an
/-Y] existing destination file
[drive:][path]dirnam /-Y Causes the prompt to confirm you want to overwrite an existing
e1 dirname2 destination file
ren SRC DES
rename SRC DES Renames files
Replaces files

replace
syntax- REPLACE Path/files– Indicates the source files, accepts wildcards.
[Drive:][path]Source path2– Provides the destination folder, default current drive, and
Files [Drive:][path2] directory as the destination
[/A] [/P] [/R] [/W] /A– Includes all the missing files
/P– Provides the prompt for confirmation for each file
REPLACE /R– Replaces even “read-only: file
[Drive:][path]Source /S– Includes all subfolders of the destination
Files [Drive:][path2] /W– Waits/pauses, or Inserts a floppy disk
[/S] [/P] [/R] [/W] [/U] /U– Updates only files that are older than the source
rmdir / rd deletes a directory
rmdir / rd
syntax- RMDIR [/S] /S Removes all directories and files in the specified directory in
[/Q] [drive:]path addition to the directory itself
RD [/S] [/Q] /Q Specifies the quiet mode. There is not need to ask whether to
[drive:]path delete a specific directory tree with /S
tree
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 Mirrors a directory tree
SOURCE_FOLDER
DESTINATION_FO
LDER /mir

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

robocopy d: g: /mir

robocopy more
edit Prompts file editing
FC These commands compare two or more files:
syntax- FC [/A] [/C]
[/L] [/LBn] [/N]
[/OFF[LINE]] [/T] /A Displays only the first and last lines for each set of differences.
[/U] [/W] [/nnnn] /B Perform a binary comparison
[drive1:][path1]filena /C Disregards the case of letters
me1 /L Compares the files as ASCII text
[drive2:][path2]filena /LBn Sets the maximum consecutive mismatches to the specified
me2 number of lines
FC /B /N Displays the line numbers (ASCII comparison)
[drive1:][path1]filena /OFF[LINE] Does not skip files with an offline attribute set
me1 /T Doesn’t expand tabs to spaces
[drive2:][path2]filena /U Compares files as UNICODE text files
me2 /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
print
syntax- PRINT
[/D:device]
[[drive:][path]file
name[...]] Allows you to print a text file to a line printer, in the background

Network

Command Description
ipconfig /all Shows the complete information about the network configuration
syntax- ipconfig
[/(all/release/renew/flushd /release [adapter] Releases the IP address for the mentioned adapter
ns/registerdns/displaydns/ /renew [adapter] Renews the IP address for the mentioned adapter
showclassid/setclassid] /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.
ping The ping command allow you to test the ability of the source computer if it is
syntax- ping [-t] [-a] [-n reachable to the specified destination computer.
count] [-l size] [-f] [-i TTL]
[-v TOS] [-r count] [-s t Pings the target
count] [-w timeout] [-R] [-S a Resolves the hostname of an IP address target
srcaddr] [-p] [-4] [-6] 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
tracert The tracert command show the complete information about a packet’s path
syntax- tracert [-d] [-h from the computer or device:
MaxHops] [-w TimeOut]
[-4] [-6] target [/?] -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
NSLOOKUP The NSLOOKUP command display the information for diagnosing the
syntax- nslookup [exit | Domain Name System (DNS) infrastructure.
finger | help | ls | lserver |
root | server | set | view]
[options] 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
ROUTE
ROUTE helps you to manually configure the routes in a routing table
syntax- ROUTE [-f] [-p]
[-4|-6] command
-f Clears all the routing tables of all gateway entries
[destination] [MASK
-p Creates a route consistent with system boots. By default, routes are not
netmask] [gateway]
preserved once the system is restarted.
[METRIC metric] [IF
interface]
-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 255.255.255.255.
gateway Specifies a gateway
interface Specifies the interface number for the specified route
METRIC Mentions the metric, i.e., the cost for the destination
ARP Th ARP command can list and alter all the entries in the Address Resolution
syntax- arp [/a Protocol (ARP) cache, containing one or more tables that stores IP
[<inetaddr>] [/n addresses and their resolved Ethernet or Token Ring physical addresses.
<ifaceaddr>]] [/g
[<inetaddr>] [-n
<ifaceaddr>]] [/d [/a [<inetaddr>] [/n <ifaceaddr>] Specifies the current arp cache tables
<inetaddr> [<ifaceaddr>]] for all interfaces. The /n parameter is case-sensitive that displays the arp
[/s <inetaddr> <etheraddr> cache entry for a specific IP address
[<ifaceaddr>]]
[/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.
NETSH You can use these commands to display or modify the network configuration
syntax- netsh[ -a AliasFile] of a currently running computer either locally or remotely.
[ -c Context ] [-r
RemoteComputer] [ -u [ -a Returns you to the netsh prompt after running AliasFile.
DomainName\ ] AliasFile Specifies the name of the text file with one or more netsh
UserName ] [ -p Password commands.
| *] [{NetshCommand | -f -c Specifies that netsh enters the specified netsh context.
ScriptFile}] 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
GETMAC /s
computername – Get
MAC Address remotely by
Computer Name
GETMAC /s 192.168.1.1 –
Get MAC Address by IP
Address
GETMAC /s localhost – These commands provide the MAC Address of your local computer along
Get local MAC Address with the query remotely by computer name or IP Address.
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
TFTP on the remote computer
syntax- tftp [-i] [<host>]
[{get | put}] <source> <source> Specifies the file to transfer
[<destination>] <destination>Specifies where to transfer the file

System-Related Information

Command Description
date
syntax- DATE
DATE mm-dd-yy Shows current date settings and allows you to reset the date
time time lets you show or edit the system time. Without any parameters, time
syntax- time [/t | displays the current system time and prompts you to enter a new time.
[<HH>[:<MM>[:<S
S>]] [am|pm]]] <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
DRIVERQUERY is used by an administrator to display a list of installed
device drivers.

/S system Specifies the remote system of where to connect


DRIVERQUERY /U [domain\]user Specifies user context under which the command
syntax- should execute
DRIVERQUERY /P [password] Specifies the password for the given user context
[/S system [/U /FO format Specifies the type of output to display
username [/P /NH Specifies that the "Column Header" should be hidden. Valid
[password]]]] [/FO for "TABLE" and "CSV" format only
format] [/NH] [/SI] /SI Displays the information about signed drivers
[/V] /V Displays the verbose output. Not valid for signed drivers
HOSTNAME Shows the host name of the full computer name of the computer
SYSTEMINFO lists 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
SYSTEMINFO /p <password> Specifies the password of the user account that is
syntax- systeminfo specified in the /u parameter
[/s <computer> [/u /fo <format> Mentions the output format with one of the following values:
<domain>\<userna TABLE - to show the output in a table
me> [/p LIST - to show the output in a list
<password>]]] [/fo CSV - to show the output in comma-separated values (.csv) format.
{TABLE | LIST | /nh to suppress the column headers in the output. Valid when the /fo
CSV}] [/nh] parameter is set to TABLE or CSV
VER Displays the version of MS-DOS or Windows
GPRESULT shows the Resultant Set of Policy information for a remote user
GPRESULT and computer.
syntax- gpresult [/s
<system> [/u /s <system> Specifies the name or IP address of a remote computer
<username> [/p /u <username> Uses specified user credentials to run the command.
[<password>]]]] /p [<password>] Specifies the password of the user account provided
[/user in the /u parameter. Without this parameter, gpresult prompts for the
[<targetdomain>\]<t password. You cannot use the /p parameter with /x or /h.
argetuser>] [/scope
{user | computer}] /user [<targetdomain>\]<targetuser>] Specifies the remote user whose
{/r | /v | /z | [/x | /h] RSoP data is to be displayed
<filename> [/f] }
/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
GPUPDATE /? Shows the Help at the command prompt

Disk Management

Command Description
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.
CHKDISK
syntax- chkdsk [volume:] /spotfix Dismounts the volume only briefly to fix issues sent to the log
[/F] [/V] [/R] [/X] [/I] [/C] file.
[/L:size] [/perf] [/scan]
[/spotfix] .
CHKNTFS CHKNTFS displays and alters automatic disk checking when the computer
syntax- chkntfs is started
<volume> [...]
chkntfs [/d] <volume> [...] Specifies one or more volumes to check when the
chkntfs [/t[:<time>]] computer starts. Valid volumes include drive letters, mount points, or volume
chkntfs [/x <volume> [...]] names.
chkntfs [/c <volume> [...]]
/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

COMPACT COMPACT displays and alters the compression of files or directories on


syntax- compact [/C | /U] NTFS partitions.
[/S[:dir]] [/A] [/I] [/F] [/Q]
[/EXE[:algorithm]] /c Compresses the specified directory or file
[/CompactOs[:option]
[/windir:dir]] [filename /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)
● XPRESS8K
● XPRESS16K
● 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.
CONVERT These commands will let you convert a disk from one disk type to another.
syntax- convert basic
convert dynamic convert basic command Converts an empty dynamic disk into a basic
convert gpt disk
convert mbr
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
DISKPART The DISKPART command help you manage your computer's drives. It
syntax- diskpart comes with the following parameters:
<parameter>
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
FORMAT FORMAT Lets you format a disk to accept Windows files. You must be in
syntax- format volume the Administrators group to format a hard drive.
[/FS:file-system]
[/V:label] [/Q] [/L[:state]] <volume> Mentions the mount point, volume name, or drive letter
[/A:size] [/C] [/I:state] [/X] (followed by a colon) of the drive that you want to format
[/P:passes] [/S:state] /FS:filesystem Mentions the type of file system (FAT, FAT32, NTFS, exFAT,
format volume [/V:label] ReFS, or UDF)
[/Q] [/F:size] [/P:passes] /V:<label> Mentions the volume label. Without /V command-line option,
format volume [/V:label] format prompts you for the volume label after the formatting is complete.
[/Q] [/T:tracks /N:sectors]
[/P:passes] /A:<size> Specifies the allocation unit size to use on FAT, FAT32, NTFS,
format volume [/V:label] exFAT, or ReFS volumes
[/Q] [/P:passes] /Q Performs a quick format. Deletes the file table and the root directory
format volume [/Q] 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.

FSUTIL 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.
LABEL You can create, change, or delete the volume label (that is, the name) of a
syntax- label [/mp] disk. Without parameters, the label command changes the current volume
[<volume>] [<label>] 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
RECOVER RECOVER will let you recover the readable information from a bad or
syntax- recover defective disk.
[<drive>:][<path>]<filena
me> [<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.
VOL VOL Shows the disk volume label and serial number
syntax- vol [<drive>:]
<drive>: Specifies the drive with the disk for which you want to display
the volume label and serial number.

Applications and Processes

Command Description
SCHTASKS
syntax- SCHTASKS
/parameter [arguments]
parameter- create,
delete, query, change, Enables an administrator to create, delete, query, change, run, and end
run, end, showid scheduled tasks on a local or remote system
SHUTDOWN
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
TASKLIST
syntax- TASKLIST [/S
system [/U username [/P
[password]]]] [/M Shows a list of currently running processes on the local computer or on
[module] | /SVC | /V] [/FI a remote computer.
filter] [/FO format] [/NH]

TASKKILL
syntax- TASKKILL [/S Lets you end one or more tasks or processes. Processes can be ended
system [/U username [/P by process ID or image name.
[password]]]] { [/FI filter]
[/PID processid | /IM
imagename] } [/T] [/F]
It will let you enable a user to execute a program on another computer as a
specified user.
RUNAS
syntax- RUNAS [ /noprofile Specifies that the user's profile should not be loaded, which
[/noprofile | /profile] allows the application to load more quickly, but can cause some applications
[/env] [/savecred | to malfunction.
/netonly] ] /profile The default setting that specifies that the user's profile should
/user:<UserName> be loaded
program /env Uses the current environment instead of the user's
RUNAS [ [/noprofile | /netonly Use if the credentials specified are for remote access only
/profile] [/env] /savecred Use credentials previously saved by the user
[/savecred] ] /smartcard Use if the credentials are to be supplied from a smartcard
/smartcard /user <UserName> should be in form USER@DOMAIN or DOMAIN\USER
[/user:<UserName>] /showtrustlevels Displays the trust levels that can be used as
program arguments to /trustlevel.
RUNAS /trustlevel <Level> should be one of the levels enumerated in
/trustlevel:<TrustLevel> /showtrustlevels.
program program Command line for EXE.
FAQs

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.

2. 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

3. 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.
4. 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

You might also like