DOS Basics - A Tutorial
 



This tutorial gives you an opportunity to try basic MS-DOS commands. By following the procedures in this section, you will learn to:




    • View the contents of a divectory
    • Change from one divectory to another
    • Create and delete divectories
    • Change from one drive to another
    • Copy files
    • Rename files
    • Delete files
    • Format a floppy disk


If you are on Windows XP
Click Start > Run > type  cmd and press Enter to get dos command prompt


You can type commands at the prompt in DOS


Help
Give list of DOS commands and what they do


Help dir 
Provide detail help on 'dir' command


Syntax
Syntax is how you can use commands
[ ] denotes that its an option
[ ] [ ] can be combined


HELP [/B] [/G] [/H] [/NOHI] [topic]


topic Specifies the help topic to view.
/B Allows use of a monochrome monitor with a color graphics card.
/H Displays the maximum number of lines possible for your hardware.


Usage
Help
Help dir
Help /B


----------------
MD
Allows you to create your own directories


md test


The above example creates the "test" directory in the directory you are currently in.


md c:\test


Create the "test" directory in the c:\ directory.



------------


Navigating in your drives/directories done with CD command


C:
Goes to drive C


D:
Goes to drive D



cd\


Goes to the highest level, the root of the drive.


cd..


Goes back one directory up.
For example, if you are within the C:\Windows\ directory, this would take you to C:\



cd windows


If present, would take you into the Windows directory. Windows can be substituted with any other name.


cd\windows


If present, would first move back to the root of the drive and then go into the Windows directory.


cd\windows\system32


If present, would move into the system32 directory located in the Windows directory.


---------------------------------------------------------------------------------------------------------------------


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.


dir \ /s |find "i" |more
A nice command to list all directories on the hard drive, one screen page at a time, and see the number of files in each directory and the amount of space each occupies.


dir > myfile.txt


Takes the output of dir and re-routes it to the file myfile.txt instead of outputting it to the screen.


edit myfie.txt
edits myfile.txt


------------------------------------------
Copy
Allows the user to copy one or more files to an alternate location.


copy *.* a:
Copy all files in the current directory to the floppy disk drive.


copy autoexec.bat c:\windows


Copy the autoexec.bat, usually found at root, and copy it into the windows directory; the autoexec.bat can be substituted for any file(s).


copy win.ini c:\windows /y


Copy the win.ini file in the current directory to the windows directory.
(Because this file already exists in the windows directory it normally would prompt if you wish to overwrite the file. However, with the /y switch you will not receive any prompt.)


---------------------------------------
Del is a command used to delete files from the computer.


Keep in mind that deleting files from DOS does not send files to the recycle bin.


del test.tmp = Deletes the test.tmp in the directory that you currently are in, if the file exists.
del c:\windows\test.tmp = Delete the c:\windows\test.tmp in the windows directory if it exists.
del c:\windows\temp\*.* = (* is for wild character(s)) *.* indicates that you would like to delete all files in the c:\windows\temp directory.
del c:\windows\temp\?est.tmp = (? is a single wild character for one letter)
This command would delete any file ending with est.tmp such as pest.tmp or zest.tmp...


del c:\windows\temp\*.tmp = (* is a single wild character for any number of letters)
deletes all .tmp files


--------------------------


Edit
Edit allows a user to view, create, and/or modify their computer files.


edit myfile.txt
edits myfile.txt


--------------------------
Move
Allows you to move files or directories from one folder to another, or from one drive to another.


move c:\windows\temp\*.* c:\temp


Move the files of c:\windows\temp to the temp directory in root, this is of course assuming you have the windows\temp directory.


move c:\temp\*.* c:\windows\temp


---------------------------------------------


ren and rename


Used to rename files and directories from the original name to a new name.
rename c:\chope hope 


Rename the directory chope to hope.


rename *.txt *.bak


Rename all text files to files with .bak extension.


rename * 1_*


Rename all files to begin with 1_.
The asterisk (*) in this example is an example of a wild character; because nothing was placed before or after the first asterisk, this means all files in the current directory will be renamed with a 1_ in front of the file. For example, if there was a file named hope.txt it would be renamed to 1_pe.txt.


--------------------------
deltree


Short for delete tree, deltree is a command used to delete files and directories permanently from the computer.


-------------------------
Cls is a command that allows a user to clear the complete contents of the screen and leave only a prompt.


-------------------
Format
Format is used to erase all of the information off of a computer diskette or fixed drive.


format a:


Would erase all the contents off a disk. Commonly used on a diskette that has not been formatted or on a diskette you wish to erase.


format a: /q


Quickly erases all the contents of a floppy diskette. Commonly used to quickly erase all information on the diskette.


format c:


This would erase all the contents of your C: hard disk drive. In other words, unless you wish to erase all your computer's information, this command should not be done unless you're planning to start over.
---------------
Xcopy


Xcopy is a powerful version of the copy command with additional features; has the capability of moving files, directories, and even whole drives from one location to another.
----------------
Date
The date command can be used to look at the current date of the computer as well as change the date to an alternate date.


----------
Doskey is a MS-DOS utility that allows a user to keep a history of commands used on the computer.


-----------
Exit
The exit command is used to withdrawal from the currently running application and/or the MS-DOS session.
-----------
prompt
Allows you to change the MS-DOS prompt to display more or less information.


prompt $t  $d$_$p$g


Display the time and the date above your prompt when in DOS.
----------------
scandisk


Scandisk is a utility capable of checking the hard disk drive and/or floppy diskette drive for any disk errors.


scandisk c: /autofix
--------------


undelete


Allows you to restore files that may have been deleted.


--------------------
type


Allows the user to see the contents of a file.


To edit the files, the user would need to use either edit or copy con.


---------------
edit myfile.txt
------------------
tree


Allows the user to view a listing of files and folders in an easy to read listing.
tree


ver


Displays the version of DOS


-------------------
Vol
Displays the disk volume label and serial number, if they exist.


VOL C:
------------


rd / rmdir


Removes empty directories in MS-DOS. To delete directories with files or directories


rmdir c:\test


Remove the test directory, if empty. If you want to delete directories that are full, use the deltree command


-------
netsh


DOS command that enables users to change network settings such as changing their network device from a dynamic address to a static address or changing the IP address.


--------------
nslookup


DOS utility that enables a user to look up an IP address of a domain or host on a network.


----------
boot disk?


A boot disk will allow you to boot off of a diskette instead of your hard drive. This diskette can be used to fix issues that may arise during the lifetime of your computer and/or to help load older DOS games.



About the autoexec and config


The autoexec.bat and the config.sys were files created for MS-DOS and Windows 3.x as an easy solution of loading the files required for various devices as well as the operating system to properly run. These files are required for later revisions of MS-DOS and Windows 3.x to load. These files are not required for Windows 95, Windows 98, Windows NT, Windows ME, Windows 2000, Windows XP, or later operating systems.


--------


net use z: \\computer\folder


Map the Z: drive to the network path //computer/folder.


net send mrhope "There is hope!"


Send a text message to the computer with a host name of mrhope the message There is hope!. Note: This command only works for Windows versions that support this command.


Note: Many computers today have also disabled the messenger service, if this service is disabled you will be unable to send/receive net send messages. Additional information about how this service is disabled can be found on document CH0000519. If you need this service enabled, follow the instructions on this page and choose to enable the service instead of disabling it.


net send * "There is hope!"


The above command would send There is hope! to all users in your current domain. This command should be used with caution since if you're on a school or work network many of the computers on that network if not all well be sent a message if the messenger service is enabled on the computers.


net config workstation


Display additional information about the network such as the computers name, workgroup, logon domain, DNS, and other useful information.


net view \\hope


View the available computers and their shared resources you may use either of the below commands. The first example displays available computers. The last command would display the shared resources on the hope computer.


net localgroup


Display all groups currently setup on the computer you're running the command on.


net share


Display all network shares on your computer.


net share hope=c:\hope\files


Create a share called "hope" for the "c:\hope\files" directory.



------------------------
PING
Helps in determining TCP/IP Networks IP address as well as determine issues with the network and assists in resolving them.


ping localhost


Pings the local host, this will allow you to see if the computer is able to send information out and receive the information back. Note that this does not send information over a network but may allow you to see if the card is being seen.


ping xxx.xxx.xxx.xxx


Allows you to ping another computer where the x's are located are where you would place the IP address of the computer you are attempting to ping. If this is not able to complete, this should relay back an unsuccessful message, which could be an indication of cable issues, network card issues, hub issue, etc.


ping google.com



Pinging google.com [209.85.153.104] with 32 bytes of data:


Reply from 209.85.153.104: bytes=32 time=47ms TTL=54
Reply from 209.85.153.104: bytes=32 time=45ms TTL=54
Reply from 209.85.153.104: bytes=32 time=44ms TTL=54
Reply from 209.85.153.104: bytes=32 time=46ms TTL=54


Ping statistics for 209.85.153.104:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 44ms, Maximum = 47ms, Average = 45ms



-------------------
Ipconfig


Ipconfig is a DOS utility that can be used from MS-DOS and a MS-DOS shell to display the network settings currently assigned and given by a network. This command can be utilized to verify a network connection as well as to verify your network settings.


ipconfig


Ethernet adapter Local Area Connection:


Connection-specific DNS Suffix . : hsd1.ut.comcast.net.
IP Address. . . . . . . . . . . . : 192.168.201.245
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.201.1


ipconfig /all
Show all network related information


ipconfig /displaydns
Running the above command would display all the DNS information.


ipconfig /flushdns
Deletes all DNS entries.



----------------
tracert


The tracert command is used to visually see a network packet being sent and received and the amount of hops required for that packet to get to its destination.



tracert google.com
-
route
Command to manually configure the routes in the routing table.


route PRINT


------------


telnet


Enables a user to telnet to another computer from the command prompt.


telnet myhost.com
-------------------------


nbtstat


MS-DOS utility that displays protocol statistics and current TCP/IP connections
-----------
nslookup 204.228.150.3
-


map


The map command is a recovery console command that displays the physical device name of a drive letter.


 

(c) Shilpa Sayura Foundation 2006-2017