Used in Windows for one-off commands or setting up Services or creating scripts and batch files.

Can be launched from typing cmd in the run dialogue box or from binary at C:\Windows\system32\cmd.exe.

Help

See available commands

help

Info on specific command

help <command name>

Command’s own help menu

<command name> /?

Terminal History Commands

Key/CommandDescription
doskey / historyPrint the session’s command history to
the terminal or output it to a file when
specified.
page upPlaces the first command in session
history to the prompt.
page downPlaces the last command in history to
the prompt.
⇧Scroll up through command history.
⇩Scroll down most recently run commands.
⇒Types the previous command to prompt one
character at a time.
F3Retypes the entire previous entry to
our prompt.
F5Pressing F5 multiple times will allow
you to cycle through previous commands.
F7Opens an interactive list of previous
commands.
F9Enters a command to our prompt based on
the number specified. The number
corresponds to the commands place in our
history.

Files and Directory Commands

CommandDescription
dirLists directory contents.
cd/chdirPrints current working
directory.
cd/chdir <path>Changes working directory
to <path>.
tree <path>Graphically displays the
directory structure from
<path>.
clsClears the terminal.
md/mkdir <directory name>Creates a directory in the
current working directory
(or specified directory)
called <directory name>.
rm/rmdir <directory name>Removes <directory name>
in the current working
directory (or specified
directory).
move [source] [destination]Move file(s) from the
source folder to the
destination folder.
copy [source] [destination]Copy file(s) from the
source folder to the
destination folder. Only
works with files and not
folders.
robocopy [source] [destination]Copy files(s) and folder(s)
from the source folder to
the destination folder.
more <file>Displays the output of a
file or command one screen
at a time.
<command> <PIPE> moreDisplays the output of a
command through a <PIPE> to
more.
type <file>Displays the contents of a
file.
fsutil file createNew <filename>Creates a new file with a
specified file name and
length.
<length>
ren <existing name> <new name>Renames <existing name>
to <new name>.
del/erase <file(s)>Deletes <files(s)>.

Input/Output Operators

OperatorDescription
[command] > [file]Redirects the output from a
command into a file.
Overwrites the specified
files’ contents.
[command] >> [file]Redirects the output from a
command into a file. Appends
additional output without
overwriting the file’s
original contents.
[command] < [file]Redirects the output of the
file and passes it into the
command.
[command1] <pipe> [command2]Redirects the output of the
first command into a “pipe”
and provides it to the second
command.
[command1] & [command2]Executes both commands in
succession. It does not
perform checks to see if
either command passes or
fails.
[command1] && [command2]Checks to see if the first
command executes successfully
and then executes the second
command. If the first command
fails, the current command
execution halts and the
second command is not
executed.
[command1] <pipe><pipe> [command2]Checks to see if the first
command fails to execute
successfully and, if so,
proceeds to execute the
second command.

where <pipe> is the | symbol.

Find & Filter content

CommandDescription
where <file>Displays the location of file(s)
provided.
find "example string" <file>Searches for a string of text in a file
or files, and displays lines of text
that contain the specified string.
findstrSearches for patterns of text in files.
Similar to grep on Unix/Linux.
comp <file1> <file2>Compares the contents of two files or
sets of files byte-by-byte.
fc <file1> <file2>Compares two files or sets of files and
displays the differences between them.
sortReads input, sorts data, and writes the
results to the screen, a file, or
another device.

User Commands

CommandsDescription
whoamiDisplays the username of the currently logged-on user.
whoami /privDisplays the security privileges of the current user.
whoami /groupsDisplays the user groups that the current user belongs
to.
whoami /allDisplays all information about the current user,
including username, security identifiers (SID),
privileges, and groups.
net userDisplays a list of the user accounts on the computer
net localgroupDisplays the name of the server and the names of local
groups on the computer.
net groupDisplays the name of a server and the names of groups
on the server. Only able to be used if the machine is
joined to the domain.

Networking Commands

