0% found this document useful (0 votes)
44 views

DOS Commands

Uploaded by

hiralvisavadia5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

DOS Commands

Uploaded by

hiralvisavadia5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

DOS COMMANDS

Faculty of Engineering &


Technology
INDEX
• Basics of DOS Commands

• The Main Function of DOS Command

• Directory structure

• Internal DOS Commands

• External DOS Commands


Basics of DOS Command
• DOS commands are the commands available in MS-DOS that are
used to interact with the operating system and other command
line based software.
• Unlike in Windows, DOS commands are the primary way in which you
use the operating system. Windows and other modern OSs use a
graphics-based system designed for touch or a mouse.
The Command Prompt in Windows provides access to over
280 commands.
• These commands are used to do certain operating system tasks
from a command line interface instead of the graphical Windows
interface we use most of the time.
• For example, Command Prompt commands let you copy data to a
different folder, format an entire disk, back up your files, send
messages to other computers, restart your own computer, and much
more.
The Main Function of DOS

• DOS translate the command issued by the user in the format that
is understood by the computer to execute it, also generate the
error message in the human readable language.

• Manage Disk files.

• Allocate system resources according to the system requirement


Directory structure

• Directory is just like a file folder, which contain all the logically
related files.

• DOS enables the users to organize the files in a disk into


directories and sub-directories.

• A directory within another directory is called a sub-directory.

• Of course, there may be sub-directories of sub-directories are


present.
Directory structure
Root
directory

C
Directory A B

A C C
B Sub
B
directory
C C

File in
subdirectory
Figure 1: Tree structure of directories
Classification of DOS Commands

• DOS Commands are classified in two categories:

• Internal commands: Internal commands are DOS commands


embedded into cmd.exe shell. They are always available to
the user and tend to focus on file and folder commands. An
example of an internal command would be "CLS" to clear the
screen.
Classification of DOS Commands

• DOS Commands are classified in two categories:

• External commands: External commands are not located in


the shell but are in program files stored on disk. They are a
combination of .exe and .com files mostly found in the \
windows\system32 folder. An example of an external
command would be "MORE.COM" to pause the output of a
command.
Internal DOS Commands
• CLS: The CLS command is used to clear the window &
move the cmd to the top of the window.
Syntax: cls
• Date: The Date command is used to display and/or
sets the system date.
Syntax: date /t
date [/t | <month – day -
year>]
Internal DOS Commands
• VER: The VER command is used to display the DOS
version number for the version of DOS currently active.
Syntax: VER

• VOL: The VOL command is used to display he volume


label and serial number of a label.
Syntax: vol[<:drive>]
Internal DOS Commands

• DIR: The DIR command is used to display a list of directory’s files


and subdirectories. As well as it displays name extension & the
size in bytes. DIR also displays the total number of files &
directories listed their cumulative size, and the free space
remaining on the disk.

Syntax: dir [<Drive :>] [<path>]


[</Filename>]
Internal DOS Commands

• //To access particular file

• [<Drive>] : specifies the drive and directory for which you


want to see.
• [<Path>]: specifies the location of file.

• [</Filename>]: specifies a particular file or group of files for


which you want to see.
Internal DOS Commands
Use of wildcard characters with DIR command:
• Asterisk (*): By using * , you can represent one or more
characters of a file name and can also display a subset
of files or subdirectories.

For example: dir * .txt*


//It lists all files in the current directory with
extensions that begin with .txt, such as .txt, .txt1,txt_old.
Internal DOS Commands
Use of wildcard characters with DIR command:

dir read*.txt*
//Lists all files in the current directory that begin with
“read” & with extensions that begin with .txt such as .txt,
.txt1.
dir read * . *
// Lists all files in the current directory that begin with
“read” with any extension.
Internal DOS Commands
Use of wildcard characters with DIR command:

• Question mark (?): Use the question mark as a


substitute for a single character in a name.

• For example: dir read??? . txt //Lists any files in the


current directory with the .txt extension that begin with
“read” & are followed by up to three characters. This
includes Read.txt, Read1.txt, Read12.txt, Read123.txt,
Readme1.txt, but not Readme12.txt
Internal DOS Commands
Use of wildcard characters with DIR command:

• Note: In the syntax of each commands, the use of [] is


