Lec 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Windows Command Prompt Cheatsheet

- Command line interface (as opposed to a GUI - graphical user interface)


- Used to execute programs
- Commands are small programs that do something useful
- There are many commands already included with Windows, but we will use a few.
- A filepath is where you are in the filesystem
• C: is the C drive
• C:\user\Documents is the Documents folder
• C:\user\Documents\hello.c is a file in the Documents folder

Command What it Does Usage

dir Displays a list of a folder’s files dir (shows current folder)


and subfolders dir myfolder
cd Displays the name of the current cd filepath
chdir directory or changes the current chdir filepath
folder. cd .. (goes one directory up)
md Creates a folder (directory) md folder-name
mkdir mkdir folder-name
rm Deletes a folder (directory) rm folder-name
rmdir rmdir folder-name
rm /s folder-name
rmdir /s folder-name
Note: if the folder isn’t empty,
you must add the /s.
copy Copies a file from one location to copy filepath-from filepath-to
another
move Moves file from one folder to move folder1\file.txt folder2\
another
ren Changes the name of a file ren file1 file2
rename
del Deletes one or more files del filename
exit Exits batch script or current exit
command control
echo Used to display a message or to echo message
turn off/on messages in batch
scripts
type Displays contents of a text file type myfile.txt
fc Compares two files and displays fc file1 file2
the difference between them
cls Clears the screen cls
help Provides more details about help (lists all commands)
DOS/Command Prompt help command
commands
SHUTDOWN (Turn off Computer)
SHUTDOWN offers control over your system's shutdown process. You can restart, shut down, or even
plan shutdowns through the command line.
• Syntax: shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/fw] [/f] [/m
\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
• Example: shutdown /I -> Open a graphical interface to shutdown computer
shutdown /i

SYSTEMINFO (System Information)


SYSTEMINFO provides a wealth of system-related information, including details about your operating
system, network, and hardware.
• Syntax: systeminfo [/s <computer> [/u <domain><username> [/p <password>]]] [/fo {TABLE |
LIST | CSV}] [/nh]
• Example: C:\Users\systeminfo

IPCONFIG (IP Configuration)


Purpose: Displays detailed network configuration information, including IP address, subnet mask,
default gateway, and more.
• Syntax: ipconfig [/all] [/renew [<adapter>]] [/release [<adapter>]] [/flushdns] [/displaydns]
[/registerdns] [/showclassid <adapter>] [/setclassid <adapter> [<classID>]]
ipconfig
NETSTAT (Network Statistics)
Purpose: Provides a snapshot of active network connections and protocol statistics, aiding in
monitoring network performance and identifying issues.
• Syntax: netstat [-a] [-b] [-e] [-n] [-o] [-p <Protocol>] [-r] [-s] [<interval>]
netstat
TRACERT (Trace Route)
Purpose: Traces the route that packets take to reach a destination, displaying hop-by-hop information
and helping pinpoint network latency or failures.
Syntax: tracert [/d] [/h <maximumhops>] [/j <hostlist>] [/w <timeout>] [/R] [/S <srcaddr>] [/4] [/6]
<targetname>

PING (Send Test Packets)


Purpose: Sends ICMP echo requests to a target host, checking network connectivity and measuring
response times.

TASKLIST (List Processes)


TASKLIST displays a list of currently running processes, similar to the information available in Task
Manager but accessible via CMD.

Syntax: TASKLIST [/S system] [/U username] [/P password] [/M [module]] [/SVC] [/V] [/FI filter] [/FO
format] [/NH] Example: TASKLIST /FI "IMAGENAME eq notepad.exe"
TASKLIST
TASKKILL (Terminate Tasks by Process ID or Image Name)
Ends one or more tasks or processes. The example command forcefully terminates all instances of
Notepad.
• Syntax: TASKKILL [/S system] [/U username] [/FI filter] [/PID processid | /IM imagename] [/T]
[/F] Example: TASKKILL /IM notepad.exe /F

TASKKILL
ATTRIB (Change File Attributes)
This command is used to change file attributes. +R sets the file as read-only, -R removes read-only
status, +H makes the file hidden, etc.

• Syntax: ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [drive:][path][filename] [/S [/D]] Example:
ATTRIB +R C:\example.txt
ATTRIB

Ex: attrib +h +s +r a.txt

COPY CON
It is used to create file name

Usage: COPY CON a.txt

ctrl+z (enter)

You might also like