Basic DOS Commands.: Command Prompt

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

19/01/2016 Basic 

DOS commands.

Basic DOS commands.


Article ID: 13195 Updated: 11 Sep 2014

Rating:          

1289 customers rated this article 4.4 out of 6

Occasionally, on your Windows computer, you may need to perform a procedure by typing in
commands at the 'Command Prompt'. Entering commands in this way allows you to bypass the
Windows graphical user interface and communicate directly with the operating system. You are
most likely to need to work in this way if you get an infection and have to disinfect your computer
from the command line, for example, using SAV32CLI. 
PRODUCTS LABS PARTNERS COMPANY SUPPORT
To communicate through the Windows command line, you will need to use MS­DOS commands.
This article lists some basic DOS commands that you are likely to find useful when working from
Overview Support Packages
the command line, but there are many more available. To find out more about MS­DOS, consult Download Documentation Training Contact
a book, online dictionary or encyclopedia, or other specialist publication.

Command and Usage Examples

ATTRIB
Change file attributes. '+' adds an attribute, '­' removes it.
ATTRIB ‐R ‐A ‐S ‐H <VIRUS.EXE>
All these attributes will be removed from
Attributes are: A=archive; R=read only; S=system; H=hidden. virus.exe.

C:
Go to the C: drive. Similarly A: and D: etc. C:

CD\ takes you to the top of the directory tree
(typically to C:) .
CD.. moves you one level up the directory tree (i.e. up
towards the root directory).
CD
Change directory. When you change directory, the prompt CD <DIRECTORYNAME> takes you to that directory. You can
changes, showing the path of the directory you are currently in. use one or more subdirectory names, separated by \ e.g. 
CD WINNT\Media takes you to the directory
Note, directory is the term used by DOS for what Windows calls a
C:\WINNT\Media
folder.
To change to another path, type the full path with slashes.
e.g. 
CD \WINDOWS\SYSTEM

CLS CLS
Clear the screen.

DEL DEL <VIRUS.EXE> deletes virus.exe
Delete one or more files in the current directory. DEL *.JPG will delete all files with the extension JPG.
Can be used with the '*' and the '?' wildcards.
DEL *.* will delete ALL files in the current directory, USE WITH DEL MY*.* will delete all files beginning with MY and with
CAUTION. any extension.

(Note: DEL cannot be used to delete directories. Use RD to DEL MY??.* will delete files that are 4 characters long and
remove a directory.) begin with MY and with any extension.

DIR displays all files and folders in the current directory.
Folders are indicated in the list by <DIR>.
Files are usually listed by name.

DIR DIR /P displays the contents a page at a time, i.e. as
Displays the contents of a directory (folder).
Note, directory is the term used by DOS for what Windows calls a many as will fit in your command line window. Press any
folder. key to display the next page.

These switches can be combined, so DIR /W /P will return DIR /W displays the files/folders in multiple rows. This view
multiple rows listing a page at a time. gives less information per file.

You can use the '*' and the '?' wildcards to search for a particular DIR *.JPG displays all files with the extension JPG in the
file. The ? character represents ONE character, and the * current directory and all subdirectories.
character represents multiple characters.
DIR MY??.* displays all files beginning with MY, exactly 4
DIR *.* lists all the files in a directory. characters long, and with any extension.

DIR /S lists the contents of all subdirectories.

DIR /AH displays all hidden files.

EDIT <VIRUSLOG.TXT> opens the file viruslog.txt and
EDIT
allows you to edit it.
Runs DOS EDIT (a simple text editor). Useful for editing batch
files and viewing logs. This command requires QBASIC.EXE to be
EDIT <NEWFILE.TXT> creates a new file called newfile.txt
present.
and opens it up for you to edit.

https://www.sophos.com/en­us/support/knowledgebase/13195.aspx 1/3
19/01/2016 Basic DOS commands.

HELP
Displays DOS Help. For help on an individual command, type HELP DIR displays information on the DIR command.
HELP then the command for which you want more information.

MD
Make directory. Creates a new directory below the current one. MD <NEWDIR> creates a new directory called Newdir.
(The command can also be written as MKDIR)

PRINT PRINT <LOGFILE.TXT>
Prints the specified file (if the printer is supported in DOS ­ many
are not). Prints LOGFILE.TXT

RD
Remove directory. Removes a subdirectory of the current
RD <DIRECTORYNAME>
directory. The directory you want to remove must be empty of all
files. (The command can also be written as RMDIR)

RENAME
Rename a file. You must use the full file name including the RENAME <OLDNAME.EXE> <NEWNAME.EXE>
suffix.

TYPE
Displays the contents of a file on the screen. If you use this
command on a file which is not a text file, the display will be
TYPE C:\README.TXT|MORE
unintelligible. Use with "|MORE" to display the text on a page by
page basis, and prevent it scrolling off the screen. "|" is a pipe
character.

>
COMMAND > FILENAME.TXT
When you run a DOS command, output is usually sent to the
screen. Use > to redirect output from the screen to a file. It runs
e.g. SWEEP > REPORT.TXT The details of any infected
the command preceding the >, creates a file in the current
files reported by SWEEP are sent to a file called
directory with the name you specify, and sends the
REPORT.TXT.
information/output returned by the command, to that file.

Accessing the command prompt from
Windows
To access the command prompt from Windows (a 'DOS box'), do as follows:

1.  At the taskbar, select Start|Run.
2.  Type
CMD
or on some versions of Windows
COMMAND
3.  Click 'OK'.
A command prompt will open.

Accessing the command prompt in safe mode


For Windows NT/2000/XP/2003, see the knowledgebase article on removing
files with SAV32CLI.
For Windows 95/98/Me you can boot from a startup disk, or use MS DOS
mode
1.  At the taskbar, select Start|Shut dows.
2.  Select 'Restart in MS­DOS mode'.
3.  Click 'OK'.

 
If you need more information or guidance, then please contact technical support.

Rate this article

How did the article rate? Very poor


0
1
2
3
4
5
6
Excellent
Did this solve your problem? Yes No
Comments

Help us improve this article

https://www.sophos.com/en­us/support/knowledgebase/13195.aspx 2/3
19/01/2016 Basic DOS commands.

Submit

POPULAR COMMUNITY WORK WITH US ABOUT SOPHOS SUPPORT


Free Trials Sophos Blog Become a Partner Jobs/Careers Extended Warranties
Free Tools Social Networks Partner Portal (login) Products Knowledgebase
Whitepapers Naked Security News Resellers Feedback Downloads & Updates
Technical Papers Podcasts Tech Partners Contact Us Documentation
Buy Online RSS OEM Press Professional Services
Sophos Brand Store Training

 English  Legal Privacy Cookie Information


© 1997 ­ 2016 Sophos Ltd. All rights reserved.

https://www.sophos.com/en­us/support/knowledgebase/13195.aspx 3/3

You might also like