Tutorials

What is cmd, what does it mean and what is it for?

Table of contents:

Anonim

The CMD (Command Prompt) is something so embedded in the Windows operating system, that it is almost hidden in Windows 10. This does not mean that Microsoft has determined to forget about this tool, but that there are other functions that it wants to distinguish in its system operating, such as the graphical user interface (GUI), voice commands, and natural language processing (NLP).

But despite being a hidden tool, it still maintains the same power that it has always had and is available for use.

Index of contents

What is Command Prompt

Command Prompt is a way to perform advanced actions using text commands.

Commonly preferred by advanced users, it is hidden from novice users to prevent them from executing commands that can modify the system.

The Command Prompt does not look attractive. It is entirely text based, with quite inspiring white text on a black background. In other words, a design that would not win any prize.

The Command Prompt is also known as a Command Prompt or CMD, but is also sometimes called a Command Shell or CMD Command Prompt, and is available on most Windows operating systems.

The CMD can be used to write and execute commands, which can be especially useful for automating tasks using scripts and batch files, as well as for performing advanced administrative functions and troubleshooting many problems in Windows.

Sometimes the Command Prompt is incorrectly referred to as "DOS Command Prompt" or as MS-DOS itself. It is a Windows program that copies many of the CMD capabilities available in MS-DOS, although it is not MS-DOS.

Run CMD as administrator

To open this tool, simply go to the Cortana search engine (in Windows 10) and type "cmd". In the results, click "Command Prompt".

Ideally, you should right-click the "cmd" icon and select "Run as administrator" to ensure that you have the necessary rights to execute the commands you are about to enter.

In Windows 8 / 8.1 and Windows 10, you can use the mouse to move it to the lower left corner of the screen and right click, or press Windows key + X. Finally, in the user task menu Advanced, select Command Prompt (Administrator).

To access the command interpreter in Windows XP, click Start, then Run, type "cmd" and click OK.

The command line (DOS prompt) is displayed as a black window showing the path of the current directory (c: \ Windows \ System32 if you are running as administrator), followed by a check arrow (> sign).

It is important to note that many commands can only be run if Command Prompt is run as administrator.

Another way to enter the Command Prompt is by entering the key combination "Windows + R", which allows you to directly display the Run dialog box, and type "cmd" to open the command line.

There is also an option to enter the CMD from the Task Manager, pressing:

Ctrl + Shift + Esc

And then by selecting File> Run New Task, and entering "cmd" in the dialog box.

How the command line works

The Command Prompt works at a more basic level than Windows, but this does not mean that it is not powerful, far from it. This means that you gain more control over the PC and communicate with it in a more direct way.

Apart from the common commands (dir, cd, copy, del), more advanced ones can be used to access parts of the operating system that are not available in the graphical user interface.

This application can be used to perform a wide variety of functions, and often using it is faster or even the only way to access certain information or functions.

