China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 17:46
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » 20 Ways to Use DOS Commands [Repost] DigestI View 8,545 Replies 16
Original Poster Posted 2003-06-10 00:00 ·  中国 江西 吉安 电信
版主
★★★★
Credits 7,296
Posts 1,628
Joined 2002-10-16 12:00
23-year member
UID 10
Gender Male
Status Offline
20 Ways to Use DOS Commands, from Feiye Net

There are about a hundred DOS commands in total (including text editing, virus scanning/removal, configuration files, batch processing, etc.). Here we will introduce twenty commonly used DOS commands in detail.
First, let’s introduce the concept of wildcards.

Wildcards * and ?

* represents a string

? represents only one character

Note that wildcards can only be used for the filename or the extension, not both together. For example, if we want to find all files starting with the letter y, we can enter the following command: dir y*.*; if we want to find all files with the extension exe, we can use dir .exe. ? represents only one character. For example, if I want to find all files whose second letter is s, I can enter: DIR ?s*.*.

1. dir

dir is the abbreviation of the English word directory

Displays files and subdirectory information in the specified disk and directory, including the volume label of the disk where the files and subdirectories are located, the names of files and subdirectories, the size of each file, the date and time the files and directories were created, as well as the number of files and subdirectories, the total number of bytes occupied, and the total remaining space on the disk.

dir

dir is one of the most commonly used DOS commands. The slash indicates that what follows is a parameter. The four most commonly used DOS parameters are the following:

Parameter
Meaning

/p
When the displayed information fills one screen, pause the display; press any key to display the next screen

/o
Display in sorted order. Different letters can follow o with different meanings

/w
Display only filenames and directory names, five filenames per line. That is, wide display

/s
Display all directories and files in the directory and its subdirectories
/a
Display hidden files


Display the information inside the C:\WINDOWS\Desktop folder


2. md

md is the abbreviation of the English make directory

Create a subdirectory

md path

Use md to create a directory named purple

3. cd

cd is the abbreviation of the English change directory

Change or display the current directory

cd

Two kinds of paths can be used: absolute paths and relative paths. If there is only cd without parameters, it only displays the current path. Note: there must be two “special directories” in a subdirectory, namely “.” and “..”. One dot represents the current directory, and two dots represent the upper-level directory. From a simple and practical point of view, as long as we learn to go down one level at a time (cd directoryname of the next level), and go back out one level at a time (cd..), we can solve all problems. Of course, absolute paths can also be used.

Enter the purple directory we just created

4. rd

remove directory -- delete directory

Delete an empty subdirectory

rd path

rd is a command specifically for deleting empty subdirectories. Note two things: first, it cannot delete a non-empty directory; second, it cannot delete the current directory.

Use rd to delete the directory purple

Next let’s use these three commands: md, cd, and rd.


5. copy

copy means duplicate in English

Copy one file or a group of files to the specified disk or directory

copy filename.ext

The basic usage of the file copy command is: “copy source filename target filename”. If only the target path is written without the target filename, it means copying under the same name; otherwise it is called renaming while copying. Note that when renaming while copying, generally do not change the file extension.

To copy all files in the C:\purple directory to a floppy disk, you can enter the following command. Please note that the current drive and current path are different:

C:\>copy purple A:\

If a file with the same name already exists on the target disk, the following prompt will appear: “Overwrite xxxx(Yes/No/All)”. At this time, reply Y to overwrite the current file, N to keep it, and A to overwrite all subsequent files without asking again.

6. del

del is the abbreviation of the English delete

Delete one file or a group of files in the specified disk and directory

del filename.ext

This command should be used carefully. Once deleted, it is not easy to recover. Wildcards can also be used to delete a class of files. When *.* is used, for safety a warning will be given, and deletion will proceed only after confirmation. If there is no message during the deletion process, it means it has been deleted correctly.

Note that this command cannot delete files with read-only, hidden, or system attributes; if the specified file does not exist, the prompt “File not found” will appear; DOS can recover files deleted by mistake with the external command UNDELETE; it can only delete files, not directories.

