Windows CMD cheat sheet for Windows Administration and Security

John D Cyber
3 min readFeb 28, 2024

--

Photo by Philipp Katzenberger on Unsplash

Windows Command Prompt (CMD) cheat sheet tailored for both new users and administrators. This guide covers basic navigation commands, file management, network utilities, and system tasks, providing a solid foundation for working effectively within the Windows environment.

Getting Started with CMD

  • Open CMD: Press Win + R, type cmd, and press Enter.
  • Open CMD as Administrator: Press Win + X and select “Command Prompt (Admin)” or “Windows PowerShell (Admin)” depending on your Windows version.

Basic Navigation

  • Change Directory: cd [directory name]
  • Move into a specific directory: cd Documents
  • Move up one directory: cd ..
  • List Contents: dir
  • Displays all files and directories in the current directory.

File Management

  • Create a New Directory: mkdir [directory name]
  • Example: mkdir NewFolder
  • Create a New File: echo > [file name]
  • Example: echo > example.txt
  • Delete a File: del [file name]
  • Example: del example.txt
  • Rename a File: rename [current name] [new name]
  • Example: rename oldname.txt newname.txt
  • Copy a File: copy [source] [destination]
  • Example: copy example.txt D:\Backup
  • Move a File: move [source] [destination]
  • Example: move example.txt D:\Documents

Network Utilities

  • Ping: ping [hostname or IP]
  • Checks connectivity with another network device.
  • IP Configuration: ipconfig
  • Displays the IP address, subnet mask, and default gateway for all adapters.
  • Trace Route: tracert [hostname or IP]
  • Determines the path packets take to reach a specific destination.

System Tasks

  • View System Information: systeminfo
  • Displays detailed configuration information about a computer and its operating system.
  • Shutdown or Restart Computer:
  • Shutdown: shutdown /s /t [time in seconds]
  • Restart: shutdown /r /t [time in seconds]
  • View Task List: tasklist
  • Displays a list of currently running processes.
  • Kill a Task: taskkill /IM [process name] /F
  • Example: taskkill /IM notepad.exe /F

Advanced Commands for Administrators

  • Disk Partition Management: diskpart
  • A powerful tool to manage disk partitions.
  • Network Statistics: netstat
  • Displays active connections, listening ports, and network statistics.
  • Service Management:
  • Start a service: net start [service name]
  • Stop a service: net stop [service name]
  • File System Check: chkdsk
  • Checks the filesystem on a disk and fixes logical file system errors.

User Management

  • Add a New User: net user [username] [password] /add
  • Example: net user John p@ssw0rd /add
  • Delete a User: net user [username] /delete
  • Example: net user John /delete
  • Add User to Group: net localgroup [groupname] [username] /add
  • Example: net localgroup Administrators John /add

SMB Shares

  • List Shared Resources: net share
  • Create a Share: net share [sharename]=[folderpath] /grant:[username],FULL
  • Example: net share DataShare=C:\Data /grant:John,FULL
  • Delete a Share: net share [sharename] /delete
  • Example: net share DataShare /delete

Group Policy Objects (GPOs)

While direct manipulation of GPOs is not typically done through CMD (it’s more common with PowerShell or Group Policy Management Console — GPMC), you can refresh GPO settings for a computer or user:

  • Refresh GPO Settings: gpupdate /force
  • This command enforces an immediate refresh of all GPO settings.

Security and Firewall Commands

  • View Firewall Status: netsh advfirewall show allprofiles
  • Enable Firewall: netsh advfirewall set allprofiles state on
  • Disable Firewall: netsh advfirewall set allprofiles state off
  • Add Firewall Rule: netsh advfirewall firewall add rule name="[name]" dir=in action=allow protocol=TCP localport=[port]
  • Example: netsh advfirewall firewall add rule name="Allow Port 80" dir=in action=allow protocol=TCP localport=80

Encryption and Security

  • Encrypt a File or Folder: cipher /e [path]
  • Example: cipher /e C:\SensitiveData
  • Decrypt a File or Folder: cipher /d [path]
  • Example: cipher /d C:\SensitiveData

Managing Services

  • View Status of All Services: sc query
  • Start a Service: net start [service name]
  • Example: net start wuauserv
  • Stop a Service: net stop [service name]
  • Example: net stop wuauserv

Helpful Tips

  • Auto-Completion: Press Tab to auto-complete file and directory names.
  • Command History: Press Up or Down arrow keys to navigate through previously used commands.
  • Help for Commands: Type command /?, e.g., cd /?, to view help for a specific command.

This cheat sheet provides a starting point for using the Windows Command Prompt. Experimenting with these commands and exploring further will greatly enhance your proficiency in managing Windows systems via CMD.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Written by John D Cyber

Experienced Sr. Red Team Engineer with demonstrated skills in DevOps, CICD automation, Cloud Security, Information Security, AWS, Azure, GCP and compliance.

No responses yet

Write a response