Here are 35 Windows Commands you NEED to know with example and explanation
-
dir - Display a list of files and folders in a directory.
- Example:
dir C:\Users\
- Explanation: This command will display a list of files and folders in the C:\Users\ directory.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir
- Example:
-
cd - Change the current directory.
- Example:
cd C:\Windows\
- Explanation: This command will change the current directory to C:\Windows.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cd
- Example:
-
copy - Copy one or more files to another location.
- Example:
copy C:\file.txt D:\backup\
- Explanation: This command will copy the file.txt from the C:\ directory to the D:\backup\ directory.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/copy
- Example:
-
del - Delete one or more files.
- Example:
del C:\file.txt
- Explanation: This command will delete the file.txt file from the C:\ directory.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/del
- Example:
-
type - Display the contents of a text file.
- Example:
type C:\file.txt
- Explanation: This command will display the contents of the file.txt file in the C:\ directory.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/type
- Example:
-
ren - Rename a file or directory.
- Example:
ren C:\oldname.txt newname.txt
- Explanation: This command will rename the oldname.txt file in the C:\ directory to newname.txt.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ren
- Example:
-
rmdir - Remove an empty directory.
- Example:
rmdir C:\emptyfolder
- Explanation: This command will remove the emptyfolder directory from the C:\ directory.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rmdir
- Example:
-
md - Create a new directory.
- Example:
md C:\newfolder
- Explanation: This command will create a new folder called "newfolder" in the C:\ directory.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/md
- Example:
-
pushd - Change the current directory and push the current directory onto a stack.
- Example:
pushd C:\Windows\
- Explanation: This command will change the current directory to C:\Windows\ and push the current directory onto a stack.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pushd
- Example:
-
popd - Change the current directory to the topmost directory on the stack.
- Example:
popd
- Explanation: This command will change the current directory to the topmost directory on the stack.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/popd
- Example:
-
netstat - Display active TCP connections and ports on which the computer is listening.
- Example:
netstat -a
- Explanation: This command will display all active TCP connections and the ports on which the computer is listening.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netstat
- Example:
-
ipconfig - Display the current TCP/IP configuration.
- Example:
ipconfig
- Explanation: This command will display the current TCP/IP configuration for the computer.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ipconfig
- Example:
-
ping - Test the connection to a remote host.
- Example:
ping www.google.com
- Explanation: This command will test the connection to www.google.com by sending a series of packets and displaying the response time.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ping
- Example:
-
tracert - Trace the route to a remote host.
- Example:
tracert www.google.com
- Explanation: This command will trace the route to www.google.com and display the hops taken to reach the destination.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tracert
- Example:
-
telnet - Connect to a remote host using the Telnet protocol.
- Example:
telnet www.google.com
- Explanation: This command will connect to www.google.com using the Telnet protocol.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet
- Example:
-
nslookup - Query DNS to resolve a hostname to an IP address or vice versa.
- Example:
nslookup www.google.com
- Explanation: This command will query DNS to resolve the hostname www.google.com to an IP address.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup
- Example:
-
tasklist - Display a list of currently running processes.
- Example:
tasklist
- Explanation: This command will display a list of currently running processes on the computer.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tasklist
- Example:
-
taskkill - Terminate a running process.
- Example:
taskkill /pid 1234
- Explanation: This command will terminate the process with the process ID 1234.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill
- Example:
-
systeminfo - Display system information.
- Example:
systeminfo
- Explanation: This command will display information about the system, such as the operating system version and the installed hotfixes.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/systeminfo
- Example:
-
driverquery - Display a list of installed device drivers.
- Example:
driverquery
- Explanation: This command will display a list of installed device drivers on the computer.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/driverquery
- Example:
-
net - Manage network resources.
- Example:
net share
- Explanation: This command will display a list of shared network resources.
- For More Details: https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/net-commands-on-operating-systems
- Example:
-
netdom - Manage Active Directory domains and trusts.
- Example:
netdom join contoso /domain:contoso.com /userd:contoso\admin /passwordd:password
- Explanation: This command will join the computer to the contoso domain using the contoso\admin user and password.
- Example:
-
sfc - Scan and repair system files.
- Example:
sfc /scannow
- Explanation: This command will scan all protected system files and replace any corrupted files with a cached copy.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sfc
- Example:
-
chkdsk - Check a disk for errors and repair them.
- Example:
chkdsk C: /f
- Explanation: This command will check the C: drive for errors and repair them if possible.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chkdsk
- Example:
-
diskpart - Manage disks, partitions, and volumes.
- Example:
diskpart
- Explanation: This command will open the DiskPart utility, which allows you to manage disks, partitions, and volumes from the command line.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart
- Example:
-
bcdedit - Manage the boot configuration data store.
- Example:
bcdedit /set {default} bootstatuspolicy ignoreallfailures
- Explanation: This command will set the boot status policy to ignore all failures.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bcdedit
- Example:
-
bootrec - Repair the boot configuration data store.
- Example:
bootrec /fixboot
- Explanation: This command will repair the boot configuration data store and write a new boot sector to the system partition.
- Example:
-
shutdown - Shut down the computer.
- Example:
shutdown /s
- Explanation: This command will shut down the computer.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown
- Example:
-
logoff - Log off the current user.
- Example:
logoff
- Explanation: This command will log off the current user.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logoff
- Example:
-
powercfg - Configure power options.
- Example:
powercfg /hibernate on
- Explanation: This command will enable the hibernate feature.
- Example:
-
wmic - Execute Windows Management Instrumentation (WMI) commands.
- Example:
wmic path win32_process get name
- Explanation: This command will display the names of all processes running on the computer.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wmic
- Example:
-
reg - Manage the registry.
- Example:
reg add HKLM\Software\Example /v ValueName /t REG_SZ /d "Hello World"
- Explanation: This command will add a new value to the registry at HKLM\Software\Example.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg
- Example:
-
cmdkey - Manage stored user names and passwords.
- Example:
cmdkey /add:server01 /user:john /pass:password
- Explanation: This command will add a new stored user name and password for the server01 server.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmdkey
- Example:
-
certutil - Manage certificates.
- Example:
certutil -addstore -enterprise root ca.crt
- Explanation: This command will add the ca.crt certificate to the enterprise root certificate store.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certutil
- Example:
-
schtasks - Schedule tasks to run at a specific time.
- Example:
schtasks /create /tn "Backup Task" /tr "robocopy C:\data D:\backup /mir" /sc daily /st 01:00
- Explanation: This command will create a new task called "Backup Task" that runs the robocopy command to copy data from C:\data to D:\backup every day at 1:00 AM.
- For More Details: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks
- Example:
If You are using Medium Please support and follow me for interesting articles. Medium Profile
If this guide has been helpful to you and your team please share it with others!