DISK OPERATING SYSTEM (DOS)


Internal commands:


1. cls (Clear the Screen)

Syntax:           cls
Example: C :\> cls

2. dir

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


Syntax: dir [drive:][path][filename] [/P] [/W] [/A[[:]attributes]] [/O[[:]sort order]] [/S] [/B] [/L] [/V]
[drive:][path][filename]
Specifies drive, directory, and/or files to list. (Could be enhanced file specification or multiple file specs.)
/P
Pauses after each screen full of information.
/W
Uses wide list format.
/A
attributes:
D Directories
R Read-only files
H Hidden files
A Files ready for archiving
S System files
- Prefix meaning not
/O
List by files in sorted order, sort order:
N By name (alphabetic)
S By size (smallest first)
E By extension (alphabetic)
D By date & time (earliest first)
G Group directories first
- Prefix to reverse order
A By Last Access Date (earliest first)
/S
Displays files in specified directory and all subdirectories.
/B
Uses bare format (no heading information or summary).
/L
Uses lowercase.
/V
Verbose mode.


Syntax: dir [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sort order]] [/P] [/Q] [/S] [/T[[:]time field]] [/W] [/X] [/4]

[drive:][path][filename]
Specifies drive, directory, and/or files to list.
attributes
D Directories R Read-only files H Hidden files A Files ready for archiving S System files - Prefix meaning not
/B
Uses bare format (no heading information or summary).
/C
Display the thousand separator in file sizes. This is the default. Use /-C to disable display of separator.
/D
Same as wide but files are list sorted by column.
/L
Uses lowercase.
/N
New long list format where filenames are on the far right.
/O
List by files in sorted order.
sortorder
N By name (alphabetic) S By size (smallest first) E By extension (alphabetic) D By date/time (oldest first) G Group directories first - Prefix to reverse order
/P
Pauses after each screen full of information.
/Q
Display the owner of the file.
/S
Displays files in specified directory and all subdirectories.
/T
Controls which time field displayed or used for sorting
timefield
C Creation
A Last Access
W Last Written
/W
Uses wide list format.
/X
This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place.
/4
Displays four-digit years
Examples
dir
Lists all files and directories in the directory that you are currently in.
dir *.exe
The above command lists any executable file or any file that ends with .exe. See our wildcard definition for other wildcard (e.g. *) examples.
dir /ad
List only the directories in the current directory. If you need to move into one of the directories listed use the cd command.

dir /s
Lists the files in the directory that you are in and all sub directories after that directory, if you are at root "C:\>" and type this command this will list to you every file and directory on the C: drive of the computer.
dir /p
If the directory has a lot of files and you cannot read all the files as they scroll by, you can use this command and it will display all files one page at a time.
dir /w
If you don't need the info on the date / time and other information on the files, you can use this command to list just the files and directories going horizontally, taking as little as space needed.
dir /s /w /p
This would list all the files and directories in the current directory and the sub directories after that, in wide format and one page at a time.
dir /on
List the files in alphabetical order by the names of the files.
dir /o-n
List the files in reverse alphabetical order by the names of the files.

3. copy con

An internal command for creating a quick batch files in DOS or Windows. For example, to create the WRITE batch file, type:
Example: copy con write.bat
4. type

Syntax: type [drive:][path]<filename>Use: Display a file. The more command is frequently used in conjunction with this command.
Example: c :\> type muna.txt
Output:           This command displays the information contained in the filename muna.txt

5. attrib
Change or view the attributes of one or more files. It defaults to displaying the attributes of all files in the current directory.
Syntax: 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
    • R - Read-only
    • A - Archive
    • S - System
    • H - Hidden
    • /D - Process folders as well.
    • /S - Process matching files in the current folder and all subfolders.

External commands:



1. xcopy


Syntax: xcopy [source drive:][path] [destination drive:] [path][switch]
Where, switch may be:
Switch                  meaning
/S                           Copies all files and sub-directories except empty ones.
/C                           Continues to copy also after error occurs.
/Q                           Quite mode. Doesn’t display files while copying.
/H                           Copies hidden files.
/R                           Over-writes read-only files, too.                     
/V                           Verifies each new file when written into the bank.
Use: copies directory along with its contents 9i.e. its files and subdirectories) to destination.
Example: c :\> copy C: D:
Output: This will copy all source directories and sub-directories of the C drive disk to D drive disk.



2. edit
 
Syntax: edit [drive:][path][filename][switch]
switch             meaning
/B                    Forces monochrome mode.
/H                    Displays the max no. of lines possible for our hardware.
/R                    load files in read only mode.
/S                    Forces the uses of short filenames.
/<nnn>           Load binary files, wrapping lines to <nnn> characters wide.
/?                     Displays this help screen.
[file]                 Specifies initial files to load. Wild-cards and multiple file specs can be given.
Use: use to edit files.
Example: C :> \ EDIT autoexec.bat
Output: This command will open the DOS file autoexec.bat and will allow us to edit.

3. del

Deletes one or more files.
This command is used to delete a particular or more files.
Syntax:
del filename
erase filename
Options:
*.* All files in current folder
*.* /s all files in current folder and sub folders.
4. rd
 

Remove a directory, which by default must be empty of files for the command to succeed (the /s flag removes this restriction).
Syntax: rd directory
5.md
 
Makes a new directory. The parent of the directory specified will be created if it does not already exist.
Syntax: md directory
6.ren

 Renames a file. Unlike the move command, this command cannot be used to rename subdirectories, or rename files across drives.
Syntax: ren filename newname
 
7.cd
 
 Change current working directory. Displays the current working directory when used without a path parameter.
cd f:
displays the current working directory on F:.
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 root (top level) directory of the current drive.


8.cd..

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