Sei sulla pagina 1di 7

Commands

A partial list of the most common commands for DOS follows.

Append

Display or sets the search path for data files. DOS will search the specified path(s) if the file is not found in
the current path. This had some creative uses, such as allowing non-CD based games to be run from the
CD, with configuration/save files stored on the HD.

append;
append [d:]path[;][d:]path[...]
append [/X:on|off][/E]

Attrib

Change or view the attributes of one or more files. It defaults to displaying the attributes of all
files in the current directory.
ATTRIB [+R|-R] [+A|-A] [+S|-S] [+H|-H][drive:][path][filename] [/S [/D]]

Options:

• To add an attribute attach a '+' in front of it.


• To remove an attribute attach a '-' in front of it
• Attributes include
o R - Read-only
o A - Archive
o S - System
o H - Hidden
o /D - Process folders as well.
o /S - Process matching files in the current folder and all subfolders.

Note: Everything inside a brace [option] is an optional item. Roughly equivalent to the Unix commands
chattr and lsattr.

cd or chdir

Change current working directory. Displays the current working directory when used without a
path parameter.
cd

displays the current working directory on the current drive.

cd directory

changes the working directory on the current drive to directory.

chdir e:directory

changes the working directory on E: to directory.


cd ..

changes the working directory to the parent directory (up one directory level).

cd \

changes the working directory to the root (top level) directory of the current drive.

Equivalent to the Unix command cd (with a path parameter), or pwd (without a parameter).
cd .. changes to the parent directory.

chkdsk

Verifies a storage volume (hard disk, partition, floppy disk, flash drive, etc) for file system
integrity.

Options:

• /F : Fixes errors on the volume (without /F , chkdsk only detects errors)


• /P : Forces a full verification
• /R : Searches for defective sectors and recovers legible information (applies /F)
• /X : Unmounts the volume before processing if needed. (Note: Unmounting temporarily
invalidates all pointers/handlers to the volume until process is completed)

chkdsk volume letter: [[path]filename] [/F] [/P] [/R] [/X]


Equivalent to the Unix command fsck

cls

Clears the screen.


cls
Equivalent to the Unix clear.

copy

Copies files from one location to another. The destination defaults to the current directory. If
multiple source files are indicated, the destination must be a directory, or an error will result.
Syntax:
copy from [source\filename] to [destination\folder]
Files may be copied to devices. For example, copy file lpt1 sends the file to the printer on
LPT1. copy file con outputs file to the screen ("console"), which can also be done using
type file. Devices themselves may be copied: copy con file takes the text typed into the
console and puts it into file, stopping when EOF (Ctrl+Z) is typed.
Files may be concatenated using +. For example, copy file1+file2 file_cat will
concatenate the files and output them as file_cat. There are two switches to modify the command's
behaviour, /a (text mode, the default) and /b (binary mode). In text mode, copy will stop when
it reaches the EOF character; in binary mode, the files will be concatenated in their entirety,
ignoring EOF characters.
Examples of usage:
copy /a alpha.txt + beta.txt gamma.txt
copy /b alpha.mpg + beta.mpg gamma.mp.
defrag

(in MS/PC-DOS; diskopt in DR-DOS)

Defragments a disk drive.


Options:

• -A – Analyses the fragmentation of a disk drive


• -F – Force defragmentation even if disk space is low
• -V – Verbose output mode
• -H – Defrag hidden files

Example of usage:
defrag driveletter: -a -v
No Unix equivalent.

del or erase

Deletes one or more files.

This command is used to delete a particular or more files.

Syntax:

del filename
erase filename

Options

14.6 All files in current folder


6.6 /s all files in current folder and sub folders,
Equivalent to the Unix command rm.
Equivalent in RT-11/RSX-11/OpenVMS operating systems line is delete command which can
be contracted to del.

dir

Lists the contents of a directory.

