50 Basic Windows Commands With Examples
50 Basic Windows Commands With Examples
with Examples
Last Updated: December 8, 2022 by Robert Allen 8 Comments
Learn basic windows commands that can help you with troubleshooting,
configuration, and gathering system details.
Tip: Most windows commands include a help menu that lists all the command
options and syntax. Type the command followed by /? to view the help menu.
For example, ping /?
The ping command is still one of my favorite tools for testing basic network
connectivity. It’s fast and very easy to use. In addition, I use it for the following:
ping 192.168.100.1
Ping by hostname.
ping dc1.ad.activedirectorypro.com
For most windows commands you can type the command followed by /? to
view the help info, it will display the full syntax and parameters. So to view the
help for ping use this command:
ping /?
ping -a 142.250.177.46
-t switch will do a continuous ping. A very popular command for testing
network connectivity.
ping -a 192.168.5.1
For more details on the ping command see Microsoft’s ping documentation.
This command can also display the DNS cache on the local machine, flush
DNS, release and renew the DHCP address on all network cards.
To view the IP configuration for all network cards on a computer type the
command below and press enter.
ipconfig /all
/all switch to display IP info for all network cards.
ipconfig /all
ipconfig /flushdns
ipconfig /registerdns
/release to release DHCP addresses. This will release DCHP address on the
network cards that are configured for DHCP.
ipconfig /release
/renew switch will renew DHCP address for all network cards.
ipconfig /renew
ipconfig /displaydns
The nslookup command is used to check DNS records and troubleshoot DNS.
This is a must-have command for any sysadmin or network engineer. You can
do all kinds of tests to verify DNS is working correctly, you can check PTR, A,
MX, SOA, and many other types of DNS records. It’s another one of my
favorite windows commands for network troubleshooting.
This command I don’t use very often but still comes in handy when
troubleshooting the network. For example, we had some speed issues with a
website from our ISP, on a different ISP we had no issues. The ISP had us run a
traceroute so they could see the path it took.
Tracert examples
The syntax for this command is tracert followed by the hostname or IP.
tracert google.com
This command has very few options. The only command line switch on this
one that I find useful is the -d which is used to not resolve the address to
hostname.
5. shutdown command
The shutdown command does exactly that, it shuts down a computer. This
command is useful for shutting down or restarting local or remote computers.
It also provides a quick way to see all the logs for why a computer restarted or
was shut down.
shutdown examples
shutdown /r /m \\pc2
shutdown /s /m \\pc2
shutdown /d
Here is an example output for the shutdown /d command. This can be useful
to quickly check why a computer restarted or shutdown.
More shutdown examples
Some of these use multiple switches, refer to the help file shutdown /? for an
explanation of each command switch.
shutdown /l /m \\pc2
shutdown /r /m \\pc2 /t 0
Shutdown the local computer and specify the time period before shutdown in
seconds.
shutdown /s /t 60
shutdown /a
shutdown /s /f
This command will pull down any GPO changes to the computer.
gpupdate
Use /force to reapply all the GPOs on the computer.
gpupdate /force
Check out my gpupdate tutorial for more examples and a video walkthrough.
netstat -a
netstat -a -n
Here is the output of the above command. You can see how you can verify
server and client connectivity. It shows that my domain controller with IP
192.168.100.10 has established these four connections with IP 192.168.100.11.
More netstat examples
netstat -ab
Displays ethernet statistics. This is a quick way to check for network card errors
and discards.
netstat -e
Displays the exe and the process ID (PID) associated with the connection.
netstat -abo
netstat -r
netstat -af
dcdiag /s:DC1
In this example, I will stop and start the printer spooler service.
10. systeminfo
You can run this command on remote computers with the /s parameter.
getmac /s pc1
This is another must know command if you work with Active Directory servers.
To display all applied GPOs run this command. Note: You need to run the
command prompt in administrator mode or it will not generate a full report.
gpresult /r
The above command will give a report for both user and computer applied
GPOs.
gpresult /r /scope:user
gpresult /r /scope:computer
gpresult /s pcname
Generate an HTML report.
gpresult /h c:\report.html
This command displays who is currently logged on to the local system. It also
can display what groups a user belongs to. Use this command to display the
logged on users group membership.
whoami
whoami /groups
Pretty cool right?
whoami /upn
whoami /user
whoami /all
14. telnet client
I use the windows telnet client to test if a remote host is allowing connection
on a specific port. I typically use this when someone says your firewall is
blocking a program from working.
If you know the port number the application runs on you can use the
command below. In this example, I installed filezilla server so port 21 should
be open.
telnet srv01 21
You may or may not get a response back from the remote server. In this case
with filezilla I do. You could also just get a blank screen on a successful
connection.
If it doesn’t get a connection you should get a message like the below.
That is all I use the telnet client for. For complete command syntax
view Microsoft’s telnet documentation.
One little trick with this command is you can type the command followed by
string and it will only display those results. For example, if I want to find
everything that starts with path I would use this command
set path
cd windows
You can also start typing the directory name and hit tab to auto complete. For
example, to change to the “Program Files” directory I can type cd pro and hit
tab and it will auto complete the path.
sfc /scannow
chkdsk /f
route print