Sunday, May 3, 2009

Basic DOS Commands




Learning operating system mainly refers to study of th use of an operating system. for this purpose, we need to learn various commands required for getting done activities from an operating system. now learn some basic commands used in MS-DOS.
  • Display the directory
If you want to know what files are on your disk, you can use the dir command. This command tells MS-DOS to dis play all the files in the working directory on a specific disk. If you in drive c and you want to see the drive d for the working directory on that disk, type dir D:
Note
Try , dir/p
dir/w
  • Searching for files
Two special characters, the asterisk (*) and the question mark (?) are called wildcards They can be used when you are searcing for files on a disk. Those symbols refers to as any character, depanding on the place where they are used in the file name
Search word documents – dir*.doc
Search word documents begin with A – dir a*.doc
Search .doc second letter is A – dir ?a*.doc
Search folder and file – dir *.*
Search only folder – dir *.
  • Creating s directory
To create a subdirectory in your working directory, use the mkdir or md command. To create a new directory named newfolder under your working directory, type Mkdir newfolder or md newfolder
  • Displaying Working Directory
All commands are exected while you are in your working directory. you can find out the name of the directory you are in by issuing the MS-DOS command chdir(change directory) or cd.
  • Changing your working directory
Changing from your working directory to another directory is very easy in MS-DOS Simply type the chdir or cd command and then a pathname.for example type, Chdir \ or cd \
Always puts you in the parent directory of your working directory
chdir.. or cd..
  • Copy Files

The copy command is a powerful command that allows you to make a copy of a file with different file name. This command takes two parameters, (remember that parameters are separated by spaces), the original file name and the new file name. For example, type copy myfile.txt myfile2.txt and press enter. What this does is takes the contents of myfile.txt and copies it into another file named myfile2.txt. They are the exact same except for the file names

  • Deleting a Directory

To delete a directory in the structure, use the MS-DOS rmdir(remove directory) or rd command. to remove the newfolder directory from the working directory,type rmdir newfolder or rd newfolder.

the newfolder directory must be empty except for the and entries before it can be removed. this prevents you from accidentally deleting files and directory. you can delete any directory by specifying its pathname. to remove the newfolder\test.txt directory, make sure that it has only , then type rmdir newfolder\test.txt or rd newfolder\test.txt

to remove the select files in a directory, erase *.* or del*.*

  • Renaming a directory

Renames a file. Unlike the move command, this command cannot be used to rename subdirectories, or rename files across drives. you want to test1.txt rename test2.txt, type

ren test1.txt test2.txt

  • commands
  • date - display date
  • time - display time
  • prompt test - display only test
  • prompt $d - display only date
  • prompt $t - display only time
  • prompt $p$g - display working drive
  • cls - clear dos command prompt