How to use the Windows command line (DOS)

How to use the Windows command line (DOS)

Windows command line (DOS)
This page covers the basics of navigate and using the Microsoft Windows control line. On this page, you learn how to move around in the command channel, find files, fudge files, and other important commands. Keep in thinker that there are over 100 different commands used in MS-DOS and the Windows command telephone line. If you are concerned in learning about the dominate line in more detail, see our DOS and control prompt overview, which gives a description and case for every command .

Get into the Windows command line

Open a Windows command line window by following the steps below. If you need extra data or alternative methods for all versions of Windows, visualize : How to get to an ms-dos prompt or Windows command line .

  1. Click Start.
  2. In the Search or Run line, type cmd (short for command), and press Enter.

Understanding the prompt

After following the steps above, the Windows command line should be shown ( alike to the model below ). Windows often starts you at your exploiter directory. In the example below, the drug user is Mrhope. then, C : \Users\Mrhope > is our immediate. This motivate shows that we ‘re in the C : drive ( nonpayment hard drive letter ) and presently in the Mrhope directory, a subdirectory of the Users directory .
Windows command line

Key tips

  • MS-DOS and the Windows command line are not case sensitive.
  • The files and directories shown in Windows are also found in the command line.
  • When working with a file or directory with a space, surround it in quotes. For example, the directory My Documents would be “My Documents” when typed.
  • File names can have a long file name of 255 characters and a three character file extension.
  • When a file or directory is deleted in the command line, it is not moved into the Recycle Bin.
  • If you need help with any of command, type /? after the command. For example, dir /? would give the options available for the dir command.

Listing the files

Let ‘s learn your beginning command. Type dir at the prompt to list files in the current directory. You should get an output exchangeable to the case image below. Without using any dir options, this is how dir end product appears. As shown, you are given lots of useful information including the initiation date and clock time, directories (

), and the name of the directory or file. In the example below, there are 0 files listed and 14 directories, indicated by the status message at the bottom of the output.
Listing files in the Windows command line
Every command in the command course has options, which are extra switches and commands that can be added after the command. For example, with the dir command, you can type dir /p to list the files and directories in the current directory one page at a time. This substitution is useful to see all the files and directories in a directory with dozens or hundreds of files. Each of the command options and switches is listed in our DOS command overview. We offer guides for individual commands, ampere well. For exemplar, if you want to see all the options for the dir command, refer to our dir command overview for a complete option listing .
The dir command can besides be used to search for particular files and directories using wildcards. For exemplar, to list files or directories that begin with the letter “ A ” you could type dir a* to list lone the AppData directory, in this above exemplar. See the wildcard definition for early examples and help with using wildcards .

Moving into a directory

now that we ‘ve seen a number of directories ( shown below ) in the current directory, move into one of those directories. To move into a directory, we use the cadmium command, so to move into the Desktop character cd desktop and crush Enter. Once you ‘ve moved into a new directory, the prompt changes. so, in our case, the prompt is now C:\Users\Mrhope\Desktop>. You can see what files are found in this directory by typing the dir command again .
Windows command line listing Desktop files

Understand the files

In the Desktop directory, as shown in the above case, there are 23 files and 7 directories, representing different file types. In Windows, you are familiar with files having icons that help represent the file type. In the command agate line, the like thing is accomplished by the file extensions. For example, “ forum posts.txt ” is a text file because it has a .txt file extension. Time.mp3 is an MP3 music file and minecraft.exe is an feasible file .
Most users are merely concern with feasible files, which a mentioned above, are files ending with .exe, .com, and .bat. When the file name is typed in the instruction credit line, the program runs, which is the lapp as double-clicking a file in Windows. For exemplar, if we wanted to run minecraft.exe, typing minecraft at the prompt runs that program .
Keep in thinker that if the feasible file you are trying to run is not in the current directory, you get an error. Unless you have set a path for the directory with the feasible 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 wrinkle use the edit command. For example, if we wanted to look at the log file hijackthis.log, we would type edit hijackthis.log at the prompt. For 64-bit versions of Windows that do not support this command, you can use the begin control ( for example, type start notepad hijackthis.log ) to open the file in Notepad. Additional information about opening and editing a file from the command line is available on the page linked below .

Moving back a directory

You learned earlier the cadmium command can move into a directory. This command besides allows you to go back a directory by typing cd.. at the prompt. When this command is typed, you ‘ll be moved out of the Desktop directory and back into the exploiter directory. To move back to the beginning directory type cd\ to get to the C : \ > prompt. If you know the name of the directory you want to move into, you can besides type cd\ and the directory name. For example, to move into C : \Windows >, type cd\windows at the prompt .

Creating a directory

