banner



How To Use Dos Commands In Windows 10

How to use the Windows command line (DOS)

Updated: 12/31/2020 by Estimator Hope

Windows command line (DOS)

This folio covers the nuts of navigating and using the Microsoft Windows control line. On this page, you learn how to movement around in the command line, notice files, manipulate files, and other important commands. Keep in mind that at that place are over 100 different commands used in MS-DOS and the Windows command line. If you are interested in learning about the command line in more detail, run across our DOS and command prompt overview, which gives a clarification and example for every control.

Get into the Windows command line

Open a Windows control line window past following the steps below. If you need boosted information or alternative methods for all versions of Windows, come across: How to get to an MS-DOS prompt or Windows command line.

  1. Click Starting time.
  2. In the Search or Run line, blazon cmd (brusque for command), and press Enter.

Understanding the prompt

Afterward post-obit the steps above, the Windows command line should be shown (similar to the case below). Windows often starts you at your user directory. In the instance below, the user is Mrhope. So, C:\Users\Mrhope> is our prompt. This prompt shows that we're in the C: drive (default difficult bulldoze letter) and currently in the Mrhope directory, a subdirectory of the Users directory.

Windows command line

Primal tips

  • MS-DOS and the Windows command line are not case sensitive.
  • The files and directories shown in Windows are also constitute in the control line.
  • When working with a file or directory with a space, surround information technology 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 3 character file extension.
  • When a file or directory is deleted in the control line, information technology is non moved into the Recycle Bin.
  • If you need aid with any of command, type /? after the command. For example, dir /? would give the options available for the dir control.

Listing the files

Permit's learn your first command. Type dir at the prompt to list files in the current directory. Yous should get an output similar to the example image below. Without using any dir options, this is how dir output appears. Equally shown, you are given lots of useful information including the creation date and time, directories (<DIR>), and the proper name of the directory or file. In the example below, there are 0 files listed and 14 directories, indicated past the status message at the bottom of the output.

Listing files in the Windows command line

Every command in the command line has options, which are additional switches and commands that tin can exist added after the command. For example, with the dir command, you can type dir /p to listing the files and directories in the current directory ane page at a time. This switch 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 control overview. We offer guides for individual commands, equally well. For example, if you desire to meet all the options for the dir command, refer to our dir control overview for a consummate option listing.

The dir control can also be used to search for specific files and directories using wildcards. For example, to listing files or directories that brainstorm with the letter "A" you could type dir a* to list only the AppData directory, in this in a higher place example. Come across the wildcard definition for other examples and assistance with using wildcards.

  • How to list files in a directory or folder on the estimator.

Moving into a directory

Now that we've seen a list of directories (shown beneath) in the electric current directory, motility into one of those directories. To motility into a directory, we use the cd command, so to movement into the Desktop type cd desktop and printing Enter. One time you've moved into a new directory, the prompt changes. And so, in our example, the prompt is now C:\Users\Mrhope\Desktop>. You can see what files are plant in this directory by typing the dir control once more.

Windows command line listing Desktop files

  • How to change a directory or open a binder.

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 control line, the same matter is achieved by the file extensions. For instance, "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 executable file.

  • List of file extensions and additional help with file extensions.

Most users are but concerned with executable files, which as mentioned above, are files ending with .exe, .com, and .bat. When the file name is typed in the control line, the program runs, which is the same as double-clicking a file in Windows. For instance, if we wanted to run minecraft.exe, typing minecraft at the prompt runs that program.

Notation

Go on in mind that if the executable file you are trying to run is not in the current directory, yous get an error. Unless you have gear up a path for the directory with 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 instance, if nosotros wanted to await at the log file hijackthis.log, nosotros would type edit hijackthis.log at the prompt. For 64-bit versions of Windows that do not support this command, yous can use the outset command (e.k., blazon start notepad hijackthis.log) to open up the file in Notepad. Additional data about opening and editing a file from the command line is available on the folio linked below.

  • How to open up, view, and edit the contents of a file on a reckoner.

Moving back a directory

Yous learned earlier the cd command can move into a directory. This command too allows you lot to become dorsum a directory by typing cd.. at the prompt. When this command is typed, yous'll be moved out of the Desktop directory and back into the user directory. To move back to the root directory blazon cd\ to go to the C:\> prompt. If you know the name of the directory you want to motility into, you can besides type cd\ and the directory name. For example, to move into C:\Windows>, type cd\windows at the prompt.

  • How to alter a directory or open a folder.

Creating a directory

Now with your basic understanding of navigating the command line, permit'due south start creating new directories. To create a directory in the current directory, utilise the mkdir command. For case, create a directory called "test" by typing mkdir test at the prompt. If created successfully, you are returned to the prompt with no fault message. Later the directory is created, move into that directory with the cd command.

  • How to create a directory or folder.

Switching drives

