Using Commands

Commands are given in CUI and Windows XP being a GUI operating system does support MS-DOS command interface also called as command line or CUI of MS-DOS. Command line utilities helps to better manage a computer in an efficient and effective manner. Command line is started by executing ‘CMD’ in run option of start menu which is a 32-bit command processor or command line is started by 16-bit command.com. After running the ‘cmd’ command, the command processor or also called as command interpreter starts. Commands are classified as per their use and the commands are

  • Directory Management – DIR, MD or MKDIR, RD, CD, DELTREE & PAT
  • File Management – COPY, XCOPY, DEL, TYPE, REN, MOVE & ATTRIB
  • Disk Management – FORMAT, CHKDSK, LABEL, DEFRAG, DISKPART & VOL
  • DOS utility – CLS, MORE & SCANDISK
  • Network utility – IPCONFIG & PING
  • System utility – SFC, FIXBOOT & FIXMBR

DIR  – This command lists the files and the sub directories in a directory except the hidden system files such as MSDOS.SYS and IO.SYS, even if present, its usage is

DIR [drive:][path][filename] [/P] [/W][:]  [/O[[:]sort order]] [/S]  or DIR [C:][filename.[ext]

Where,

[drive:][path][filename] – Specifies drive, directory, and/or files to list.

/P      –   This command lists the directory page wise and pauses after each screen of information.

/W    –   This command lists the directory width wise and Uses wide list format.

/O     –    List by files in sorted order and the sort order is given as

N  By name (alphabetic)       S  By size (smallest first)

E  By extension (alphabetic)  D  By date & time (earliest first)

/S     –    Displays files in specified directory and all subdirectories.

For each file its size and date and time of modify is shown. If more data than one screen, /p and /w can be combined as

DIR [C:][filename.[ext][/p][/w]

Global characters: ‘?’ and ‘*’are known as wildcard characters and are used in file name and extension parameters. A ‘?’means zero or one character and ‘*’ for any number of characters for eg. to display files having extension .BAK of drive C type

C:>DIR *.BAK

MD or MKDIR – It creates a directory in the specified location. Its usage is

MKDIR [C:] path Or MD [C:] path –OR- MKDIR [drive:]path –OR-  MD [drive:]path

If we omit the drive letter, current drive is assumed. Path is path of creation of directory. All characters, that are valid for file name, are valid for a directory name. For e.g.

C:>MD WS

Will create a subdirectory namely WS under the root directory of drive C. the following command creates the subdirectory PRG under the subdirectory WS.

C:>MD WS\PRG

We can create as many subdirectories, limited by disk space. But maximum length of path from root to desired level is no more than 63 characters, including embedded backslashes. Two or more files or directory can have the same name as long as they are defined in separate directories.

RMDIR or RD – It removes directory from the specified path. Its usage is

RMDIR [C: [[path] –OR- RD [drive:]path

Directory to remove must be empty i.e. no files or sub-directory. The root directory, the working directory can’t be removed. Suppose we want to remove a directory named C:\DOS\TEMP, first ensure that the directory is empty and then type the following command.

RD C:\DOS\TEMP

CHDIR or CD – It changes the current directory. Its syntax is

CHDIR [C:] [path] –OR- CD [C:] [path]

To go to root directory of the drive.

C:>CD\

To go to parent directory

C:>CD..

If our working directory is C:\DOS\BASIC and we want to change our path to another directory such as C:\DOS\PCTOOLS type the following command and press enter

C:\DOS\BASIC>CD ..\PCTOOLS

‘.’ Points to present directory and ‘..’ refers to parent directory.

DELTREE – It deletes a directory and all the subdirectories and files in it. Its syntax is

DELTREE [/Y] [drive:]path

Where,

/Y                  Suppresses prompting to confirm we want to delete the subdirectory.

[drive:]path    Specifies the name of the directory we want to delete.

DELTREE deletes every file and subdirectory within the specified directory.

PATH – It stores list of directories separated by semicolons where program or executable files are present. Its syntax is

PATH  [C:] [drive][path] [:drive] [path]…]  or   PATH

OS searches specified directories in the sequence we entered them. To display current path, type only PATH. To specify specific new list of directories to search, type

C:>PATH C:\DOS

COPY – Copies one or more files to another location, its usage is

COPY source  [+ source  [+…]] [destination]

Where,

Source        –  Specifies the file or files to be copied.

Destination –  Specifies the directory and/or filename for the new file(s).

For e.g.

COPY ABC.IMP B:

If the original file is on the default drive and we don’t specify the second pathname, the copy command is not performed and MS-DOS displays the following message:

File cannot be copied onto itself: 0 file(s) copied.

  • If the second option is a filename only, MS-DOS copies the original file to one on the default drive and renames it with the specified filename. E.g.

C>COPY VIP.IMP VVV.IMP

We can use the global characters? And * in the file name and in the extension of both the sources and the target files. E.g.

A>COPY *.* B:

Copies all type of files in the current directory from the default drive A to B.

XCOPY – This command copies files and directory trees to another location. Its syntax is

XCOPY source [destination] [/P] [/S [/E]] [/W]

Source             Specifies the file(s) to copy.

Destination      Specifies the location and/or name of new files.

/P                     Prompts us before creating each destination file.

/S                     Copies directories and subdirectories except empty ones.

/E                    Copies directories and subdirectories, including empty ones.

/W                   Prompts us to press a key before copying.

DEL (DELETE) – It deletes the files specified by the drive and path name. Its syntax is

DEL [drive:][path] filename [/P] –OR-  ERASE [drive:][path]filename [/P] [drive:][path]filename   – Specifies the file(s) to delete.  Specify multiple files by using wildcards.

/P  –      Prompts for confirmation before deleting each file. A message “Are we sure (Y/N)?” is displayed to verify that we actually want to delete the file. Type Y (Yes) if we want to delete otherwise type N (No).

If we do not specify the drive name the current working drive is assumed i.e. the files will be deleted from the current working directory.

A> del C:\temp

We can’t delete files that are marked as read only. Don’t use DEL command to delete a sub-directory. We can use the global filename characters  ‘?’ and ‘*’ in the filename and extension e.g.

B> DEL *.BAK

TYPE

It displays contents of a file. Its syntax is

type [filename]

REN (RENAME) – Renames a file/directory or files/directories, its usage is

RENAME [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]

Note that we cannot specify a new drive or path for our destination.

A>REN B: MAIN.PRG TIME.PRG

Renames the file MAIN.PRG on drive B to TIME.PRG

MOVE – This command is utilized for moving files and renames files and directories.

To move one or more files

MOVE [/Y | /-Y] [drive:][path]filename1[,…] destination

To rename a directory

MOVE [drive:][path]dirname1 dirname2

[drive:][path]filename1            Specifies the location and name of the file or files we want to move.

Destination                              Specifies the new location of the file. Destination

[drive:][path]dirname1            Specifies the directory we want to rename.

dirname2                                 Specifies the new name of the directory.

ATTRIB – This command can display or change file attributes. Each file has got some attributes, according to which commands are applicable to it. For example a file having enabled hidden attribute cannot be

seen with DIR command. Its syntax is

ATTRIB [+R | -R] [+S | -S] [+H | -H] [[drive:][path]filename]

Where,

+   Sets an attribute,    –   Clears an attribute,    R   Read-only file attribute,    S   System file attribute,   H   Hidden file attribute.

FORMAT – This command formats the disk to the specified disk. Formatting analyses the entire disk for any defective tracks; and prepare the disk accept MS DOS files by initializing the directory, File Allocation Table, and system loader. We must use this command to format all new disks before MS can use them. Be careful before formatting any disk, particularly a fixed disk because formatting destroys all data on the disk. Its usage is

FORMAT drive: [/V[:label]] [/Q] [/4] [ /S]

/4   – Format a single sided or double-sided diskette in a high capacity disk drive. (1.2MB)

/Q  – Performs a quick format.

/S  –  To copy the operating system files MSDOS.SYS, IO.SYS, COMMAND .COM

The first two files are hidden files, so we can’t see these two files in a directory of formatted disks. If the operating system is not on the default drive, format prompts to insert a system disk in the default drive or in drive A. If the default drive is non-removable, a message system transferred is displayed if the operating system files are successively copied onto the disks we are formatting. /V prompts for a volume label after the disks is formatted as

Enter volume label (11 characters, enter for none)?

A volume label identifies and can be up to 11 characters in length. The volume label cannot be used in place of file names as input to any of the DOS commands.

CHKDSK – The CHKDSK command checks a disk’s formatted size and available memory space. It also indicates the amount of disk space consumed by system files, data files, and bad sectors. DOS 5 also reports the volume serial number and information about the disks allocation units (clusters).

[C: Path] CHKDSK [File Spec][/F]

C: Path is the drive and path where the command file is located if it is not in the current directory or in a directory on the search path.

File Spec is an optional drive and path, including the filename and extension, of the file that is the object of the command. Wild cards are allowed.

/F allows us to make actual corrections on the disk.

LABEL – It creates, changes or deletes the volume identification label on a disk. Its syntax is

[C:] [path] LABEL [C:] [volume label]

To create a volume label type the following command

LABEL b: PURCHASE 89   or we can type      LABEL B:

Then we are prompted

Volume in drive B has no label

Volume Label (11 characters, Enter, for none)?

Type PURCHASE 89 and press enter.

DEFRAG

Defragments a disk drive. Its options are

-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 drive letter: -a –v

DISKPART –  It is a command-line hard disk partitioning utility, replacing fdisk which was used in MS-DOS based operating systems. The diskpart command supports the use of scripts to automate its usage. For example, the following text file could be supplied to diskpart to create a new partition:

create partition logical size=2048

assign letter=F

This will create a 2 GB logical partition at the beginning of the free space on the disk and assign it the drive letter F:, provided that space requirements are met.

VOL – This command displays the disk volume label or volume ID of the specific drive, if it exists. Its syntax is

VOL [drive:]

If we don’t specify a drive letter, MS-DOS displays the volume label or the disk in the default drive. To display the volume label of drive C

C>VOL C:

Volume in drive C has no label Volume serial number is 1106-16DF

CLS  – This command clears the terminal screen. Its syntax is CLS

MORE  – This command reads data from the standard input device, sends one screen of data to the standard input device, sends one screen of data to the standard output device and then pauses with the message

—MORE—

Its usage is

[C:] [path] MORE

[C:] [path] before MORE specifies the drive specifies and path contains the MORE command file. The MORE command will not work if the disk is full or write protected because to hold input information until it is displayed, the MORE command creates a temporary file on the disk. This command is useful for viewing long files, e.g. the following command displays the contents of the LONG.COB on the screen at a time.

TYPE ONG.COB|MORE

If screen is full, the message “—MORE— Press any key to see the next screen” appears.

SCANDISK – It checks and repairs file systems and bad clusters on the hard drive. It was introduced in MS-DOS 6.2. It includes a more user-friendly interface than MS-DOS CHKDSK, more command-line and other configuration options, and the ability to detect and sometimes recover from physical errors on the disk.

IPCONFIG – It is an acronym for internet protocol configuration and it displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings. Its syntax is

ipconfig [/? | /all | /renew [adapter] | /release [adapter] |/flushdns | /displaydns |

/registerdns | /showclassid adapter |/setclassid adapter [classid] ]

where,

adapter         Connection name

/?           Display help message

/all         Display full configuration information.

/release     Releases the IP address for the specified adapter.

/renew       Renews the IP address for the specified adapter.

/flushdns    Purges the DNS Resolver cache.

/registerdns Refreshes all DHCP leases and re-registers DNS names

/displaydns  Display the contents of the DNS Resolver Cache.

PING – It tests the reachability of a host on an Internet Protocol (IP) network and to measure the round-trip time for messages sent from the originating host to a destination computer. It sends Internet Control Message Protocol (ICMP) echo request packets to target and wait for response. Usage

ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]

where,

-t             Ping the specified host until stopped.

-a             Resolve addresses to hostnames.

-n count       Number of echo requests to send.

-l size       Send buffer size.

-f              Set Don’t Fragment flag in packet (IPv4-only).

-i TTL     Time To Live.

-v TOS    Type Of Service (IPv4-only).

For example ping –t www.google.com or ping 192.168.1.100

SFC – System File Checker (SFC) is a utility to check protected system files. It replaces incorrect versions or missing files with the correct files. To run it, type SFC with the appropriate switch at command prompt. ‘/scannow’ option scans all protected files immediately and ‘/scanonce’ scans all protected files at the next boot. If some files are missing, prompt to put original OS disc is given, so the files can be copied.

FIXMBR —It repairs MBR of system partition; if MBR is damaged and windows cannot start.

FIXBOOT —It writes new windows boot sector code to system partition.

Get industry recognized certification – Contact us

Menu