7. ren

ren is short for the English rename

Change the name of one file or a group of files in the specified disk and directory

ren filename1 filename2

The renaming operation is limited to the name of a certain file or group of files; it will not change the directory where the file is located. If wildcards are used, a batch of files will be renamed.


8. type

Command to display the contents of a text file on the screen

type filename.ext

The type command is used to quickly and conveniently display the contents of a text file on the screen. Files with the extension TXT are text files. If this command is used to display files with extensions such as EXE or COM, the output is often a bunch of garbled symbols accompanied by irregular beeping sounds, and sometimes it may even cause a hang.

9. format

Disk formatting

format drive:

Various disks manufactured by vendors can be used to store files for various operating systems. The disk formats of different operating systems are generally different and not interchangeable. The format command makes a new disk recognizable by the DOS operating system, so that it can store DOS files.

The process of formatting a disk with this command is actually the process of organizing the disk using the information storage format specified by DOS. When formatting a disk, all existing data on the disk must be erased, a boot record written to the disk, a file allocation table and root directory divided out, and at the same time all bad sectors on the disk must be found and marked as unusable. We list only one command parameter here: /S. When this parameter is used, the disk is formatted and the operating system files are loaded, turning it into a boot disk. This is equivalent to running the next command SYS after format.

10. discopy

diskcopy, translated into Chinese, means disk copy

Copy a disk exactly identical to the original in content

diskcopy source drive name target drive name

Its main use is for backup. For example, when we first buy a computer, some device driver disks are usually included, and these drivers may be needed later. To prevent damage to these disks, you should make a backup set of them all. At that time, using the diskcopy command is relatively quick and convenient.

11. deltree

Delete a directory tree

DELTREE ]

This command wipes out the entire specified directory tree, whether it is read-only, hidden, or not. It should be used with special care. It is a dangerous command.

12. mem

mem is short for memory

This command is used to see how much memory your computer has, as well as memory usage.

Just type the mem command directly

13. chkdsk

chkdsk is short for check disk.

Used to check your disk usage.

chkdsk disk name

For example, to check usage on drive A, enter chkdsk A: ; to check usage on drive C, enter chkdsk C: ; if you directly enter chkdsk, it checks usage on the current disk.

14. sys

System file transfer command. It transfers DOS’s two hidden system files IO.SYS and MSDOS.SYS to a specific location on the target disk, and copies the COMMAND.COM file there as well. When finished, the target disk becomes a DOS boot disk.

SYS d2:

Since these files need to be copied to specific locations, copying with the COPY command may not necessarily boot the machine. With the SYS command, DOS can move files that already occupy specific positions on the target disk, and copy the system files into the corresponding positions. The parameter C1ath is used to indicate the directory where the system files are located. If it is not specified, the default is the current directory of the current disk. Therefore this command should generally be run in the root directory of the source disk.


15. path -- KO says: Thanks to tanglu_sd for pointing this out. The original text had pass. That was a mistake in the original!

Set the directories where DOS looks for .COM, .EXE, and .BAT files

path=path] or path

16. edit

The edit command is a simple editing program. We often use it to edit some programs and batch files.

17. cls

Clear the contents on the display screen, and move the DOS prompt to the upper-left corner of the screen.

cls

18. time

Display and set the DOS system time

time ]]

19. date

Display and set the DOS system date

date

20. ver

Display the version number of the DOS system currently running

ver


Command: Function:
attrib…………set file attributes
ctty …………change control device
defrag…………disk defragmentation
doskey…………call and create DOS macro commands
debug …………program debugging command
emm386…………expanded memory management
fc  …………file comparison
fdisk …………hard disk partitioning
lh/loadhigh …load a program into upper memory
move …………move files, rename directories
more …………paged display
prompt…………set the prompt
set  …………set environment variables
smartdrv………set disk accelerator
setver…………set version
subst …………path substitution
vol  …………display the specified disk volume label
xcopy …………copy directories and files