In some circumstances, y'all may want to copy or list files on some other drive. To switch drives in the Windows control line, type the drive letter of the drive followed by a colon. For instance, if your CD-ROM drive is the D bulldoze, you would type d: and printing Enter. If the bulldoze exists, the prompt changes to that drive letter of the alphabet. If the bulldoze does not exist or is non attainable (e.g., no disc in CD-ROM drive), you get an error.

  • How do you re-create files from one drive to another drive?
  • How to change drives in MS-DOS and Windows command line.

Creating a new file

Yous can create a new file from the command line using the edit command, re-create con command, or using the kickoff control to open up a file.

  • How to create a file in MS-DOS and the Windows command line.

Creating a new batch file

In the new test directory, let's create your kickoff file. In most circumstances, you lot never need to create any file at the command line, just it is even so 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 helps automate often used commands in the command line. We are calling this batch file example, and then type edit case.bat at the prompt. As mentioned in the document on creating a file, if the edit control does not work, use the start control to open the batch file in Notepad. To perform this activity, you type start notepad example.bat into the prompt.

Both of the commands higher up open a new blank example.bat window. In the file, type the three lines below, which clear the screen with the cls command and run the dir command.

@repeat off cls dir

Later on these iii lines are typed into the file, save, and exit the file. If you are in the edit command, click File (or printing Alt+F) and and so Salve. Afterward the file is saved and you are back at the command prompt, typing dir displays the "example.bat" file in the exam directory.

Now, run the batch file to go a better understanding of what a batch file does. To run the batch file, type example at the prompt, which executes the batch file, clears the screen, and runs the dir command.

  • Total data and additional examples on batch files.

Moving and copying a file

Now that we've created a file, permit's movement it into an alternate directory. To help make things easier, create another directory for the files. So, type mkdir dir2 to create a new directory in the test directory called dir2. After the new directory is created, utilise the move command to motility the example.bat file into that directory. To practise this, type move example.bat dir2 at the prompt. If done successfully, you lot go a message indicating the file was moved. You could likewise substitute the motility control for the copy control to copy the file instead of moving it.

  • How to motion files and folders on the estimator.
  • How to copy files.

Rename a file

Later the file is moved into the dir2 directory, move into that directory with the cd command to rename the file. In the dir2 directory, use the rename control to rename the example file into an alternate proper noun. Blazon rename case.bat offset.bat at the prompt to rename the file to "first.bat." Now, when using the dir control, y'all see "first.bat" as the only file.

Tip

When renaming any file, make sure the file has the aforementioned file extension. If you were to rename the .bat file to a .txt file, information technology is no longer an executable file only a text file. Likewise, go along in mind that renaming the file to a different file extension does not catechumen the file. For example, if you lot renamed the file as an .MP3, information technology may wait similar an MP3 in Windows, only information technology's not going to play music.

  • How to change or rename a file, folder, or directory.

Deleting a file

At present that nosotros've had our fun with our new file, delete the file with the del command. Blazon 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 current directory.

Tip

When deleting files, you can also use wildcards to delete multiple files at once. For example, if the directory contained several .GIF image files you lot could type del *.gif to delete all files ending with the .gif file extension.

  • How to delete a file, directory, or folder.

Renaming a directory

Go back one directory to go back to the test directory using the cd.. command mentioned before. At present, rename our dir2 directory to something else using the same rename control we used earlier. At the prompt, type rename dir2 hope to rename the directory to "promise." Afterward this command is completed, type dir and you see one directory called "hope."

  • How to change or rename a file, folder, or directory.

Removing a directory

While still in the test directory, remove the promise directory using the rmdir control. At the prompt, type rmdir hope to remove the hope directory.

Tip

If the directory you are trying to remove contains any files or directories, you'll receive an mistake. To preclude this mistake, use the /s option. For example, if the hope directory still had the kickoff.bat file, yous would need to type rmdir /s hope at the prompt.

  • How to delete a file, directory, or folder.

Running a programme

Whatsoever executable file can run from the command line past typing the proper name of the file. For case, if you listed files using the dir control and see a file named "myfile.exe," typing "myfile" at the control line runs that programme.

  • How practise I run a file from MS-DOS?

How to list available commands

After getting a good agreement of using the command line from the steps shown higher up, yous tin movement on to other available commands past typing help at the control line. Typing "help" displays a listing of available commands with a brief clarification of each control.

Endmost or exiting the command line window

After y'all are done with the Windows control line, you tin can type exit to close the window.

In conclusion

Now you take a practiced understanding of how to navigate the command line, create directories and files, rename directories and files, and delete. As mentioned earlier, in that location are hundreds of other commands you can use at the command line. If you want to aggrandize your knowledge further, we recommend looking at the options available for each control above and reviewing our commands overview page. Yous can besides utilize our search to observe whatsoever command by the name of the command or by the action it performs.

Source: https://www.computerhope.com/issues/chusedos.htm

Posted by: farrellfroma1981.blogspot.com

0 Response to "How To Use Dos Commands In Windows 10"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel