Windows command line, everything you need to know

Windows command line tools are still as useful today as they were in the days of text-based operating systems. Their use is not as intuitive as that of modern graphical interfaces (much more visual and easier to handle), but they still show an enormous potential when performing certain tasks..

Although this type of application is reminiscent of MS-DOS because of its type of execution, it is not the operating system based on DOS nor is it a part of the Windows system, but a tool that allows you to interact directly with the computer by executing commands. What we know as ‘Windows console’ is equivalent to the Linux terminal or the one provided by other operating systems such as macOS. Visually they are quite similar, but in practice they offer significant differences.

In any case it is a good way to perform repetitive tasks with greater flexibility, manage certain components, access certain system information that is not available in any other way or use in situations when the graphical interface is blocked. Widely used by system administrators, is also useful for the everyday user and it is useful to know at least its basic operation.

Windows command line types and accesses.

To know where these tools come from (today in Windows two different ones coexist) we must go back to Windows 95 where Microsoft included a primitive interpreter known as COMMAND.COM. From Windows NT (Windows XP and following) it released a command line application called “cmd.exe” or as it is commonly known, Command prompt (CMD). With some improvements, it has survived to the present day as the basic Windows console and allows to execute MS-DOS commands (.exe of 16 bits) and others as scripts in .bat and .sys format.

Windows command line

But there is more. Microsoft started working at the turn of the century on a more advanced console than the previous ones. Known in its development as Microsoft Shell or “Monad” it saw the light integrated in Windows Vista as PowerShell. It is a console interface (CLI) that goes beyond the features of CMD by allowing you to create your own commands and scripts using the C# programming language, plus features such as remote task execution, background tasks, task automation or command pipelining. It is the preferred choice for system administrators and more advanced users, but the learning curve is steeper than the basic CMD interpreter.

Two modes of use

Another issue to be aware of is that access to the Windows command line is provided in. two modes, user and administrator. The first one is limited and the second one is more powerful and has access to all functions. There are quite a few ways to access the Windows console, such as:

  • Type “CMD” or “PowerShell” from the general search box of any version of Windows to access one or the other.
  • You can also launch them from the run window (Windows + R to open it) and type “cmd” or “PowerShell”.
  • Finally, another very simple method of access is to access the advanced start menu by right-clicking on the start button.

Windows Terminal

In order to make it easier to use the console, Microsoft created a standalone, free and open source applicationwhich he defined as the “ultimate tool” to work with the two command line applications present in your operating systems. If you use Linux you will be familiar with its surname because this tool -like other advanced Windows tools- is clearly inspired by its Linux counterpart even in its name.

Developed externally to Windows, it can receive individual updates and upgrades without having to wait for regular operating system updates. Microsoft classified it as one of the “inbox” applications and therefore, in addition to being installed from the Microsoft Store or its GitHub page, it is included in the group of applications that it installs by default in Windows 10 and Windows 11.

Like CMD or Powershell, Windows Terminal runs in text mode, but offers a greater degree of customization in layout, colors or fonts, tabs and more that the previous ones don’t have. Microsoft has no plans to remove the individual applications, but Windows Terminal has become the ultimate command-line tool to interact with them and also with related ones such as the Windows Subsystem for Linux, allowing their execution from the same interface.

Usage and main commands

Whether you use Windows Terminal, CMD or PowerShell, you will find a text interface that will remind you of DOS systems, although it is not an operating system. This command line allows you to communicate directly with the computer. Its operation is as simple as it is powerful: We type the command and the CMD application acts as an interpreter. for its execution.

The use of modifiers for each of the commands allows you to execute. hundreds of combinations for a wide variety of tasks. Although its operation is a text mode, the console can be customized in design, colors or fonts by accessing its properties through a secondary click on the CMD frame. Windows Terminal has added features such as the use of tabs and others.

The commands are common to all of them. We leave you some of the most important ones because the complete list is very extensive:

Help. A good way to start is by using the “help” command which will show you a list of all available commands. “Help + command name” will show us information about a specific command while “Command name + /?” will show us all the modifiers and possibilities of the command.

Assoc. Most Windows files are associated with a specific program assigned to open the file by default. This command displays or modifies the file extension associations.

Chkdsk. Checks the status of a hard disk/partition/volume and displays a status report. Fixes disk errors or finds bad sectors and recovers information.

Driverquery. Device drivers are among the most important software installed on the PC. Their removal or improper installation is a constant source of problems. This command lists all the ones you have on the machine, their name, driver type, link date or directory where they are installed.

Powercfg. Powerful command for energy management of the equipment. Energy saving, sleep or hibernation states. Creates a detailed report of power consumption on a PC that allows to know a failure for this reason. Windows 8 has added a modifier that provides a detailed analysis of a laptop’s battery usage, capacity, state of charge or recharge cycles.

Shutdown. Shutdown, restart or hibernate the local computer. It has a lot of modifiers to schedule in time the shutdown or restart, a logout as well as force shutdown of applications. It is also used to document an unexpected system shutdown.

Sfc. Examines the integrity of all protected system files and replaces incorrect versions with the correct Microsoft versions. The command checks for damaged or missing files, replacing them automatically using cached copies of the system.

Systeminfo. Displays information about the operating system configuration of a local or remote computer, including service pack levels. It reports the processor installed, the physical and virtual RAM used and available, the BIOS, the motherboard manufacturer, as well as the operating system version used and all installed updates.