represent that the content written into [] is optional.
Internal DOS Commands
• COPY CON: It allows the Creation of a new file through the
command line.
Syntax: copy con filename
Than write lines to insert into the file & when done.
Press ctrl + z to save & create file
Press ctrl + c to cancel file
• TYPE: Type is a built command, which displays the contents of
file without modifying it.
Syntax: type [</drive>:] [<path>]
<filename>
• /? : This command is used to get help.
Internal DOS Commands
• MKDIR (Make directory): The mkdir command is used
to create a directory or subdirectory in current drive.
Syntax: md [<drive>:] <path>
mkdir[<drive>:] <path>
• For example,
md directory1
md taxes\property\current //To
create directory tree within root directory.
Internal DOS Commands
• CD (change directory) : Displays the name of or changes the
current directory.
Syntax: cd [/d] [<drive>] [<path>]
cd [..]
• where,
[/d] = change current drive as well as current directory
for a drive.
<drive> = specifies the drive to display or change (if
different from current directory)
<path> = specifies the path to the directory.
< .. > = Specifies that you want to change to the parent
folder.
Cd\ = Used to reach to the root directory.
Internal DOS Commands
For example,
• To change drive = cd /d D:
• To change directory as well as drive = cd /d D:/users/lenovo
• To change parent node: cd..
• To reach to the root folder: cd\
• RMDIR (remove directory): To deletes a only directory.
Syntax: rd [<drive>:] <path> [/s[/q]]
Where,
• [<drive>:] = Specifies the location & the name of the directory that
you want to delete.
• /s = Deletes a directory tree with confirmation.
• /q = Specifies quite mode without confirmation.
Internal DOS Commands
• Rename(ren): Rename files or directories.
Synatx: rename [<Drive>:] [<path>]
<filename1> <filename2>
For example,
• To change .txt extension in the current directory to .doc
extension
rename *.txt *.doc
• To change directory name
rename chap10 part10
Internal DOS Commands
• DEL (erase): Delete one or more files and also drive.
Syntax: del [/p] [/f] [/s] [/q] [/a [:]
<attributes>] <names>
Where,
<names> = specifies a list of one or more files or
directories.
/p = prompt for confirm before delete.
/f = Force deletion of read-only files.
Internal DOS Commands
• DEL (erase): Delete one or more files
Syntax: del [/p] [/f] [/s] [/q] [/a [:]
<attributes>] <names>
Where,
/s = Deletes specified files from the
current & subdirectories. Displays the names of the files
as they are being deleted.
/q = quite mode.
Internal DOS Commands
/a[:]<attributes> = attributes r = Read-only files
h = Hidden files
i = not content identify
s = system files
For example,
• del \work Delete files from specific folders
• del * . * Delete all of the files in the current
directory
• del C:\test\* .* Delete all files from test folder
• del *.bat Delete all files with the .bat extension
from the current directory
• del /a:r *.* Deletes all read only files from current
directory
Internal DOS Commands
• MOVE : Used to move one or more files from one directory to
another directory.
Syntax: move [{/y | /-y}] [<sources>]
[<target>]
• Where,
/y = Supresses prompting to confirm that you want to
overwrite an existing file.
/-y = causes prompting
<sources> = path or name of file from current directory
<target> = path or name to move file.
• For example,
move \data\*.xls \second_q\reports\
Internal DOS Commands
• COPY : Copy one or more files from one location to another.
Syntax: copy source_file_name
dest_file_name
• For example,
copy memo.doc letters.doc
copy robin.py c:\ birds //To copy a file from
the current directory to
existing directory of other
drive c.
copy mar89.txt + apr89.txt+may89.txt
report
// To combine files. In the
case of destination is not
mentioned, all combined files are
Internal DOS Commands
• PROMPT : It changes the cmd.exe command prompt. Prompt
resets the command prompt to the default settings, which is the
current drive letter & directory followed by the greater than
symbol (>).
To remove current prompt:
Syntax: prompt new_name
To change from new to actual name:
Syntax: prompt $p $g
For example,
prompt $d $s $s $t - $g
prompt - - $g
prompt $p $g
Internal DOS Commands
• DOSKEY: Display all commands that are stored in memory.
Syntax: doskey/history > tmp.txt //To create txt
programmed named tmp.txt file that contains recently used
commands.
External DOS Commands
• ATTRIB : Dispalys / sets or removes attributes assigned to files or
directories.

List of attributes:
• r : Read-only
• a : Archive file
• s : System file
• h : Hidden file
• i : Not – content indexed
• /s : Applies attrib for directory as well as subdirectories
• /d : Only applies for directory.
External DOS Commands
• ATTRIB :
Syntax: attrib + [option] file_name //To
set attribute

• For example,
To assign read-only attribute to report.txt file.

attrib +r report.txt

To remove the Read-only attribute from files in the public


directory & its subdirectories on a disk in drive B.

attrib -r b: \ public\ *.* /s


External DOS Commands
• FORMAT: Format disk to accept window files. It creates a new root
directories & file system for the disk. Nevertheless, you must be a
member of the administer group to format the disk, because its
require authority.
Syntax: format a: //To format a new floppy disk in
drive A.
format a: /q //To perform quick format
operation on a previously
formatted disk in drive A.
format a: /v :data //To format disk and
assign it the volume label
“data”.
External DOS Commands
• TREE: Displays the directory structure of a path or of the disk in a
drive graphically.
Syntax: tree [<drive>:] [<path>] [/f] [/a ]
Where,
• <drive> = Specifies the drive that contains the disk for which
you want to display the directory structure.
• <path> = specifies the directory for which you want to display.
• /f = Displays the names of the files in each directory.
• /a = Specifies that tree is to use text characters instead of
graphic characters to show the lines that link subdirectories.
External DOS Commands
• TREE: Displays the directory structure of a path or of the disk in a
drive graphically.
Syntax: tree [<drive>:] [<path>] [/f] [/a ]
• For example,
To display the names of all the subdirectories on the disk in your
current drive
tree \
To display , one screen at a time, the files in all the directories on
drive C.
tree c: \ /f | more
To print a list of all the directories on drive C,
tree c: \ /f prn
External DOS Commands
• XCOPY : Copies all files & directories, including subdirectories.
Syntax: xcopy <source> [<destination>]
• For example,

To copy all files & subdirectories from drive A to drive B.


xcopy a: b: /s /e
Batch File
Batch File

• A batch file is an unformatted text file or script file which


contains multiple commands to achieve a certain task.

• It contains series of command that is executed by command line


interpreter.

• The extension of batch file is : .bat or .cmd


Batch File

How to create a batch file?

• Open a built-in text editor for windows.

• After writing commands, all you need to do is save it as


a .bat or .cmd file.

• A batch file can be run via command prompt.

You might also like