25 Windows CMD Commands You Should Know

Index

  • Que es CMD
  • List of cmd commands
    • CD: To move between discs and folders
    • DIR: To list the files and directories
    • ATTRIB: Change file attributes
    • DISKPART: Partition Management
    • ASSOC: Correct File Associations
    • FC: File Comparison
    • IPCONFIG: IP Configuration
    • NETSTAT: Network Statistics
    • PING: Send test packets
    • TRACERT: Trace the route
    • POWERCFG: Power Configuration
    • SHUTDOWN: Turn off the computer
    • SYSTEMINFO: System Information
    • SFC: System File Checker
    • NET USE: Map Units
    • NETSH command
      • Commands in this context:
        • Reset TCP/IP stack with Netsh
          • Import and explore network settings
        • CHKDSK: Check the hard drive
        • SCHTASKS: Schedule Tasks
        • Other Windows CMD commands

In this article I am going to show you what the Windows CMD is, how to use it and the most important and useful commands.

Que es CMD

Window has a command console called Command Prompts or CMD which is a feature that has been a core part of the Windows operating system for a long time. This console allows you to execute text commands, mainly to make system administration easier and faster. There are commands to manage folders, files, disk management, network management, fix errors etc. Some commands that are so useful and easy to use that even regular users see Windows command prompts as a key part of the operating system.

There are always rumors that it will be removed at some point… but that’s unlikely to happen any time soon.

List of cmd commands

The following are 25 of the best CMD commands that you should know if you want more control over your Windows PC.

CD: To move between discs and folders

Are you thinking how to enter a folder by CMD? The cd command is essential for the use of the Windows console since it is the one that allows you to move through the folders and through the hard drives. If you put cd <ruta de la carpeta que quieres entrar>it, it will go to the folder that you have put in the path , if you put it, cd <letra de unidad>it will go to the unit that you have put, and if you put it, cd ..it will go to the folder of a higher level.

DIR: To list the files and directories

The dir command is used to list the files and folders you have in the current directory you are in.

ATTRIB: Change file attributes

In Windows you can change file attributes by right-clicking on a file and finding the correct property to change. But you can also use the ATTRIB command to set file attributes.

I have already talked about ATTRIB command to unhide folders and files and how we use it to recover hidden files after Airhashing virus removal

For example, if you type: ATTRIB +R +HC:\temp\file1.bat, it will make file1.bat a hidden, read-only file.

There is no response when successful, so unless you see an error message, the command worked.

DISKPART: Partition Management

The Diskpart command allows you to create, delete and modify partitions from the command console. To learn more about its use, I recommend that you take a look at the article on how to use the Diskpart command .

ASSOC: Correct File Associations

One of the most powerful tools in the CMD command library is the ASSOC command.

Your computer associates certain file extensions with certain programs. This is how your computer knows to open Adobe when you duplicate… click on a PDF file, or Microsoft Word when you double-click on a DOC file.

You can see all the file associations that your computer knows about by typing ASSOC in the command window. You will see the file extension and the program it is associated with.

You can set the association by typing something like assoc .doc=Word.Document.8.

FC: File Comparison

Sometimes when files are changed over time, it’s hard to
remember what the differences were between the versions. You may not know that a
CMD command offers the ability to compare files and see all the differences, but
it is true.

The FC command performs an ascii or binary file comparison and will list any differences it finds.

fc /a file 1.txt file 2.txt will compare two ascii files.

fc /b image1.jpg image2.jpg will do a binary comparison on two images.

IPCONFIG: IP Configuration

Network troubleshooting is never simple, but one command that makes it much easier is IPCONFIG.

Using this command at the CMD prompt gives you detailed
information about your current network adapter connection, including:

  • current IP address
  • Subnet mask
  • Default gateway IP
  • current domain

This information can help you troubleshoot router and other connection issues you might be experiencing with your network adapter.

The IPCONFIG command can also be used to release and renew IP in addition to other DNS functions, if you want to know how I recommend the article: How to release and renew an IP address from CMD

NETSTAT: Network Statistics

Worried that you might have malware running on your computer that connects to places on the Internet without you knowing?

If you run NETSTAT at the command line, you can get a list of all active TCP connections on your computer.

If you are worried about knowing if your computer is being spied on, I recommend the article: How to know if my PC is being monitored

PING: Send test packets

An IT analyst’s best friend is the PING command. Running this command sends test packets over the network to the target system.

You can use the PING command to check if your computer can access another computer, a server, or even a website. It can help with disclosing network disconnections. It also provides transit time for packets in milliseconds, so it also reveals a bad network connection.

TRACERT: Trace the route

TRACERT is a fascinating Windows Command to use. If you’re ever curious to see the path your Internet traffic takes to get from your browser to a remote system like Google servers, you can use TRACERT to see it.

The command stands for “Trace Route”, which sends packets
to a remote destination (server or website), and provides it with all of
the following information:

  • Number of hops (intermediate servers) before
    reaching the destination
  • The time it takes to reach each jump
  • The IP and sometimes the name of each hop