There are also groups of commands specialized for certain tasks such as the. for networksproviding a management and information capability that simply does not exist elsewhere in the operating system. The most useful in this section are:

Ipconfig. This is one of the most useful network commands. It reports the current TCP/IP network configuration values and updates the DHCP protocol and Domain Name System (DNS) settings.

Ping. Tests the communication status of the local host with one or more remote computers on an IP network. By sending ICMP packets, it diagnoses the status, speed and quality of a given network.

Tracert. It allows to know the packets coming from a host (network point). A statistic of the RTT or network latency of these packets is also obtained, providing an estimate of the distance between the ends of the communication.

Pathping. Combines the utility of ping and tracert. It is more informative, so it takes longer to execute. After sending packets to a given destination, it analyzes the route taken and calculates packet loss and provides details between two hosts.

Getmac. Gets the mac of the computer where it is executed. The MAC address is a 48-bit identifier determined and configured by the IEEE and the manufacturer (24 bits each). Also known as physical address, it is unique for each device.

Nslookup. It is used to find out if the DNS is resolving names and IPs correctly. It also allows us to find out the IP address behind a given domain name. If you want to convert an IP address into a domain name, just type it into the browser and see where it leads.

Netstat. Powerful command that displays network statistics and allows diagnostics and analysis. By default, it displays a listing of a computer’s active connections, both incoming and outgoing. It includes the protocol in use, routing tables, interface statistics and connection status.

Netsh. Synonymous of network shell, it allows to modify, manage and diagnose the configuration of a network, with more detail and power than the previous ones. An advanced command that offers a lot of options using its modifiers and, as an example, allows you to change the primary and secondary DNS of a computer.

Tricks to handle the Windows command line.

We already said that the use of the Windows console is not as simple or intuitive as that of a graphical interface. But there are a series of very convenient tricks to facilitate its handling, like the ones we are going to list.

1. Use the function keys. Most of the function keys (F1 to F9) have a function in the Windows console:

  • F1: Rewrites the last command used, character by character per keystroke.
  • F2: Prompts for a character, then retypes the last command used up to the first occurrence of that character.
  • F3: Completely rewrites the last used command.
  • F4: Requests a character, then deletes all characters in the current command, starting from the cursor position to the first occurrence of the requested character.
  • F5: Completely rewrites the previously used commands, but does not activate.
  • F6: Types ^ Z in the current command.
  • F7: Presents a menu of previously used commands.
  • F8: Completely rewrites the commands used ??previously.
  • F9: Completely rewrites a previously used command, which corresponds to the number in the menu presented by F7.

2. View the command history. When you want to see all the commands you have typed since the beginning of the session, you can use the “doskey /history” command. Doskey is a utility provided by Microsoft with several functions, one of which is the command history. It is basically the same as pressing F7, but in addition, it allows you to save, feed or manipulate the output of information.

3. Repeats a previous command. If you need to recall a previous command, either to repeat it or modify it, all you have to do is press the up arrow key on your keyboard. If you continue to press it, it will keep repeating previous commands starting with the most recent one. Functionally it is similar to using the F8 key except for one difference: the up arrow places the cursor at the end of the command while F8 places the cursor at the beginning of the command.

4. Execute several commands at once. If you need to run multiple commands, but each command takes a long time to execute, you can preempt this with the command “cd C: && echo…”. The commands will be executed in the order you typed them, starting from the left to the right of the console. New commands are not executed until the previous ones are finished.

5. Cancels a command in execution. If you ever run a command and it takes too long to execute, you can stop it by pressing “Ctrl + C”. Also useful when you want to stop an application or service.

6. Display information, page by page. Most Windows commands produce information output on the screen. Sometimes, it displays a huge amount of information that is inaccessible even if you scroll up. With the command “[command with output] | more” we get the console to display the information page by page, moving from one page to another by pressing the space bar key.

7. Filter the output of a command. If the output of a command is detailed and you need to find a particular line or instance of a word, you can filter the output with the command “[command with output] | find “query”. The search filter is applied line by line, so it will return all lines that include the query text.

8. Copy the output of a command. If you’re looking for help troubleshooting a system problem, you may need to output the information to an external tool. And it’s cumbersome if you don’t use a command such as “[command with output] | clip” which copies the information to the clipboard. From there, with the typical “Control + V” command, you can copy it wherever you want.

9. Save the output of a command. If your intention is to save the output of a command to a file, you can either use the above method or directly send it to a file with the “[command with output] > filename.txt”. The text file will be saved to the location of the command prompt you are using, although you can save it to any other location by setting the full path “… C:\folderfilename.txt)”.

10. Drag and drop files. If you are working with files in a deeply nested directory and need their full path names for a command, you have a few options. You can type them manually. You can copy the path from the File Explorer address bar and then type the file name. Or you can simply drag and drop the file directly into the command prompt.

The above commands and tricks are just a sampling of the great possibilities of the Windows console. Those who want more can use the PowerShell console interface (CLI) (more powerful than the CMD) and those who want to reunify everything and – incidentally – access the Windows Subsystem for Linux, have everything they are looking for in Windows Terminal. So accustomed to modern graphical interfaces, it will be difficult to get started with this type of tools that work in text mode, but are still highly recommended for certain tasks.

Click to rate this entry!
(Votes: 0 Average: 0)

Leave a Comment