The Top Command Line Commands That Every Windows Developer Should Know

The Top Command Line Commands That Every Windows Developer Should Know

Whether you're just starting your coding journey or you've been at it for years, mastering the Windows command line is one of those skills that just makes everything smoother.

Sure, we've got fancy IDEs and GUI tools, but sometimes the fastest way from point A to point B is through that Command Prompt or PowerShell window.

I've put together this list of essential commands that I find myself using constantly on Windows. Hopefully they'll save you time and make you more productive day in and day out.

Note: Most of these commands work in both Command Prompt (cmd) and PowerShell, but I'll mention when there are PowerShell-specific alternatives that are better.

File and Directory Navigation

cd - Change Directory Your main navigation command. cd .. goes up one level, cd %USERPROFILE% takes you to your user folder, and cd /d D:\Projects switches to a different drive and folder.

dir - List Directory Contents Shows files and directories in your current location. Use dir /a to see hidden files, dir /s to search subdirectories.

pwd (PowerShell) - Print Working Directory In PowerShell, this shows your current location. In Command Prompt, just type cd with no arguments.

mkdir or md - Make Directory Creates new folders. mkdir "My New Folder" creates a folder with spaces in the name.

rmdir or rd - Remove Directory Removes directories. Use rmdir /s foldername to remove a directory and all its contents.

File Operations

copy - Copy Files Copies files from one location to another. copy source.txt destination.txt copies a file.

xcopy - Extended Copy More powerful than copy. xcopy source destination /e /i copies directories and subdirectories, including empty ones.

move - Move/Rename Files Moves files or renames them. move oldname.txt newname.txt renames a file.

del - Delete Files Deletes files. del filename.txt removes a file, del *.tmp removes all .tmp files.

ren or rename - Rename Files Renames files or directories. ren oldname.txt newname.txt changes the filename.

Text Processing

type - Display File Contents Shows the contents of a text file. type readme.txt displays the file content.

more - View File Contents Page by Page Better for larger files since you can scroll through them page by page.

findstr - Search Text Windows equivalent of grep. findstr "searchterm" filename.txt finds lines containing your search term. Use /r for regular expressions.

find - Simple Text Search Simpler than findstr. find "text" filename.txt searches for exact text matches.

Process Management

tasklist - List Running Processes Shows all running processes. tasklist | findstr "notepad" finds all notepad processes.

taskkill - Terminate Processes Stops processes. taskkill /pid 1234 kills process with ID 1234, taskkill /im notepad.exe kills all notepad processes.

start - Start Programs Launches programs or opens files. start notepad.exe opens Notepad, start . opens current directory in Explorer.

Network and System Info

ping - Test Network Connectivity Tests if a host is reachable. ping google.com checks your connection to Google.

ipconfig - Network Configuration Shows network adapter information. ipconfig /all shows detailed info, ipconfig /release and ipconfig /renew refresh your IP address.

netstat - Network Statistics Shows network connections. netstat -an shows all connections and listening ports.

systeminfo - System Information Displays detailed system configuration information.

wmic - Windows Management Interface Powerful tool for system info. wmic cpu get name shows CPU info, wmic logicaldisk get size,freespace,caption shows disk space.

where - Find Files in PATH Finds executable files. where python shows where Python is installed.

forfiles - Advanced File Operations Performs operations on files based on criteria. forfiles /m *.log /c "cmd /c del @path" deletes all .log files.

dir with wildcards Use dir *.txt /s to find all .txt files in current directory and subdirectories.

Environment and Variables

set - Environment Variables Shows or sets environment variables. set PATH shows the PATH variable, set MYVAR=value sets a variable.

echo - Display Text Displays text or variable values. echo %PATH% shows the PATH variable content.

path - Display/Modify PATH Shows or modifies the PATH environment variable.

PowerShell Specific Commands

Get-Process - List Processes PowerShell way to list processes. More powerful than tasklist with object-oriented output.

Get-Service - List Services Shows Windows services and their status.

Get-ChildItem (or ls) - List Files PowerShell equivalent of dir, but with more powerful filtering options.

Get-Content - Read File Contents PowerShell way to read files. Get-Content filename.txt displays file contents.

Select-String - Search Text PowerShell's powerful text searching. Select-String "pattern" filename.txt searches for patterns.

Compression and Archives

tar - Archive Files (Windows 10+) Recent Windows versions include tar. tar -czf archive.tar.gz folder\ creates a compressed archive.

compact - File Compression Compresses files using NTFS compression. compact /c filename.txt compresses a file.

PowerShell Archive Commands:

  • Compress-Archive -Path folder -DestinationPath archive.zip creates a ZIP file
  • Expand-Archive -Path archive.zip -DestinationPath folder extracts a ZIP file

Version Control (Git)

git status - Check Repository Status Shows which files are staged, unstaged, or untracked.

git add - Stage Changes Stages files for commit. git add . stages everything, git add filename stages specific files.

git commit - Save Changes Commits staged changes. git commit -m "commit message" commits with a message.

git push and git pull git push uploads your changes to the remote repository, git pull downloads changes from the remote.

git log - View Commit History Shows the commit history. git log --oneline gives a condensed view.

Batch File Basics

@echo off - Suppress Command Display Put this at the top of batch files to hide the commands as they execute.

pause - Wait for User Input Pauses execution until user presses a key.

goto - Jump to Label Jumps to a labeled section in a batch file.

if - Conditional Execution if exist filename.txt echo File exists checks if a file exists.

Useful Shortcuts and Tips

cls - Clear Screen Clears the command prompt screen.

exit - Close Command Prompt Closes the current command prompt window.

doskey - Command History Sets up command aliases and shows command history features.

Tab Completion Press Tab to auto-complete file and folder names.

F7 - Command History Shows a popup with recent commands you can select from.

Windows-Specific File Operations

attrib - File Attributes Changes file attributes. attrib +h filename.txt hides a file, attrib -h filename.txt unhides it.

icacls - File Permissions Manages file and folder permissions. icacls filename.txt /grant Everyone:F gives everyone full access.

robocopy - Robust Copy Advanced file copying with many options. robocopy source dest /e /z /r:3 copies with error recovery.

Putting It All Together

The real power comes from combining these commands and using pipes (|) to chain them together. For example, you might use tasklist | findstr "node" to find Node.js processes, or dir *.log /s | find "error" to search for log files containing errors.

You can also create batch files (.bat) or PowerShell scripts (.ps1) to automate repetitive tasks. A simple batch file might look like:

@echo off
echo Starting development environment...
cd /d D:\Projects\MyApp
code .
npm start

Don't feel like you need to memorize everything at once. Start with the basics like cd, dir, mkdir, and del. As you get comfortable, add more commands to your toolkit. Most importantly, don't be afraid to experiment!

The Windows command line might seem intimidating at first, but once you get the hang of it, you'll wonder how you ever lived without it. It's fast, powerful, and these commands will make you more productive whether you're using Command Prompt or PowerShell.

Walt is a computer scientist, software engineer, startup founder and previous mentor for a coding bootcamp. He has been creating software for the past 20 years.

Community Comments

No comments posted yet

Code Your Own Classic Snake Game – The Right Way

Master the fundamentals of game development and JavaScript with a step-by-step guide that skips the fluff and gets straight to the real code.

"Heavy scripts slowing down your site? I use Fathom Analytics because it’s lightweight, fast, and doesn’t invade my users privacy."
Ad Unit

Current Poll

Help us and the community figure out what the latest trends in coding are.

Total Votes:
Q:
Submit

Add a comment