Sie sind auf Seite 1von 6

DOS commands

Command and Usage Examples

ATTRIB ATTRIB -R -A -S -H <VIRUS.EXE>


Change file attributes. + adds an All these attributes will be removed from
attribute, - removes it. Attributes are: A=archive; virus.exe.
R=read only; S=system; H=hidden.

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

CD CD\ takes you to the top of the directory tree


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

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. Can
be used with the * and the ? wildcards. DEL *.JPG will delete all files with the extension
JPG.
DEL MY*.* will delete all files beginning with MY
DEL *.* will delete ALL files in the current directory, and with any extension.
USE WITH CAUTION.
DEL MY??.* will delete files that are 4
(Note: DEL cannot be used to delete directories. characters long and begin with MY and with any
Use RD to remove a directory.) extension.

DIR DIR displays all files and folders in the current


Displays the contents of a directory (folder). directory. Folders are indicated in the list by
<DIR>.
Note, directory is the term used by DOS for what Files are usually listed by name.
Windows calls a folder.
DIR /P displays the contents a page at a time,
These switches can be combined, so DIR /W /P will i.e. as many as will fit in your command line
return multiple rows listing a page at a time. window. Press any key to display the next page.

You can use the * and the ? wildcards to search for DIR /W displays the files/folders in multiple
a particular file. The ? character represents ONE rows. This view gives less information per file.
character, and the * character represents multiple
characters. DIR *.JPG displays all files with the extension
JPG in the current directory and all
DIR *.* lists all the files in a directory. subdirectories.

DIR MY??.* displays all files beginning with MY,


exactly 4 characters long, and with any
extension.

DIR /S lists the contents of all subdirectories.

DIR /AH displays all hidden files.

EDIT EDIT <VIRUSLOG.TXT> opens the file


Runs DOS EDIT (a simple text editor). Useful for viruslog.txt and allows you to edit it.
editing batch files and viewing logs. This command
requires QBASIC.EXE to be present. EDIT <NEWFILE.TXT> creates a new file called
newfile.txt and opens it up for you to edit.
HELP HELP DIR displays information on the DIR
Displays DOS Help. For help on an individual command.
command, type HELP then the command for which
you want more information.

MD MD <NEWDIR> creates a new directory called


Make Directory creates a new directory below the Newdir.
current one. (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 RD <DIRECTORYNAME>
Remove directory. Removes a sub-directory of the
current directory. The directory you want to remove
must be empty of all files. (The command can also
be written as RMDIR)

RENAME RENAME <OLDNAME.EXE>


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

TYPE TYPE C:\README.TXT|MORE


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 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 e.g. SWEEP > REPORT.TXT The details of any
screen to a file. It runs the command preceding the infected files reported by SWEEP are sent to a
>, creates a file in the current directory with the file called REPORT.TXT.
name you specify, and sends the information/output
returned by the command, to that file.

UINX COMMANDS

Key/Command Description

cd [folder] Change directory e.g. cd Documents

cd Home directory

cd ~ Home directory

cd / Root of drive

cd - Previous directory

ls Short listing

ls -l Long listing

ls -a Listing incl. hidden files

ls -lh Long listing with Human readable file sizes

ls -R Entire content of folder recursively

Run command with the security privileges of the superuser (Super


sudo [command]
User DO)

open [file] Opens a file ( as if you double clicked it )

top Displays active processes. Press q to quit

nano [file] Opens the file using the nano editor

vim [file] Opens the file using the vim editor

clear Clears the screen

reset Resets the terminal display

Control+C Terminates most operations.


Key/Command Description

date Displays the current date and time.

Repeats whatever appears after the command (after


echo
expansion).

help Displays a partial list of bash commands.

mkdir [dir] Create new directory

mkdir -p [dir]/[dir] Create nested directories

rmdir [dir] Remove directory ( only operates on empty directories )

rm -R [dir] Remove directory and contents

less [file] Output file content delivered in screensize chunks

[command] > [file] Push output to file, keep in mind it will get overwritten

[command] >>
Append output to existing file
[file]

[command] < [file] Tell command to read content from a file

Linux Commands
pwd It gives us the Absolute Path, which means the path that starts from
the root.
ls The “Is” command is used to know what files are there in the directory
you are in. You can see all the hidden files by using the command “ls -
a”.
cd “cd” is the command used to go to a directory.
mkdir & rmdir The mkdir command is used when you need to create a folder or a
directory.
rmdir is the command used for deleting a directory. To delete a
directory containing files, rm is used.
rm The rm command is used to delete files and directories. rm cannot
simply delete a directory. “rm -r” is used to delete a directory. In this
case, it deletes both the folder and the files in it.
touch The touch command is used to create a file. It can be anything, from
an empty txt file to an empty zip file.
man & –help To know more about a command and on how to use it,
the man command is used. It shows the manual pages of the
command.
cp The cp command is used to copy files through the command line. It
takes two arguments, the first one is location of the file to be copied,
the second iswhere to copy.
mv The mv command is used to move files through the command line.
We can also use the mv command to rename a file.
locate The locate command is used to locate a file in a Linux System, just
like the search command in Windows.