Definition

What is a command prompt?

A command prompt is the input field in a text-based user interface screen for an operating system (OS) or program. The prompt is designed to elicit an action. The command prompt consists of a brief text string followed by a blinking cursor, which is where the user types command prompt commands.

What is Windows Command Prompt?

Command-line interfaces (CLI) and prompts were the standard interface for computers from the early days of computing into the 1980s. Microsoft MS-DOS systems and other early consumer-based computers used CLIs.

Current Windows systems offer the command prompt, which is a CLI for administrative tasks and works on the basis of the command entered in its text-based user interface. In the Windows OS, Command Prompt is an application (program) is used to execute administrative or troubleshooting commands, automate repetitive tasks, run groups of scripts and shut down processes.

A popular misnomer for the Windows Command Prompt is DOS prompt. The Windows CLI and DOS CLI are not the same, although the former includes some of the command-line abilities of the latter.

Other names for the Windows Command Prompt are as follows:

  • Windows Command Processor.
  • Command Shell.
  • cmd prompt.
  • cmd.exe.

The CLI is also an essential part of the Linux OS and is powerful and easy to use.

Is Command Prompt a tool?

In Windows, Command Prompt is an executable CLI program, cmd.exe. At the command prompt, the user types a statement including a base batch file or a command name and any arguments to specify running conditions, logging and so on for the program. In Windows systems, such as Windows 10 and many previous versions, the command interpreter and executioner are referred to as the Windows Command Processor.

Command prompt interfaces can be powerful and succinct. Some tools that aren't available through the Windows graphical user interface (GUI) can be accessed through the Command Prompt. It also offers superior automation through scripting, but mastering the commands can be challenging.

A chart comparing the benefits of a CLI to a GUI.
The CLI remains popular with network administrators because its speed for configuring interfaces, routing protocols and access lists is superior to a GUI.

How to access Command Prompt in Windows

There are various ways to open Command Prompt in the Windows OS. A common one in Windows is to use the Command Prompt shortcut located in the Start menu or on the Apps screen. Another way is to run the cmd Run command. The basic command level might look like the following:

C:\Windows\system32\>cmd.exe and <enter>

This results in the following:

C:\>

The OS is now ready for a command.

The Command Prompt can also be accessed from its original location:

C:\Windows\system32\cmd.exe.

Some versions of Windows (Windows 8.1 and up) also provide a Power User Menu, which can be used to access Command Prompt. Also known as Windows Tools Menu and Power User Task Menu, the Power User Menu includes several shortcuts to simplify OS management, configuration and troubleshooting. Two such shortcuts are Command Prompt and Command Prompt (Admin). These shortcuts can be changed to Windows PowerShell and Windows PowerShell (Admin) in Windows 8.1 and Windows 10, respectively.

How to use Command Prompt in Windows

Many Windows users regularly use its GUI to perform certain tasks. However, it is helpful to know how to execute system functions in the Command Prompt window. For example, basic functions such as changing a directory or examining the system disk are easy to execute at the command level.

To use the tool, a user enters a valid command plus any optional parameters. The syntax of the wording entered on the command-line is important. The system will not execute a function if a letter or number is in the wrong sequence.

Even a small spelling mistake or extra space can be catastrophic. For instance, using del L instead of dir will tell the Command Prompt that files are to be deleted in a certain location instead of simply showing the files at that location.

Each command given to Command Prompt launches a batch file that initiates a specific function.

i. The change directory function looks like this:

C:\>dir and <enter>

This presents a list of available directories linked to the root directory -- for example, the C drive -- in the system.

ii. To change to a different directory, the following is performed, using the example of changing to a directory called applications:

C:\>cd applications\ and <enter>

This changes the directory to:

C:\applications\>

Now the system needs a command to execute something in the applications directory.

iii. To check on the status of the elements associated with a specific directory; the user enters the following at the command prompt:

C:\applications\>chkdsk and <enter>

The OS executes the chkdsk utility for the applications directory and presents a summary of the components in that directory, such as the number of files and subdirectories, and number of bytes in use and the number available.

iv. Here's the command to delete all GIF files from the Downloads folder:

del * .gif

A command prompt screenshot.
Output using command prompt and the 'net user' command to see if a backup admin account exists on end-user devices.

Examples of commands in Windows Command Prompt

There are some variations in commands for Command Prompt across Windows OS. The most used commands in Command Prompt include the following:

  • dir to display the files and subfolders in a folder.
  • cls to clear the command prompt screen.
  • copy to create a copy of something such as a file.
  • del to delete a file.
  • format to format a disk according to specific requirements.
  • ipconfig to list the network data such as IP address and subnet mask.
  • ping to send a packet to an IP address and display the information returned from the other device.
  • sfc to detect and fix corrupt system files.
  • shutdown to shut down, restart, log off or hibernate a system.
  • chkdsk to check a specific disk and repair or recover data as needed.
  • attrib to display or change a file's (or folder's) attributes.
  • help to ask for more information about another command, such as its syntax, options and usage.

Some of these commands might not be available in older versions of Windows.

PowerShell is an advanced version of the Windows command prompt. It provides additional functionality to the command prompt.

Visual comparison of PowerShell and a command prompt.
Examples of how PowerShell compares to a command prompt.

How to access Command Prompt in Mac

Command Prompt is a Windows utility. However, Mac systems include a similar utility called Terminal. Here's how to access it:

In the Finder, go to Applications > Utilities and double-click Terminal.

Another option is to click the Launchpad icon in the Dock, type Terminal in the search field and click Terminal.

Once Terminal is open, users can enter commands and execute them by pressing Return. Common Terminal commands include the following:

  • ipconfig
  • ping
  • telnet
  • tracert

To exit Terminal, either click Terminal > Quit Terminal or type exit in the Terminal text window.

Check out command-line interface commands every IT pro should know. Also, the Windows command prompt and PowerShell can do similar things. Learn from examples of when to use command prompt and PowerShell.

This was last updated in October 2024

Continue Reading About What is a command prompt?

Networking
Security
CIO
HRSoftware
Customer Experience
Close