The dir command typed by itself, displays the disk's volume label and serial number; one directory or
filename per line, including the filename extension, the file size in bytes, and the date and time the file was
last modified; and the total number of files listed, their cumulative size, and the free space (in bytes)
remaining on the disk. The command is one of the few commands that exist from the first versions of DOS.

dir [drive:][path][filename] [parameters]

Most commonly used parameters of dir include:

• /W : Displays the listing in wide format, with as many as five filenames or directory names on
each line.
• /P : Pause at every page
• /S : Also look in subdirectories
• /Axx: Display files with the specified attributes only
• /Oxx: Modifies sort order
• /B : Uses bare format (no heading information or summary)
• > [drive:][path]filename : To Store Result in a text file;(c:\dir > c:\fileList.txt) (this is
not a parameter, it is output redirection)

Possible attributes for the A parameter are D (directories), R (read-only files), H (hidden files), A
(files/directories with the archive bit on), and S (system files). The prefix - negates an attribute; attributes
can be combined (e.g. /A:DA means directories with the archive bit on).

Possible sort orders are N (name), S (size), E (extension), D (date and time), A (last access date), and G
(group directories first). The prefix - reverses the order.

Other less commonly used parameters of dir include:

• /D : Display wide format but sorted by column


• /L : Display forced into lowercase
• /N : Display forced into long file name format instead of 8.3
• /Q : Displays the owner of each file
• /X : Display shows 8.3 names next to long file names

exit

Exits the current command processor. If the exit is used at the primary command, it has no effect
unless in a DOS window under Microsoft Windows, in which case the window is closed and the
user returns to the desktop.
exit [/B]
/B When used within a batch script, exits the script without closing
the calling DOS window

fdisk

Manipulates hard disk partition tables. The name derives from IBM's habit of calling hard drives
fixed disks. When run from the command line, it displays a menu of various partitioning
operations:
1. Create DOS partition or Logical DOS Drive
2. Set active partition
3. Delete partition or Logical DOS Drive
4. Display partition information
5. Change current fixed disk drive (only available if the computer has
more than one hard drive)
FDISK /MBR installs a standard master boot record on the hard drive.
FDISK /MBR #: where # is other partition on system. Completes above command on indicated
partition.
e.g.: "C:\FDISK /MBR D:" would install boot record on
D:\ partition.
Fdisk exists under Unix with the same name, but it is an entirely different program. However they
share purposes.

find
A filter to find lines in the input data stream that contain or don't contain a specified string and
send these to the output data stream.
Find may also be used as a pipe.
find "keyword" < ''inputfilename'' > ''outputfilename''

Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.


/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the
string.
"string" Specifies the text string to find.
[drive:][path]filename Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the


prompt
or piped from another command.

format

Delete all the files on the disk and reformat it for MS-DOS
In most cases, this should only be used on floppy drives or other removable media. This command
can potentially erase everything on a computer's hard disk.
/autotest and /backup are undocumented features. Both will format the drive without a
confirmation prompt.
format [options] drive
FORMAT drive: [/V[:label]] [/Q] [/F:size] [/B | /S] [/C]
FORMAT drive: [/V[:label]] [/Q] [/T:tracks /N:sectors] [/B | /S] [/C]
FORMAT drive: [/V[:label]] [/Q] [/1] [/4] [/B | /S] [/C]
FORMAT drive: [/Q] [/1] [/4] [/8] [/B | /S] [/C]
/V[:label] Specifies the volume label.
/Q Performs a quick format.
/F:size Specifies the size of the floppy disk to format (such
as 160, 180, 320, 360, 720, 1.2, 1.44, 2.88).
/B Allocates space on the formatted disk for system files.
/S Copies system files to the formatted disk.
/T:tracks Specifies the number of tracks per disk side.
/N:sectors Specifies the number of sectors per track.
/1 Formats a single side of a floppy disk.
/4 Formats a 5.25-inch 360K floppy disk in a high-density
drive.
/8 Formats eight sectors per track.
/C Tests clusters that are currently marked "bad."

