Windows Command Line (doscommand) Tutorial

Source: Internet
Author: User

1. symbol conventions

To facilitate the description of the format, we use some symbol conventions which are common:

C:

Drive letter

Path

Path

Filename

File Name

. Ext

Extension

Filespec

File Identifier

[]

The items in square brackets are optional. You can choose not to enter the content as needed.

{}

Braces indicate that one item is required.

|

A vertical line indicates either of the two sides of the content.

...

Repeated items

2. Internal and External commands
Command lines are divided into internal commands and external commands. Internal commands are loaded into the memory with command.com, while external commands are a separate executable file.

Internal commands are concentrated in the command.com file in the root directory. The computer reads the file into the memory every time it starts. That is to say, these internal commands reside in the memory during computer running, you cannot see these internal commands using the Dir command.

External commands are stored on disks as independent files. They are all files suffixed with "com" and "EXE". They are not resident memory and are only required by computers, will be transferred to the memory.

 

Three Common commands

There are about one hundred doscommands in total. Here we will detail 20 commonly used doscommands.

First, we will introduce the concept of wildcard. * Indicates a string? Only one character
Note that wildcard characters can only be configured with file names or extensions, not all. For example, to search for all files starting with Y, run the following command: Dir y *. *. If you want to find all files with an extension of EXE, you can use dir. EXE .? It only represents one character. For example, if you want to find all files with the second letter "S", you can enter: Dir? S *.*.
1. dir

DIR is the abbreviation of directory, which is used to display files and subdirectories in a directory.

[Function] displays files and subdirectories in a specified disk or directory, includes the volume label of the disk where the files and subdirectories are located, the name of the files and subdirectories, the size of each file, and the date and time when the files and directories were created, and the number of file subdirectories, the total number of bytes occupied, and the total space remaining on the disk.

[Format] dir [C:] [path] [filename] [. Ext] [/o] [/S] [/P] [/W] [/A]

[Note] DIR is one of the most commonly used doscommands. A slash indicates that the following content is a parameter. DoS parameters are commonly used in the following four scenarios:

Parameter

Yi

/P

When the display information is full, the display is paused. Press any key to display the next screen.

/O

Sort display. O can be followed by letters of different meanings

/W

Only the directory name of the file name is displayed, with five file names in each row. That is, Wide Row display

/S

Display All directory files in directories and subdirectories

[Example] display information in the c: \ windows \ Desktop Folder

 

2. md

MD is the abbreviation of make directory.

[Function] create a sub-directory

[Format] MD [C:] path

[Example] using MD to create a directory called purple

3. CD

CD is the abbreviation of Change directory.

[Function] changing or displaying the current directory

[Format] CD [C:] [path]

[Description] Two Types of paths are available: absolute path and relative path. If there is only CD but no parameter, only the current path is displayed. Note: There must be two "Special directories" in the subdirectory, namely "." and "...". One of them indicates the current directory, and the other two indicate the previous directory. From a simple and practical perspective, we can solve all the problems by learning to enter (a directory name under the CD layer) and exit (CD ..) layer by layer. Of course, you can also use the absolute path method.

[Example] Go to the purple directory we just created

4. Rd

Remove directory -- delete a directory

[Function] deletes an empty sub-directory.

[Format] RD [D:] path

[Note] RD is a command used to delete empty sub-directories. Note: You cannot delete a non-empty directory or the current directory.

[Example] Use rd to delete the purple directory

Next we will use the MD, CD, and RD commands.

5. Copy

Copy means copying in English.

[Function] copies one or more files to a specified disk or directory.

[Format] Copy [C:] [path] [filename. Ext] [C:] [path] filename. ext

[Description] The basic usage of the copy file command is: "copy the source file name target file name ". If you only write the target path without writing the target file name, it indicates copying with the same name; otherwise, it is called renaming. Note that do not change the file extension during name-change replication.

[Example] to copy all files in the C: \ purple directory to a floppy disk, run the following command. Note that the current disk is different from the current path:

C: \> copy purple :\

If a file with the same name already exists on the target disk, the following message is displayed: "overwrite xxxx (Yes/No/All)". Then, if you answer y, the current file is overwritten, and N is retained, A will overwrite all subsequent documents without asking questions.

6. DEL

Del is the abbreviation of Delete.

[Function] deletes one or more files from a specified disk or directory.

[Format] del [C:] [path] filename. ext

[Note] This command should be used with caution. Once deleted, it will not be easy to restore. You can also use wildcards to delete a type of files. When *. * is used, a warning will be given for security purposes, and the confirmation party will delete the work. If no message is displayed during the deletion process, the deletion is correct.

Note that this command cannot delete files with read-only, implicit, and system attributes. If the specified file does not exist, the message "file not found" appears; DOS can use the undelete external command to restore objects that are accidentally deleted. It can only delete files and cannot delete directories.

7. Ren

Rename is short for rename.

[Function] changes the name of a file or a group of files in a specified disk or directory.

[Format] Ren [C:] [path] filename1 [. Ext] filename2 [. Ext]

[Note] the renaming operation is only limited to the names of a group of files in a file. It does not change the directory where the files are located. If a wildcard is used, rename a batch of files.

 

8. Type

[Function] command for displaying text files on the screen

[Format] type [C:] [path] filename. ext

[Note] the type command is used to quickly and easily display the content of a text file on the screen. A file with the extension of txt is a text file. If you use this command to display files with an extension of EXE or com, the output result is often a mess of symbols with irregular bells, and sometimes even crashes.

9. Format

[Function] disk formatting

[Format] [C:] [path] format drive: [/S]

[Note] various disks manufactured by the manufacturer can be used to store files in various operating systems. The disk formats of different operating systems are generally different and are not universal. The format command enables a new disk to be recognized by the DOS operating system to store DoS Files.

This command is actually used to plan the disk in the information storage format specified by DOS. When formatting a disk, clear all existing data on the disk, write boot records on the disk, and divide the File Allocation Table and root directory. At the same time, it also finds all bad sectors on the disk and marks them as unavailable. Here, we only list one command parameter:/s. When this parameter is used, the disk is formatted and loaded into the operating system file to convert it into a boot disk. It is equivalent to format and then run the following command: SYS.

10. discopy

Diskcopy.

[Function] copies a disk with the same content as the original disk.

[Format] diskcopy source drive name destination drive name

[Note] its main purpose is to back up data. For example, when our computer is just purchased, it will randomly attach some device driver disks, which may be used in the future. To prevent the disk from being damaged, make sure to back up all of them. In this case, the diskcopy command is quick and convenient.

11. deltree

[Function] deletes a directory tree.

[Format] [C:] [path] deltree [C1:] [path1] [C2:] [path2] […]

[Note] This command eliminates the entire specified directory tree, regardless of whether it is read-only or hidden. Be especially careful when using it. It is a dangerous command.

12. mem

Mem is short for memory

[Function] This command is used to view the memory size of your computer and the memory usage.

[Format] directly type the mem command

13. chkdsk

Chkdsk is short for check disk.

[Function] is used to check the usage of your disk.

[Format] chkdsk disk name

[Note] For example, to check disk A usage, enter chkdsk A: To check disk C usage, enter chkdsk C:. If you directly enter chkdsk, check the usage of the current disk.

14. sys

[Function] Transfers System File commands. Transmit the two implicit dos systems Io. sys and msdos. sys to a specific location on the target disk and copy the command. com file. After completion, the target disk becomes the DOS boot disk.

[Format] [C:] [path] sys [C1:] [path] D2:

[Note] because these files need to be copied to a specific location, the copy command may not be able to start the machine. Through the Sys command, DOS can move the files in a specific location on the target disk and copy the system files to the corresponding location. The C1: path parameter specifies the directory where the system file is located. If this parameter is not specified, the current directory of the current disk is used by default. Therefore, this command is generally performed in the root directory of the source disk.

15. Pass

[Function] sets the directory where dos searches for. com,. EXE, And. BAT files.

[Format] Path = [[drive:] path [;…] Or path

[Description] Only environment variable content is displayed when path is used and no parameter is set. If there is a parameter, reset the PATH variable. When no path environment variable is specified, the user issues a command. Dos first checks whether it is an internal command and then finds whether the main file name in the current directory is an executable file of the command, if none, "Bad command or FILENAME" is displayed ". If the command for the specified path is issued, search for the path in sequence. If the path still cannot be found, the above prompt is displayed.

16. Edit

[Function] the edit command is a simple editing software, which is often used to edit programs and batch files.

17. CLs

[Function] clears the content on the display screen and enables the DOS prompt to go to the upper left corner of the screen.

[Format] CLS

18. Time

[Function] displays and sets the DOS system time.

[Format] time [HH [: Mm [: ss [. CC]

19. Date

[Function] displays and sets the DOS system date.

Date [MM-DD-YY] [format]

20. Ver

[Function] displays the running DOS system version number.

[Format] ver

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.