Skip to content

A crash course in MS-Dos.

March 9, 2009

The power of Dos is amazing.Learning to use DOS is very important in understanding Windows. Here is a basic guide that will help you kick start in MS-Dos.
Thinking seriously about DOS I would like to mention some useful commands that will help you understand the power of DOS. First for newbies, I will tell how to start DOS. If you have windows XP, then press Start+R and enter “cmd“.
This will open the command prompt window. This is your playground and you are going to type commands inside it and see the wonderful results it provide.
1. Writing Assembly Language programs:
Definitely, you can use DOS to write and compile assembly language programs. So first type Debug, and press enter. Nothing happens! But no error message is flagged. So something has happened. That is debug.exe is activated. Now you are going to write assembly language programs in DOS.
First, type “A” and press Enter. You will see a hex value and that is starting address of your assembly language program. Now type the following code:
Mov AX, 1200
MOv BX, 2000
ADD AX, BX
HLT

PRESS ENTER TWICE.
Now type “g” followed by starting address and the end address. The starting address is address to the right of your fist statement, which is here MOV AX, 1200.The end address is the last hex address you will see. You have got something and that is the output.
Now type “d” and press enter, again you got something and this is the contents of memory in hex and ASCII format.
To see the registers in your computer type “R” and press enter. To quit debug type “quit“. There are few other assembly language commands in Dos that you can use. Search and find them.
2. Directory management in DOS:
Dos can be used to manage your files. We know that the files in a computer are arranged in the hard-disk in the form of directories. So here we will discuss how to manage files or directories using DOS.
First, open a DOS window again and simply type “dir” into it and press Enter. You will get the list of directories in specified drive or folder.This is just basic and we are going to dig deep into directories and managing them in DOS.
Another very useful and prominent command that you use is cd\ command.It is used to change directories. This command can be used to navigate among the directories and folders in your system. So in order to change a folder you just type cd / and press enter. Now type in cd \ “name of folder” without quotes to navigate to a new folder. Just look at this screen shot.

To change a directory simply type cd \ and press Enter. Now type the name of the directory. Look at this screen shot.

Now you have learned to change directories and navigate among them.
Now we are going to create a directory. For this use the command mkdir
The syntax is mkdir dirname.
To remove a directory you can use RMDIR(RD) command. The command looks like this:
C>rd myfile
This command removes the directory named “myfile”.

3.Disk operations in Dos:

MS DOS has number of disk checking , defragmenting tools avialable which can be used to check for hardware related problems.
CHKDSK
Type chkdsk in the command prompt and this will check your disk for errors. Instead of chkdsk you can use scandisk in newer versions of dos. It also do the same thing. The format is scandisk drivename:
eg:scandisk D:
DEFRAG
This command can be used to perform defragmentation. The format is defrag drivename:
eg:defrag D:
FDISK
FDISK is one of the most useful dos tools and it is used to create partitions in hard-disk. Type in this command and press enter. You will be presented with options to create, remove, display partition information options.
4.Most common file operations in Dos:
Erase
The command is used to delete specific files. The command is erase filename
Rename
The command is used to rename files.To rename a file in dos you can write command like this:
C>ren d:myfile.txt brotherfile.txt. Here I changed the name of myfile.txt in drive D to brotherfile.txt.
Copy
The copy command can be used to copy files.Look at this example.
C> copy c:myfile d:
What this command does is that it copies “myfile” which is located in C drive to D drive.

5.Network Operations with DOS:
Dos contains a lot of powerful networking tools that help you to anlayze networks, check connections, communicate with other computers etc.
Pinging with Dos
Ping can be used to find if a computer is online or not. So the command is just like this ping argument where argument may be a domain name or numeric address of the compute to be pinged.
We can use ping like this:
ping http://www.google.com

What ping does is that it sends your request to a computer specified and waits for its response for some time. Just look at this screen shot.

Tracert
The command tracert can be used to indentify the number of computers or hops between a source and destination. Just type in traceroute ipaddress to identify how many hops away is your source. You can also use it along with a swith -h in the following format:
tarcert -h 132.124.123.21

Telnet
The command telnet will allow you to start a telnet session. Type in “?\” to see the possible commands you can use with telnet.

Netstat
Netstat
is used to know the current status of your internet connection. Type netstat and press Enter. This will display active connections, tcp ,udp ports, and their status.

Ipconfig
Displays your ip configuration settings. ipconfig [/? | /all | /release [adapter] | /renew [adapter] | /flushdns | /registerdns | /showclassid adapter | /setclassid adapter [classidtoset] ] adapter Full name or pattern with ‘*’ and ‘?’ to ‘match’, * matches any character, ? matches one character. Options /all Display full configuration information. /release Release the IP address for the specified adapter. /renew Renew 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. /showclassid Displays all the dhcp class IDs allowed for adapter. /setclassid Modifies the dhcp class id. The default is to display only the IP address, subnet mask and default gateway for each adapter bound to TCP/IP. For Release and Renew, if no adapter name is specified, then the IP address leases for all adapters bound to TCP/IP will be released or renewed. For SetClassID, if no class id is specified, then the classid is removed.

Examples: C:> ipconfig … Show information. > ipconfig /all … Show detailed information > ipconfig /renew … renew all adapaters > ipconfig /renew EL* … renew adapters named EL…. > ipconfig /release *ELINK?21* … release all matching adapters, eg. ELINK-21, myELELINKi21adapter.

Route
It is used to manipulate network routing tables.
ROUTE [-f] [-p] [command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]

-f Clears the routing tables of all gateway entries. If this is used in conjunction with one of the commands, the tables are cleared prior to running the command.
-p
When used with the ADD command, makes a route persistent across boots of the system. By default, routes are not preserved when the system is restarted. Ignored for all other commands, which always affect the appropriate persistent routes. This option is not supported in Windows 95.

PRINT Prints a route
ADD
Adds a route
DELETE
Deletes a route
CHANGE
Modifies an existing route
destination
Specifies the host.
MASK
Specifies that the next parameter is the ‘netmask’ value.
netmask Specifies a subnet mask value for this route entry.
If not specified, it defaults to 255.255.255.255.
gateway Specifies gateway.
interface the interface number for the specified route.
METRIC
specifies the metric, ie. cost for the destination.

6.Mathematical operations in DOS:
You can use DOS to do mathematical calculations.
C:\>set /a 1+1
2
C:\>set /a 5*(3/2)
5
C:\>set /a (4*10)/5
8
C:\>set /a “46>>7”
0
There are a lot of commands that remain to be mentioned. But this is a starter guide and I hope this will help you understand DOS.

No comments yet

Leave a comment