C M D

C M D

COMMANDS ( Every Programmer should Know)

What is C M D ?

Command Prompt, also known as the Windows Command Processor or cmd prompt, is an application available in most Windows operating systems. It allows users to execute commands and automate tasks through scripts and batch files. The command prompt can be used to perform advanced administrative functions and troubleshoot or solve certain types of Windows issues. It is also known as the command shell or cmd.exe.

It's a powerful tool for advanced users and IT professionals to automate tasks and troubleshoot issues. Command Prompt can also be used in conjunction with other Windows tools, such as Windows PowerShell, to further increase its capabilities./

How to Access Command Prompt

There are a few ways to access the Command Prompt in Windows:

  1. Press the Windows key + R on your keyboard to open the Run dialog box. Type "cmd" and press Enter. This will open the Command Prompt window.

     C:\Windows\system32\cmd.exe
    
  2. Click the Start button, scroll down the list of apps and locate the Windows System folder. Click on the Command Prompt or Windows PowerShell app to open it.

  3. Press the Windows key + X on your keyboard and then select Command Prompt (Admin) from the menu that appears. This will open the Command Prompt with administrator privileges.

  4. You can also use the search function to find Command Prompt. Press the Windows key + S on your keyboard, then type "cmd" in the search box and press Enter.

  5. If you are using an older version of Windows, you may need to navigate to the Start menu, All Programs, Accessories, and then Command Prompt.

Once you have accessed the Command Prompt, you can begin entering commands. Remember that some commands require administrator privileges, so you may need to open the Command Prompt as an administrator to execute those commands.

The List of Command Prompt (CMD) Commands

1.dir - The dir command is used to display a list of files and folders in the current directory. It can also be used to display information about the files such as their size and creation date.

/> dir

2.cd - The cd command changes the current directory. When executed without any arguments, it changes the current directory to the user's home directory. When executed with a directory name, it changes the current directory to that directory. For example, cd Documents would change the current directory to the Documents folder on the user's computer.

/> cd [directory name]

3.copy - The copy command is used to copy files from one location to another. It takes two arguments, the source file and the destination file or folder. For example, copy file1.txt newfolder would copy file1.txt to the newfolder directory.

/> copy [source file] [destination]

4.xcopy - The xcopy command is similar to the copy command but it also copies subdirectories and their files. It takes three arguments: the source directory, the destination directory and options. For example, xcopy c:\oldfolder c:\newfolder /s /e would copy all files and subdirectories from the oldfolder to the newfolder directory and it would copy also empty directories.

/> xcopy [source file] [destination] [option]
  1. del - The del command is used to delete files. It takes one argument, the name of the file to be deleted. For example, del file1.txt would delete the file named file1.txt.
/> del [file name ]

  1. rmdir - The rmdir command is used to delete directories. It takes one argument, the name of the directory to be deleted. For example, rmdir newfolder would delete the directory named newfolder.

     /> rmdir [Directory name]
    
  2. type - The type command is used to display the contents of a text file in the command prompt window. It takes one argument, the name of the file to be displayed. For example, type file1.txt would display the contents of file1.txt in the command prompt window.

     /> type [file name]
    
  3. ren - The ren command is used to rename files. It takes two arguments, the current name of the file and the new name for the file. For example, ren file1.txt newfile.txt would rename file1.txt to newfile.txt.

/> ren [Old folder] [new FolderName]
  1. cls - The cls command is used to clear the command prompt window. It takes no arguments.

     />cls
    
  2. echo - The echo command is used to display a message in the command prompt window or turn command echoing on or off. If executed without any arguments, it turns command echoing on. When executed with the argument off, it turns command echoing off. For example, echo Hello, World! would display the message "Hello, World!" in the command prompt window.

     /> echo [message]
    

    It's worth noting that some of the commands have options, which can be added after the command name to modify its behavior. For example, xcopy has options like /s to copy subdirectories, /e to copy empty directories, and /i to assume that the destination is a folder if it doesn't exist.

    Also, these commands must be executed inside the command prompt window.

Did you find this article valuable?

Support Mehar Gupta by becoming a sponsor. Any amount is appreciated!