now with your basic understand of navigating the command line, let ‘s start creating new directories. To create a directory in the current directory, use the mkdir command. For exemplar, create a directory called “ test ” by typing mkdir test at the motivate. If created successfully, you are returned to the prompt with no error message. After the directory is created, move into that directory with the cadmium instruction .

Switching drives

In some circumstances, you may want to copy or list files on another drive. To switch drives in the Windows command trace, type the drive letter of the drive followed by a colon. For exercise, if your cd-rom drive is the D drive, you would type d: and crush Enter. If the drive exists, the prompt changes to that drive letter. If the drive does not exist or is not accessible ( for example, no phonograph record in CD-ROM force ), you get an error .

Creating a new file

You can create a newfangled file from the command agate line using the edit command, copy con command, or using the starting signal command to open a file .

Creating a new batch file

In the new test directory, let ‘s create your first file. In most circumstances, you never need to create any file at the command line, but it is still good to understand how files are created. In this case, we are creating a batch file. A batch file is a file that ends with .bat and helps automate frequently used commands in the command argumentation. We are calling this batch file example, so type edit example.bat at the motivate. As mentioned in the document on creating a file, if the edit instruction does not work, use the start command to open the batch file in Notepad. To perform this action, you type start notepad example.bat into the motivate.

Both of the commands above open a new lacuna example.bat window. In the file, type the three lines below, which clear the screen with the chlorine command and run the dir dominate .

@echo off

After these three lines are typed into the file, save, and exit the charge. If you are in the edit dominate, chatter File ( or press Alt+F ) and then Save. After the file is saved and you are back at the command immediate, typing dir displays the “ example.bat ” file in the test directory .
now, run the batch file to get a better understand of what a batch charge does. To run the batch file, type example at the prompt, which executes the batch file, clears the screen, and runs the dir command .

Moving and copying a file

now that we ‘ve created a file, let ‘s move it into an interchange directory. To help make things easier, create another directory for the files. so, character mkdir dir2 to create a newfangled directory in the screen directory called dir2. After the new directory is created, use the move command to move the example.bat file into that directory. To do this, type move example.bat dir2 at the immediate. If done successfully, you get a message indicating the file was moved. You could besides substitute the move command for the replicate command to copy the charge alternatively of moving it .

Rename a file

After the file is moved into the dir2 directory, move into that directory with the compact disk control to rename the file. In the dir2 directory, use the rename command to rename the exemplar file into an alternate name. Type rename example.bat first.bat at the prompt to rename the file to “ first.bat. ” immediately, when using the dir dominate, you see “ first.bat ” as the only file .
When renaming any file, make sure the file has the lapp file elongation. If you were to rename the .bat file to a .txt file, it is nobelium longer an feasible charge only a text file. besides, keep in mind that renaming the file to a different file extension does not convert the file. For case, if you renamed the file as an .MP3, it may look like an MP3 in Windows, but it ‘s not going to play music .

Deleting a file

now that we ‘ve had our fun with our raw file, delete the file with the del instruction. Type del first.bat to delete the first.bat file. If successful, you are returned to the prompt with no errors, and the dir command shows no files in the stream directory .
When deleting files, you can besides use wildcards to delete multiple files at once. For exemplar, if the directory contained several .GIF image files you could type del *.gif to delete all files ending with the .gif file extension .

Renaming a directory

Go back one directory to get back to the trial directory using the cd.. command mentioned earlier. now, rename our dir2 directory to something else using the same rename command we used earlier. At the prompt, type rename dir2 hope to rename the directory to “ hope. ” After this command is completed, type dir and you see one directory called “ hope. ”

Removing a directory

While inactive in the test directory, remove the hope directory using the rmdir command. At the prompt, type rmdir hope to remove the hope directory .
If the directory you are trying to remove contains any files or directories, you ‘ll receive an error. To prevent this erroneousness, use the /s choice. For example, if the hope directory still had the first.bat file, you would need to type rmdir /s hope at the immediate .

Running a program

Any feasible file can run from the command line by typing the name of the file. For exemplar, if you listed files using the dir command and see a file named “ myfile.exe, ” typing “ myfile ” at the command credit line runs that program.

How to list available commands

After getting a good sympathize of using the command argumentation from the steps shown above, you can move on to other available commands by typing help at the command line. Typing “ aid ” displays a tilt of available commands with a brief description of each control .

Closing or exiting the command line window

After you are done with the Windows command line, you can type exit to close the window .

In conclusion

now you have a good understand of how to navigate the command line, create directories and files, rename directories and files, and erase. As mentioned earlier, there are hundreds of other commands you can use at the dominate telephone line. If you want to expand your cognition further, we recommend looking at the options available for each command above and reviewing our commands overview page. You can besides use our research to find any command by the name of the command or by the military action it performs .

beginning :
Category : Tech

About admin

I am the owner of the website, my purpose is to bring all the most useful information to users.

Check Also


Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.