================
KO says:
I actually saw a DOS article in another place too, I’m touched... reposting it here. Hehe...



ko20010214
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器
Floor 2 Posted 2003-06-10 00:00 ·  中国 湖南 长沙 联通
初级用户
Credits 110
Posts 2
Joined 2003-06-10 00:00
23-year member
UID 4712
Gender Male
Status Offline
Simply too convenient!!!!!!!
Floor 3 Posted 2003-06-10 00:00 ·  中国 湖南 长沙 联通
初级用户
Credits 110
Posts 2
Joined 2003-06-10 00:00
23-year member
UID 4712
Gender Male
Status Offline
Is there more stuff?
Floor 4 Posted 2003-06-10 00:00 ·  中国 山东 滨州 联通
高级用户
★★
Credits 948
Posts 271
Joined 2002-12-13 00:00
23-year member
UID 502
Gender Male
From sd
Status Offline
15. It should be: path
Floor 5 Posted 2003-06-11 00:00 ·  中国 山东 青岛 联通
初级用户
Credits 131
Posts 6
Joined 2003-06-04 00:00
23-year member
UID 3408
Gender Male
Status Offline
Thanks for sharing
Floor 6 Posted 2003-06-13 00:00 ·  中国 湖北 潜江 电信
初级用户
Credits 127
Posts 5
Joined 2003-06-13 00:00
23-year member
UID 4995
Gender Male
Status Offline
Good
Floor 7 Posted 2003-06-14 00:00 ·  中国 辽宁 沈阳 大东区 联通
初级用户
Credits 110
Posts 2
Joined 2003-06-14 00:00
23-year member
UID 5147
Gender Female
Status Offline
Thank you very much!
Floor 8 Posted 2003-06-17 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 105
Posts 1
Joined 2003-06-17 00:00
23-year member
UID 5360
Gender Male
Status Offline
Floor 9 Posted 2003-06-18 00:00 ·  中国 江苏 徐州 电信
初级用户
Credits 115
Posts 3
Joined 2003-06-18 00:00
23-year member
UID 5435
Gender Male
Status Offline
Great
Floor 10 Posted 2003-06-18 00:00 ·  中国 上海 电信
金牌会员
★★★★
小飞侠
Credits 4,590
Posts 1,812
Joined 2003-04-02 00:00
23-year member
UID 1400
Gender Male
From 上海市
Status Offline
Thanks!
Floor 11 Posted 2003-06-19 00:00 ·  中国 辽宁 大连 联通
初级用户
Credits 105
Posts 1
Joined 2003-06-19 00:00
23-year member
UID 5502
Gender Male
Status Offline
Pretty good, I read it.
Floor 12 Posted 2003-06-19 00:00 ·  中国 北京 电信
初级用户
Credits 131
Posts 7
Joined 2003-06-17 00:00
23-year member
UID 5380
Gender Male
Status Offline
When testing copy. It’s best for the .txt file to be larger than 10 bytes
轩辕:
华夏始祖黄帝所铸,被称为诸剑之祖,后传至夏禹,夏禹曾用它劈开龙门。轩辕夏禹剑,是勇气、智慧、仁爱的典范,轩辕夏禹剑是一把开天圣道之剑。
Floor 13 Posted 2003-08-06 00:00 ·  中国 广东 广州 电信
中级用户
Credits 386
Posts 48
Joined 2003-06-29 00:00
23-year member
UID 6106
Gender Male
Status Offline
I had the best DOS lesson, thanks!
Floor 14 Posted 2003-08-06 00:00 ·  中国 浙江 杭州 华数宽带
初级用户
Credits 106
Posts 1
Joined 2003-08-06 00:00
22-year member
UID 8163
Gender Male
Status Offline
Floor 15 Posted 2003-09-18 00:00 ·  中国 上海 东方有线
中级用户
★★
Credits 333
Posts 62
Joined 2003-09-16 00:00
22-year member
UID 9869
Gender Male
Status Offline
Forum Jump: