Skip to content
GEEKnodes

Windows

Basic CMD and PowerShell Commands You Should Know

The most useful CMD and PowerShell commands: repair Windows with sfc and DISM, check the disk with chkdsk, view processes, shut down and navigate folders.

The Windows console is a bit scary at first, but a handful of commands solves problems that take much longer through windows: repairing damaged files, checking the disk, closing a frozen program or seeing battery health. This guide gathers the most useful system commands, explained for beginners.

In short

  • On Windows 11 everything opens from Terminal: right-click Start › Terminal (Admin).
  • To repair Windows: first DISM ... /RestoreHealth, then sfc /scannow.
  • chkdsk checks the disk for file system errors.
  • tasklist, taskkill and shutdown control programs and shutdowns.
  • Most CMD commands also work in PowerShell.

CMD, PowerShell and Terminal: what is what

  • Command Prompt (CMD): the classic console inherited from MS-DOS. Simple and compatible with everything.
  • PowerShell: the modern console. It understands almost all CMD commands and adds its own (cmdlets), in Verb-Noun form.
  • Terminal: the app that on Windows 11 opens both in tabs. It is the default.

Many commands here need administrator rights. Open the console like this: right-click Start (or Windows + X) › Terminal (Admin) and accept the prompt.

Command Prompt, PowerShell and Terminal: Terminal opens the other two consoles in tabs
Terminal is the window; CMD and PowerShell run inside it.

Repair Windows: DISM and sfc

If Windows acts strange, freezes or updates fail, these two commands are the first step. Order matters.

  1. DISM repairs the Windows image, the reference copy the system uses:
DISM /Online /Cleanup-Image /RestoreHealth
  1. sfc compares system files with that image and replaces damaged ones:
sfc /scannow

DISM can take 10–20 minutes and seem stuck at some percentage: wait. When sfc finishes, read the final message. If it found and repaired damaged files, restart.

If you only want to check without repairing, DISM has two lighter options: /CheckHealth (quick) and /ScanHealth (thorough).

Check the disk: chkdsk

chkdsk finds and fixes file system errors on a drive.

chkdsk C:
chkdsk C: /f
chkdsk C: /r
  • Without parameters it only reads and reports.
  • /f fixes errors.
  • /r also looks for bad sectors. Much slower, especially on large hard drives.

On drive C: it cannot work while Windows runs, so it asks to schedule it for the next restart. Answer Y and restart.

Repair order: first DISM repairs the image, then SFC repairs files and CHKDSK checks the disk
DISM, then SFC and, if you suspect the disk, CHKDSK.

System information

CommandPurpose
winverExact Windows version in a window
systeminfoSummary: model, RAM, install date, patches
hostnameComputer name
powercfg /batteryreportLaptop battery health report
Get-ComputerInfoDetailed info (PowerShell)
Get-PhysicalDiskDrives, type (SSD/HDD) and health (PowerShell)

powercfg /batteryreport saves a battery-report.html file in the current folder. Open it and compare Design capacity with Full charge capacity: the difference is wear.

To get the computer’s serial number or the key stored in BIOS, see recover the BIOS serial number.

Programs and processes

View what is running and close a frozen program:

tasklist
taskkill /IM notepad.exe
taskkill /IM notepad.exe /F

/F forces closing: unsaved work is lost. In PowerShell the equivalent is:

Get-Process
Stop-Process -Name notepad

To install and update programs from the console, the tool is winget; see the winget guide.

Shut down and restart

shutdown /s /t 0
shutdown /r /t 0
shutdown /s /t 3600
shutdown /a
  • /s shuts down, /r restarts and /t sets the wait in seconds.
  • shutdown /s /t 3600 shuts down in an hour.
  • shutdown /a cancels a scheduled shutdown.

For repeated tasks (shutting down every night, for example), Task Scheduler is better.

Moving around folders

The basics to not get lost in the console:

CommandWhat it doesExample
dirLists contentsdir
cdChanges foldercd Documents · cd ..
mkdirCreates a foldermkdir Backups
copyCopies filescopy note.txt D:\
moveMoves or renamesmove note.txt Backups
delDeletes filesdel note.txt
clsClears the screencls

Careful with del: what it deletes does not go to the Recycle Bin. To copy or sync whole folders, use robocopy.

If a path has spaces, quote it: cd "C:\Program Files".

Two time-saving tricks: press Tab so the console completes a folder or file name, and use the ↑ and ↓ arrows to recall previous commands without retyping. In PowerShell, Tab also completes command and parameter names.

Variables in paths

Long paths are shortened with environment variables. For example, cd %USERPROFILE% in CMD (or cd $env:USERPROFILE in PowerShell) takes you to your user folder whatever its name. To learn what they are and how the PATH variable works, see environment variables in Windows.

Basic command cheat sheet: dir to list, cd to change folder, copy to copy and del to delete
Four commands to move around without fear.

And for the network

Network commands (ipconfig, ping, tracert, nslookup…) have their own guide: Windows network commands explained.

Frequently asked questions

Can I break something with these commands? sfc, DISM and chkdsk are meant to repair and are safe. The ones that can harm are those that delete (del, rmdir) or force close: check what you type before pressing Enter.

It says “Access denied” or “requires elevation”. You opened the console without rights. Close it and open with Terminal (Admin).

How do I see a command’s help? In CMD add /? (for example chkdsk /?). In PowerShell, Get-Help Stop-Process.

sfc found errors but could not repair them? Run DISM with /RestoreHealth first, restart and run sfc /scannow again. If it persists, you may need to repair Windows from an installation USB.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor