Back in the day, using a desktop computer meant typing in a range of commands. You have to realise that roughly two decades ago, there wasn't any Start menu or a taskbar. The friendly graphics user interface as we know it today didn't exist, and a black screen with a blinking cursor was all we had. Things have significantly changed since, though if you want to learn programming, or just want to access certain Windows elements, you will still need to open the command prompt or CMD.
If you've never used command prompt, this guide is aimed at helping you quickly get started and share some of the commands that you should know as Windows user, just in case an emergency arises. These commands can be very helpful to get you out of sticky situations, and into the clear. But first, where do you feed these commands?
It's called command prompt or command line, and if you're on Windows 7 or higher, you should be able to find it from the search bar on the Start menu by typing cmd or command prompt. Alternatively, you can find it here: Start menu > All Programs > Accessories > Command Prompt. Once there, type in any of the below mentioned commands. Do note, further listing options and modifications for each of the below commands can be found on Microsoft's website.
Note that the commands are case insensitive, which means both DIR and dir will work, and you will need to press Enter (Return) to run these commands.
Basic CMD commands
DIR is short for Directory and it shows all the files and directories (or folders) in a particular directory, alongside their size, extension, and free space remaining on disk. The command can be modified with additional parameters, such as DIR /p (shows one page at a time), DIR /q (shows ownership information), DIR /w (displays a wide format), DIR /d (wide format display sorted into columns), DIR /n (long list format with file names on far right), DIR /l (shows unsorted directory names and files in lower case), DIR /b (shows a bare-bones list with no additional information), while DIR /s shows listing of that directory as well as all sub-directories. Enter DIR /? to see a list of all available options - this works with most other commands as well.
CD or CHDIR aka Change Directory is meant to help users change directories. It has several operations. CD \ takes you to the top of the directory tree. CD .. moves you to the immediate parent folder. CD directory-name takes you to that directory. Type just CD to have the name of the current directory printed on screen.
MD or MKDIR aka Make Directory lets you create a directory (folder). To create one, use the following syntax: MD directory-name
CLS will clear your screen. You will want to remember this command when your Command Prompt is filled with a number of commands and their operations.
EDIT file-name will let you modify the contents of the file.
DEL command lets you delete one or more files. Alternatively, for this task you can also use the ERASE command. To delete a file, use DEL file-name
If you only want to delete all files with a specific extension, you can type DEL *.doc and all files with doc extension in the current directory. DEL *.* will delete all the files in the current directory so be really careful with this command, as there's no Recycle Bin with the command line.
RD or RMDIR does the same to a directory what DEL does to a file. You can use it to remove a folder, but the folder needs to be empty. The syntax is pretty simple. Type in RD name-of-folder. If you want to delete a folder that's not empty, you can use RD /S name-of-folder - again, be careful with this command as it will delete a folder and all its contents immediately, with no easy way to bring back your data.
RENAME, same as REN, will let you rename a file or a directory. The syntax for this command is RENAME current-name new-name. For instance, if you want to rename a file called iPhone.txt to iPad.txt, you can do so by typing rename iPhone.txt iPad.txt
MOVE will allow you to move one or more files from one directory to another directory. For instance, if you wanted to move 1.txt placed in the current folder to a folder named Numericals inside the current folder, type MOVE 1.txt Numericals
If you tried renaming a directory (folder) with the RENAME command mentioned above, you will realise that doesn't work. This is where Move can help, as it can also be used to rename directories. Simply type MOVE current-name new-name , where current name is name of a directory in the current folder.
COPY command will allow you to copy one or more files from one location to another location. The command is quite powerful, and lets users combine files of the same type. Let's take a look at various examples of COPY:
COPY file-name name-of-folder will copy the file named file-name to a(n already existing) folder.
COPY file-name name-of-new-file will create a copy of the file with the new name.
COPY *.doc Word will copy all files that have extension doc to a folder named Word.
XCOPY is meant to files and directories, including subdirectories. Once again, a rather powerful command, it has several abilities. The simplest use case would be copying all files from a drive to another drive. The command for this would be, XCOPY Source-Drive:\ Destination-Drive:\ /e, where the /e switch include all subdirectories even if they are empty. Use /s if you don't want empty subdirectories to be copied. You can use names of folders in source and destination to simply copy all contents of one folder to another.
FORMAT command allows you to erase information from a specified computer drive or prepare it for copying data if you get a new drive. The syntax for using Format command is FORMAT drive:. If you want to convert the specific drive into a particular file system, you can format with the following command: FORMAT drive: /fs:FILE-SYSTEM where file-system can be FAT, FAT32, or NTFS. Note you will lose all data on that drive, so be very, very careful with this command.
FC, file compare command is used to compare two files with each other, you can use File Compare command. The syntax for this command is fc. Suppose there are two files gadgets360_1.txt and gadgets360_2.txt. To compare them, you can type in the following command: FC gadgets360_1.txt gadgets360_2.txt
IPCONFIG gives you a detailed look at your network settings. The command will provide you with information such as IP address, and also tell the type of network connection your computer is using (Wi-Fi or Ethernet) among other details. Type IPCONFIG /ALL to get an overview of all your network settings including what DNS servers you are using. Type IPCONFIG /RENEW to get a fresh IP address from your DHCP server - this can sometimes help if you are having connectivity issues.
PING is another network related command. If you're unsure whether the website you're trying to visit is down, you can type ping followed by an IP address or a Web address to find out. For instance, ping google.com. If the reply says Destination Net Unreachable, your Internet connection may be down. If this reply contains Host is down or Request timeout, the website may be down. If everything is fine, you should see text similar to - 64 bytes from 22.214.171.124: icmp_seq=0 ttl=56 time=118.355 ms - the exact numbers may vary.
SHUTDOWN cab a useful command if for some reason your shutdown button isn't working on Start menu (could happen because of malware), or you are having a hard time finding the button (new Windows 8 users). You can perform the task going the Command Prompt route. To shutdown a Windows computer, just try SHUTDOWN /S
To restart a computer, SHUTDOWN /R
CHKDSK, a disk check command, it meant to allow you to check if your operating system is able to read your hard drive or any other storage media properly. The syntax for the Check Disk command is similar to CHKDSK C: - replace C with the letter of the drive you want to check. Type CHKDKS /? to see various other options available.