TRACERT can reveal how the paths of your Internet requests
change depending on where you are accessing the web. It also helps with
troubleshooting a router or switch on a local network that may be problematic.

POWERCFG: Power Configuration

Are you frustrated by how fast your laptop seems to run
without power? It could be that your power settings are set
to be as efficient as possible. There is a Windows CMD command called POWERCFG (power configuration) that can
help. Run the command prompt as administrator and type powercfg –energy to get a full energy efficiency report.

The process can take up to a minute, but when it’s done,
you’ll see if there are any warnings or errors that can help you improve
your system’s energy efficiency.

See the energy-report.html file for details of those
errors and warnings.

SHUTDOWN: Turn off the computer

The shutdown command is quite versatile in that it allows you to shut down the computer but control the behavior of that shutdown. It is commonly used as a scheduled task or part of an IT batch job after patches have been applied to a computer system.

Typing shutdown /i from the command line will initiate a shutdown, but it will be a GUI that will give the user a choice as to whether to reboot or do a complete shutdown. If it doesn’t
If you want any graphical interface to appear, you can issue a shutdown command.

There is a long list of other parameters that can be used to do a logoff, hibernate, reboot and more. Just type “shutdown ” without any argument to see them all.

SYSTEMINFO: System Information

If you need to know what brand of network card you have, processor details, or the exact version of your Windows operating system, the SYSTEMINFO command can help.

This command polls your system and retrieves the most important information about your system. It lists the information in a clean format that is easy to read.

If you want to see more options to see information about your system, I recommend the article on how to know what Windows I have installed

SFC: System File Checker

If you’re ever concerned that a virus or other software may have corrupted your core system files, there’s a Windows command that can scan those files and ensure their integrity.

You need to start CMD as administrator (right click and
select Run as administrator). Typing SFC /SCANNOW will check the integrity of all files on the protected system. If a problem is found, the files will be repaired with backup system files.

The SFC command also allows you following attributes:

  • /VERIFYONLY: Check the integrity but do not repair the files.
  • /SCANFILE: Scans the integrity of specific files and fixes them if they are corrupted.
  • /VERIFYFILE: Verifies the integrity of specific files but does not repair them.
  • /OFFBOOTDIRUse this to do repairs to an offline boot directory.
  • /OFFWINDIR: Use this to make repairs to an offline Windows directory.
  • /OFFLOGFILE: Specify a path to save a log file with scan results.

The scan can take up to 10-15 minutes, so give it time.

NET USE: Map Units

If you want to map a new drive, you can always open File Explorer, right-click “this computer”, and go through the Map Network Drive wizard.
However, using the NET USE command, you can do the same thing with a command string.

For example, if you have a shared folder on a computer on your network called “\\OTHER-PC\SHARE-FOLDER”, you can map this as your own Z: drive by typing the command:

NET USE Z: “\\OTRO-PC\CARPETA-COMPRATIDA” /persistent:yes

The /persistent:yes attribute means that this disk will be redone every time you log in. back on your computer.

NETSH command

Once you write the command if you give ? you will get the list of commands

Commands in this context:

.. – Go up one level of context.
? – Shows a list of commands.
abort – Discard changes made while in Offline mode.
add – Adds a configuration entry to a list of entries.
advfirewall – Switch to the `netsh advfirewall’ context.
alias – Add an alias.
branchcache – Switch to the `netsh branchcache’ context.
bridge – Switch to the `netsh bridge’ context.
bye – Exits the program.
commit – Commits changes made in offline mode.
delete – Deletes a configuration entry from a list of entries.
dhcpclient – Switch to the `netsh dhcpclient’ context.
dnsclient – Switch to the `netsh dnsclient’ context.
dump – Shows a configuration script.
exec – Executes a script file.
exit – Exits the program.
firewall – Switch to the `netsh firewall’ context.
help – Shows a list of commands.
http – Switch to the `netsh http’ context.
interface – Switch to the `netsh interface’ context.
ipsec – Switch to the `netsh ipsec’ context.
lan – Switch to the `netsh lan’ context.
mbn – Switch to the `netsh mbn’ context.
namespace – Switch to the `netsh namespace’ context.
netio – Switch to the `netsh netio’ context.
offline – Sets the current mode to Offline.
online – Sets the current mode to Online.
p2p – Switch to the `netsh p2p’ context.
popd – Pop a context from the stack.
pushd – Push the current context onto the stack.
quit – Quits the program.
ras – Switch to the `netsh ras’ context.
rpc – Switch to the `netsh rpc’ context.
set – Updates the configuration options.
show – Show information.
trace – Switch to the `netsh trace’ context.
unalias – Delete an alias.
wcn – Switch to the `netsh wcn’ context.
wfp – Switch to the `netsh wfp’ context.
winhttp – Switch to the `netsh winhttp’ context.
winsock – Switch to the `netsh winsock’ context.
wlan – Switch to the `netsh wlan’ context.

With this you will be able to many network management options from the command console.