Skip to content

15 Windows Command Prompt (CMD) Commands You Must Know

In this post, I’1000 going to show yous the best Windows cmd commands that every network and system administrator should know.

In fact:

I still prefer these bones windows commands over PowerShell for bones troubleshooting tasks. The good matter is these commands are uniform with PowerShell so yous tin use them from the Windows control prompt or PowerShell console.

Table of contents:

  1. Ping
  2. ipconfig
  3. nslookup
  4. tracert
  5. shutdown
  6. gpupdate
  7. netstat
  8. dcdiag
  9. net stop and net start
  10. systeminfo
  11. getmac
  12. gpresult
  13. whoami
  14. telnet client
  15. fix

What are Windows CMD Commands?

Windows commands are small-scale programs that collaborate with the operating organization to provide you with systems information. They are likewise used to automate many It operations that administrators must perform. PowerShell is the predecessor to the Windows command prompt just it notwithstanding remains function of the Windows operating system. All windows commands can exist run from the PowerShell console and used in scripts.

Although PowerShell is the preferred choice for automating operations there are still many cracking Windows commands that yous should know. They are yet the best option for bones network and estimator troubleshooting. In add-on, they are dandy for getting systems details like the IP address, hostname, and then on.

When an Information technology technician works on a estimator they will often use windows commands to get arrangement details and troubleshoot an issue. In this guide, I walk through many of those commands used by the helpdesk and sysadmins.

1. ping


The ping control tests network connectivity between two devices by sending ICMP echo requests. For example, computer A tests if information technology has connectivity to reckoner B past sending some packets back and forth.

The ping command is still one of my favorite tools for testing basic network connectivity. It’southward fast and very easy to use. In addition, I use it for the following:

  • Exam for bundle loss
  • Test latency
  • Examination DNS queries
  • Examination connectivity with configuring new connections (can my router talk to the next hop such every bit the ISPs router?)

Ping Example

To exam the connectivity to some other device by IP or hostname utilize the command beneath

        ping 192.168.100.x
      

or by hostname

        ping dc1.ad.activedirectorypro.com
      

For most windows commands you can type the command followed by /? to view the help info, information technology will brandish the full syntax and parameters. So to view the assistance for ping utilize this command:

        ping /?
      

More Ping Examples

-l switch specifies a package size

        ping -l 2024 192.168.five.1
      

-a switch will do a reverse name resolution on the IP (PTR record lookup)

        ping -a 142.250.177.46
      

-t switch will exercise a continuous ping. A very popular command for testing network connectivity.

        ping -a 192.168.5.1
      

Send any command output to a text file

        ping -t > c:\it\examination-ping.txt
      

Here is the ping command ran from PowerShell. It’s the exact same syntax as using CMD.

ping from powershell

For more details on the ping command see Microsoft’s ping documentation.

ii. ipconfig

ipconfig

ipconfig is used to display organisation TCP/IP configuration. You tin can display the IP info for a unmarried or all network cards installed on a computer.

Only.. Look in that location is more than!

This control tin can too display the DNS cache on the local machine, affluent DNS, release and renew the DHCP address on all network cards.

ipconfig command example

To view the IP configuration for all network cards on a estimator type the command beneath and press enter

        ipconfig /all
      

Here are some additional parameters that I find useful. Remember yous can type ipconfig /? to view the unabridged command syntax and list of parameters.

More ipconfig examples

/all switch to display IP info for all network cards

        ipconfig /all
      

/flushdns switch to articulate the local DNS resolver cache

        ipconfig /flushdns
      

/registerdns to trigger dynamic registration of the DNS names and IP addresses that are configured on the computer

        ipconfig /registerdns
      

/release to release DHCP addresses. Will release DCHP address on the network cards that are configured for DHCP.

Popular:   How to Create Log and Semi-Log Graphs in Google Sheets

        ipconfig /release
      

/renew switch will renew DHCP address for all network cards

        ipconfig /renew
      

/displaydns switch volition brandish the DNS client enshroud.

        ipconfig /displaydns
      

iii. nslookup

nslookup

The nslookup command is used to check DNS records and troubleshoot DNS. This is a must-have command for any sysadmin or network engineer. Yous can practise all kinds of tests to verify DNS is working correctly, yous 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.

Nslookup command example

To exam that the A record of a hostname follow these ii steps

Footstep 1:
Blazon nslookup and printing enter