CommandDescription
ipconfigView basic networking configurations.
ipconfig /allView detailed networking configuration information.
netCLI utility containing multiple commands to manage
and configure network resources.
net shareDisplays info about all of the resources that are
shared on the local computer.
net viewDisplays a list of domains, computers, or resources
being shared by the specified computer.
arpDisplays and manages the contents and entries within
the Address Resolution Protocol (ARP) cache.
netstat -anDisplay current network connections.
nslookup <query>Query DNS for a name or address.

Environment Variable Commands

CommandDescription
%EXAMPLE_VARIABLE%Example format for an environment
variable.
setPrints all available environment
variables on the system.
set <%VARIABLE_NAME%>Prints out the value of the environment
variable specified. It can also be used
to set the variable’s value.
echo <%VARIABLE_NAME%>Prints out the value of the environment
variable specified. It cannot make any
edits to variables and will only print
out the values to the console.
set <%VARIABLE_NAME%>=<Value>Creates a new environment variable or
modifies an existing one and sets the
value for the current command line
session.
set <%VARIABLE_NAME%>=Removes the environment variable with
the specified name for the current
command line session.
setx <%VARIABLE_NAME%> <Value>Creates a new environment variable or
modifies an existing one and sets the
value globally by making changes to the
registry.
setx <%VARIABLE_NAME%> ""Removes the environment variable with
the specified name globally.

Services Commands

CommandDescription
sc queryLists all running services and
provides additional information for
each service.
sc query <Name>Lists details about a specific
service by name.
sc start <Name>Start a service by name.
sc stop <Name>Stop a service by name.
sc config <Name> start= disabledChange settings of the service
specified.
tasklist /svcProvide a list of services running
under each process on the system.
net startList all running services.
wmic service list briefList all services on the system using
WMIC. Includes information such as:
ExitCode, Name, ProcessID, StartMode,
State, and Status.

Task Scheduling Commands

Use schtasks, which on its own displays all tasks scheduled on the local machine.

For task scheduling management append schtasks with the following actions and perhaps their parameters:

ActionParameterDescription
QueryPerforms a local or remote host search to determine
what scheduled tasks exist. Due to permissions, not
all tasks may be seen by a normal user.
/foSets formatting options. We can specify to show
results in the Table, List, or CSV output.
/vSets verbosity to on, displaying the advanced
properties set in displayed tasks when used with the
List or CSV output parameter.
/nhSimplifies the output using the Table or CSV output
format. This switch removes the column headers.
/sSets the DNS name or IP address of the host we want
to connect to. Localhost is the default specified.
If /s is utilised, we are connecting to a remote
host and must format it as “\\host”.
/uThis switch will tell schtasks to run the following
command with the permission set of the user
specified.
/pSets the password in use for command execution when
we specify a user to run the task. Users must be
members of the Administrator’s group on the host (or
in the domain). The u and p values are only
valid when used with the s parameter.
CreateSchedules a task to run.
/scSets the schedule type. It can be by the minute,
hourly, weekly, and much more. Be sure to check the
options parameters.
/tnSets the name for the task we are building. Each
task must have a unique name.
/trSets the trigger and task that should be run. This
can be an executable, script, or batch file.
/sSpecify the host to run on, much like in Query.
/uSpecifies the local user or domain user to utilise
/pSets the Password of the user-specified.
/moAllows us to set a modifier to run within our set
schedule. For example, every 5 hours every other
day.
/rlAllows us to limit the privileges of the task.
Options here are limited access and Highest. Limited
is the default value.
/zWill set the task to be deleted after completion of
its actions.
ChangeAllows for modifying existing scheduled tasks.
/tnDesignates the task to change
/trModifies the program or action that the task runs.
/ENABLEChange the state of the task to Enabled.
/DISABLEChange the state of the task to Disabled.
DeleteRemove a task from the schedule
/tnIdentifies the task to delete.
/sSpecifies the name or IP address to delete the task
from.
/uSpecifies the user to run the task as.
/pSpecifies the password to run the task as.
/fStops the confirmation warning.