In addition to the commands mentioned above (which show listings of file directories, enter directories, copy files and delete them), there are other useful commands such as ipconfig (which shows the IP address of a computer), tracert (which shows information about each It passes between the computer and a destination host somewhere else on the internet (such as a website) and the System File Checker (sfc), which finds the damaged or lost files and automatically replaces them using cached copies saved by Windows.

To use Command Prompt, you must enter a valid command along with any optional parameters. Command Prompt executes the command as entered and performs any task or function that it is designed to perform in Windows.

There are a large number of commands in the CMD, although their availability will vary from one operating system to another.

Commands must be entered exactly at the Command Prompt. Incorrect syntax or misspelling could cause the command to fail or worsen, you could run the wrong command, or run the appropriate command, but incorrectly.

Windows Powershell is the successor

Command Prompt has been around forever, but with Windows 10, Microsoft is trying to make PowerShell the main command line of the operating system.

This offers a very rich set of commands (called cmdlets) that are more integrated with Windows and most Microsoft products. These cmdlets are functions that exist within DLLs compiled into a system. Its main purpose is not only to replace Command Prompt, but also batch files and VB scripts.

Command Prompt Availability

Command Prompt is enabled on all Windows NT-based operating systems, including Windows 10, Windows 8, Windows 7, Windows Vista, Windows 2000 and Windows Server 2012/2008/2003 and Windows XP.

Windows PowerShell, a more advanced command line interpreter available in the latest versions of Windows, complements in a number of ways the execution of commands available at the Command Prompt. Windows PowerShell may replace CMD in a future release.

How to use CMD in Windows 10

With these commands you will learn to move around the CMD, search for files, manipulate them and execute different important commands. Please note that there are over 100 different commands that have been used in MS-DOS and the Windows command line.

Access the Command Prompt

Open a CMD window by following the steps below.

  • Simultaneously press the Win + R keys in Windows 10. Choose Command Prompt (administrator).

Understanding CMD

After following the steps above, the Windows command line will be displayed. Windows normally opens this window in the user directory.

In the following example, the user is Lucas, so our prompt is C: \ User \ Lucas>. This notice tells us that we are on the C: drive (the default letter of the hard drive) and currently in the Lucas directory, which is a subdirectory of the Users directory.

To take into account:

  • MS-DOS and Windows CMD are not case sensitive. Files and directories displayed in Windows are also found on the command line. When working with a file or directory with a space, surround it with quotation marks. For example, the My Documents directory would be "My Documents" when typed on the command line. File names can be 255 characters long and a file extension 3 characters long. When a file or directory is deleted on the command line, it does not move to the Recycle Bin. If you need help with any command, type /? after the command. For example, "dir /?" would give the options available for the "dir" command.

List of files

Type "dir" into the CMD to list files in the current directory. A list will appear with all the files in the directory where you are.

As you can see, the list includes a lot of useful information including the creation date and time, directories (

), and the name of the directory or file.

In the example below, there are 3 files listed and 15 directories as indicated in the state located at the bottom of the window.

All Command Prompt commands have options, which are switches and additional commands that can be added after the command.

For example, with the command "dir" you can type "dir / p" to list the files and directories in the current directory on one page at a time. This switch is useful for viewing all the files and directories in a directory that has dozens or hundreds of files.

The "dir" command can also be used to search for specific files and directories using wildcards. For example, if you only want to list files or directories that start with the letter "M", you can type "dir m *".

How to enter a directory

To move to another directory we must use the command "cd", so to move to the Windows directory we type "cd windows" and press Enter. Once you have moved to a new directory, the prompt should change, so in our example, the prompt is now C: \ Windows>. Now, in this directory, you will be able to see what files are here by typing the command "dir" again.

Understanding the CMD files

In this Windows directory there are 22 files and 73 directories, representing different types of files. In the Windows interface this is the same, only it is represented in a more graphic way, with icons that help to identify the type of file.

On the command line, the same is done with file extensions. For example, "contacts.txt" is a text file because it has the txt extension. Time.mp3 is an MP3 music file and minecraft.exe is an executable file.

Most users will only be interested in executable files, which as mentioned above is a file that ends with.exe and they are also files that end with.com and.bat.

When the name of these files is written on the command line, the program runs, which is the same as double-clicking on a file from the Windows interface. For example, if we want to run minecraft.exe by typing "minecraft" at the prompt, we will run that program.

Please note that if the executable file you are trying to run is not in the current directory, you will get an error. Unless you have set a path to the directory that contains the executable file, which is how the command line finds external commands.

If you want to view the contents of a file, most versions of the command line use the "edit" command.

For example, if we wanted to see the log file hijackthis.log we would write "edit hijackthis.log" at the prompt. For 64-bit versions of Windows that do not support this command, you can use the "start" command, for example, type "start notepad file.txt" to open the file in Notepad.

Go back a directory

Before we have seen that with the command "cd" we could move to a directory. Well, this command also allows you to go back a directory by typing "cd.." at the prompt. When this command is written, the user moves from the directory where it is located to a previous directory according to the system directory tree.

If you want to return to the root directory, type "cd \" from where you are to go to C: \>.

If you know the name of the directory you want to move into, you can also type cd \ and the name of the directory. For example, to move to C: \ Windows> type cd \ windows at the prompt.

Create a directory

Now we are ready to start creating new directories. To create a directory in the current directory we are going to use the command "mkdir".

For example, create a directory called "test" by typing "mkdir test" at the prompt. If it was created correctly, you will be in the command query without an error message. After creating the directory, you can enter it using the "cd" command.

Exchanging units

In some circumstances, you may want to copy or list files on another drive. To change drives on the Windows command line, type the drive letter followed by a colon.

For example, if the DVD drive is drive D, type "d:" and hit the Enter key. If the drive exists, the indicator will change to that drive letter.

How to create a file in the CMD

You can create a new file from the command line using the "edit" command or the "copy con" command, followed by the file name. Example:

Create batch or batch files

In a new test directory you will create your first file. In most circumstances, you don't need to create any files on the command line, but it's still good to understand how files are created.

In this example, we are creating a batch file. A batch file is a file that ends with.bat and is a file that can help automate frequently used commands on the command line. We are calling this batch file "test", so type "edit test.bat" or "copy with test.bat" at the prompt.

If the "edit" command does not work with your version of Windows, use the "copy with" command.

Another option is to create a new file with Notepad. For this, you would have to write the following:

start notepad test.txt

The above command opens a new blank window in test.bat. In the file, type the following three lines, which clear the screen with the cls command and then run the dir command.

@echo off cls dir

After these three written lines, save and exit the editor. After saving the file and returning to the command line, typing "dir" will see the file test.bat in the directory.

Now run the batch file to get a better understanding of what this file type does. To run this newly created file, type "test". What this file will do is delete the screen and list the files in the directory.

Move and copy a file

To move a file, you must use the command “move”. In this example, we move the test.txt file to the ProfessionalReview directory.

move test.txt professionalreview

This can also be done by copying this file to another directory.

Rename a file

For this action the command "rename" is used. If you want to rename the test.txt file, you should do the following:

rename test.txt test2.txt

Thus, the file is now called test2.txt

When you rename a file, make sure it has the same extension. If you were to rename the.bat file to a.txt file, it will no longer be an executable file, but just a text file. Also, note that renaming the file to a different extension does not convert to the new file extension. For example, if you are going to put the mp3 extension to a file, in Windows it will seem to be an mp3 music file, but it will not play any sound.

Delete a file

To delete a file from the Command Prompt we use the command "del".

del test.txt

If all went well, you will return to the command line without error, and the "dir" command will no longer display that file.

Also, when deleting files, you can also use wildcards to delete multiple files at once. For example, if the directory contains multiple JPG image files, you can type:

del *.jpg

This will delete all files that end with the JPG file extension.

Rename a directory

For this the same command is used as for renaming a file, thus leaving the syntax:

rename windows office

This changes the name of the Windows directory to Office.

Delete a directory

To delete a directory from the Command Prompt we use the command "rmdir".

rmdir windows

If the directory you are trying to delete contains files or directories, you will receive an error. To avoid this error use the / s option. This removes all content from this directory.

rmdir / s windows

Run a program

Any file that is an executable file can be run from the command line by typing the file name. For example, if you have listed files using the dir command and you see a file named "myfile.exe" by typing "myfile" on the command line, that program is run.

How to list available commands

After gaining a good understanding of using the command line from the steps shown above, you can move on to other available commands by typing help on the command line.

Type "help" to see a list of available commands with a brief description of each one.

Close or exit the command line window

Once you're done with the Windows command line, you can type exit to close the window.

Conclusion and final words about CMD

Now you have enough knowledge about the Command Prompt, how it works and its different commands.

We recommend reading about our comparison: Windows 10 Home vs Windows 10 PRO

With this knowledge, you will be able to create directories and files, rename directories and files, delete, copy and much more. As mentioned earlier, there are hundreds of other commands that can be used on the command line.

Tutorials

Editor's choice

Back to top button