Step 2:
blazon in a domain name and press enter


four. tracert

tracert

The tracert command is used to rail the pathway a packet takes from a source IP to the destination address. This simply ways it’due south going to display each hop (router) that the package passes through to reach its destination.

This control I don’t use very frequently only still comes in handy when troubleshooting the network. For example, we had some speed problems with a website from our Internet service provider, on a different ISP we had no bug. The Internet service provider had united states run a traceroute so they could run into the path information technology took.

Tracert case

The syntax for this command is tracert followed by the hostname or IP.

        tracert google.com
      

This control 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

shutdown

The shutdown command does exactly that, it shuts down a computer. This control is useful for shutting down or restarting local or remote computers. It likewise provides a quick mode to see all the logs for why a computer restarted or was shut down.

shutdown examples

This control volition restart reckoner pc2

        shutdown /r /yard \\pc2
      

This command volition close downwardly the remote computer

        shutdown /due south /m \\pc2
      

View previous shutdown/restart logs

        shutdown /d
      

Here is an case output for the shutdown /d command. This can be useful to speedily check why a computer restarted or shutdown.


More shutdown examples

Some of these utilise multiple switches, refer to the assist file shutdown /? for an explanation of each command switch.

Log user off of a remote reckoner

        shutdown /50 /m \\pc2
        
      

Restart a remote computer with no countdown

        shutdown /r /m \\pc2 /t 0
      

Shutdown local estimator and specify fourth dimension period before shutdown in seconds

        shutdown /south /t 60
      

Shutdown a remote computer with a custom message

        shutdown /m \\pc2 /c "Rebooting computer, have a squeamish day"
      

Abort a system shutdown

        shutdown /a
      

Forcefulness applications to close without warning

        shutdown /s /f
      

6. gpupdate

gpupdate

The gpupdate command is used to apply group policies on a reckoner in a windows domain. This is a very popular command, I see a lot of helpdesk techs that employ it. Sometimes you lot can run this command to refresh the GPOs and avoid a reboot but that doesn’t ever work.

gpupdate command examples

This control will pull downward whatsoever GPO changes to the calculator

        gpupdate
      

Utilize this choice to reapply all the GPOs on the computer.

        gpupdate /force
      

7. netstat

netstat

This is such an awesome command.

The netstat command displays TCP/IP connexion data, ethernet stats, and the computer’s routing tabular array. Every bit a sysadmin I apply this command on Windows servers and clients when troubleshooting connexion issues. I tin verify application servers are working correctly by checking that the service is running and listening for connections on the port.

Popular:   How to Make Your Spotify Playlists Private

netstat command examples

Display all active and listening ports

        netstat -a
      

Display all connections in numerical order

        netstat -a -n
      

Here is the output of the higher up command. You tin can see how y’all can verify server and client connectivity. It shows that my domain controller with IP 192.168.100.x has established these four connections with IP 192.168.100.11.


More netstat examples

Displays the executable that is used to create the connexion

        netstat -ab
      

Displays ethernet statistics. This is a quick way to cheque for network carte du jour errors and discards

        netstat -e
      

Displays the exe and the process ID (PID) associated with the connectedness.

        netstat -abo
      

Displays the reckoner local routing table

        netstat -r
      

Displays FQDN with the connectedness info.

        netstat -af
      

8. dcdiag

If you are the administrator of Active Directory then you must know this command. This command volition analyze the state of your domain controllers, information technology has over 30 built in tests. Y’all should be running this command at regular intervals to ensure your domain environment is healthy.

dcdiag

dcdiag examples

To run dcdiag on a specific domain controller utilise this command

        
          dcdiag /s:DC1
        
      

9. internet stop and net get-go


Simple command to start and stop windows services

Examples

In this case, I will finish and start the printer spooler service

        net terminate spooler
      

and now outset the spooler service

        net kickoff spooler
      

That is it for this command, there are no boosted parameters.

10. systeminfo

systeminfo

The systeminfo command displays configuration details on a computer such every bit OS proper noun and version, hardware data, boot time, logon server, and more than.

There are a lot of details this command displays, I typically use it to bank check final boot fourth dimension, logon server, and Bone version.


Y’all tin run this command on remote computers with the /south parameter

        system info /southward pc1
      

11. getmac

getmac

This command returns the MAC accost from all the network cards on a organization. When troubleshooting a customer connection issue I volition often demand the computer’s MAC address so I tin can verify I see information technology continued on the switch. This command is the best way to quickly catch a computer’s MAC address.

To run it on a local computer merely type getmac.

To run on a remote computer use the /s parameter

        getmac /s pc1
      

12. gpresult

gpresult

The gpresult command reports on what grouping policies and settings are applied to a user or reckoner.

This is some other must know command if you work with Agile Directory servers.

To display all practical GPOs run this command. Note: You need to run the command prompt in administrator mode or it will non generate a total report.

        gpresult /r
      

The above command volition requite a report for both user and figurer applied GPOs.


and the computer settings


More GPResult examples

Display GPOs applied to the user

        gpresult /r /scope:user
      

Display GPOs applied to the computer

        gpresult /r /telescopic:computer
      

Brandish GPOs for a remote computer

        gpresult /south pcname
      

Generate an HTML report

        gpresult /h c:\report.html
      

Send command output to a text file

        gpresult /r > c:\upshot.txt
      

13. whoami

whoami

This command displays who is currently logged on to the local system. It also tin can display what groups a user belongs to. Use this control to display the logged on users group membership.

        whoami /groups
      

Pretty cool right?

More whoami commands

Display the user proper noun in UPN format

        whoami /upn
      

Displays current domain, username and users SID

        whoami /user
      

Displays all data for the current user

        whoami /all
      

14. telnet client

telnet

I apply the windows telnet client to test if a remote host is allowing connection on a specific port. I typically utilize this when someone says your firewall is blocking a program from working.

Popular:   How to Fix the \What Needs Your Attention\" Error on Windows"

If you know the port number the application runs on you lot tin can use the control below. In this instance, I installed filezilla server so port 21 should exist open.

The syntax is telnet + hostname or IP + port number

        telnet srv01 21
      

You lot may or may not go a response back from the remote server. In this case with filezilla I do. You lot could as well simply get a blank screen on a successful connection.


If it doesn’t get a connexion you should get a message like the below.


That is all I utilize the telnet customer for. For complete command syntax view Microsoft’s telnet documentation.

15. gear up

set

The set command displays environs variable information.

I don’t employ this control that often only nonetheless is useful to cheque a user’due south logon server or quickly await at the environment variables.

Ane little trick with this command is you can type the command followed by string and it will simply display those results. For example, if I want to find everything that starts with path I would use this command

        ready path
      

At present information technology merely displays everything that starts with “path”.


Basic Windows Commands

Hither are some additional basic commands.

  • CD – Use this control to alter directories
  • MKdir – This command is used to create new directories
  • SFC – System file Checker
  • Internet apply – This command is used to map a bulldoze to a network share
  • CHKDSK – Scans the drive for errors
  • Route – Displays the local routing table
  • Powercfg – Manage ability settings
  • Tasklist – Become a current list of running programs
  • Taskkill – Stop a program from running
  • Format – Format a deejay from the command line
  • cls – Clear the screen. This comes in useful when the screen is a mess.
  • Diskpart – Displays disk partition
  • Robocopy – Keen command to copy files and directories
  • Xcopy – Another command used to copy files and directories

Oft Asked Questions

How do I open up the control prompt?

Click First and type cmd.

Click on the control prompt


Is there a command to list all Windows commands?

You lot can type aid to get a list of the system default commands.


Unfortunately, this will not list commands that take been installed past other programs like the RSAT tools. To run across a consummate listing of commands the Microsoft Windows Commands documentation.

How practice I run the command prompt every bit administrator?

This is a great question as some commands will not run unless the command prompt is in ambassador mode.

To run the control prompt every bit an ambassador correct click on “command prompt” and select “Run as administrator”


How do I get my IP address from the control prompt?

Employ the command ipconfig. Use the command ipconfig /all to display IP information for all network adapters.

How do I get my hostname?

Use the control hostname.


Summary

At that place you get the pinnacle 15 windows commands that I still use on a regular basis. All of these commands can be used in PowerShell or the old (and dead) Windows CMD. These commands are smashing no thing where you are at in your IT career. I’ve used some of these commands since I started as a helpdesk tech and still use them as a sysadmin/network engineer.

Got any commands you lot all the same employ? Please share them in the comment section below.

15 Windows Command Prompt (CMD) Commands You Must Know

Source: https://activedirectorypro.com/windows-cmd-commands/