help

Gives help about DOS.


MS-DOS
help 'command' would give help on a specific command. By itself, it lists the contents of
DOSHELP.HLP. Help for a specific command invokes the command with the /? option

md or mkdir
Makes a new directory. The parent of the directory specified will be created if it does not already
exist.
md directory
Equivalent to the Unix command mkdir.
.

move

Moves files or renames directories.


move filename newname
move driveletter:\olddir driveletter:\newdir
Example of usage:
move c:\old c:\new
Equivalent to the Unix command mv. DR-DOS used a separate command for renaming
directories, rendir.

path

Displays or sets a search path for executable files.

rd or rmdir

Remove a directory, which by default must be empty of files for the command to succeed. The
DELTREE command in DOS removes non-empty directories. In Windows NT's CMD.EXE,
rd /s functions in the same way as deltree.

rem

Remark statement, normally used within a batch file, or for DOS 6 and above, in CONFIG.SYS.
rem This creates a zero-byte file in some command processors.
rem > newfilename
:: This never creates a file
:: > filename.ext
Redirecting the output from a rem command produces a zero-byte file in some command
processors.
REM is also useful in logged sessions or screen-captures.
In Unix, the # sign can be used to start a comment.

ren

Renames a file. Unlike the move command, this command cannot be used to rename
subdirectories, or rename files across drives.
ren filename newname
You can rename files in another directory by using the PATH parameter:
ren [[path\]filename] [newfilename]
This example renames c:\windows\filex.txt to c:\windows\filey.txt
ren c:\Windows\filex.txt filey.txt
Using a path in the destination newname will move the file to the new path, if this is on the same
device. This renames the file to the c:\temp directory.
ren c:\windows\filex.txt \temp\filey.txt
On DOS with long filename support, care must be taken when directories have spaces in their
names like "Documents and Settings". In these cases double-quotes are used to enclose them. Note
it is necessary only to enclose blocks including spaces.
ren c:\"Documents and Settings"\"All Users"\Desktop\filex.txt filey.txt
ren "c:\Documents and Settings\All Users\Desktop\filex.txt" filey.txt
Wildcards in the destination are replaced by the corresponding part of the original name, so the
command below will change the extension of the file from .doc to .txt, here myfile.doc becomes
myfile.txt.
ren myfile.doc 6.txt
Mass renames can be accomplished by the use of wildcards. For example, the following command
will change the extension of all files in the current directory which currently have the extension
htm to html:
ren 6.htm 6.html
In Unix, this functionality of a simple move is provided by the mv command, while batch renames
can be done using the rename command.

scandisk

Disk diagnostic utility. Scandisk was a replacement for the chkdsk utility, starting with later
versions of MS-DOS. Its primary advantages over chkdsk is that it is more reliable and has the
ability to run a surface scan which finds and marks bad clusters on the disk. It also provided
mouse point-and-click TUI, allowing for interactive session to complement command-line batch
run.

chkdsk had surface scan and bad cluster detection functionality included, and was used again on
Windows NT based operating systems.

Equivalent to the Unix command fsck.

sys

A utility to make a volume bootable. Sys rewrites the Volume Boot Code (the first sector of the
partition that Sys is acting on) so that the code, when executed, will look for Io.sys. Sys also
copies the core DOS system files, Io.sys, Msdos.sys, and Command.com, to the volume. Sys does
NOT rewrite the Master Boot Record, contrary to widely-held belief.

time and date

Display and set the time and date


time
date
When these commands are called from the command line or a batch file, they will display the time
or date and wait for the user to type a new time or date and press RETURN. The commands time
/t and date /t will display output without waiting for input.
The Unix command date displays both the time and date, but does not allow the normal users to
change either. Users with superuser privileges may use date -s <new-date-time> to
change the time and date.
The Unix command time performs a different function.

tree

Shows the directory tree of the current directory


Syntax:
tree [options] [directory]

Potrebbero piacerti anche