You are on page 1of 6

Introduction to Computing Operating System Shell/Commands

Lab-12 Introduction to DOS

Pathname
Pathname is a reference to identify a file within the directory structure. For example the following file name indicates the file in the hierarchy of directories: C:\users\ali\letters\pay The C:\ indicates the drive is C, move down to users, then ali, then letters and finally to the file. So this pathname is reference to the file pay with respect to the root directory. A path may be of two types.

Absolute Pathname
The pathname, which identifies a file or a directory irrespective of the current state of the user. The user's "current directory" is part of the user's state. The absolute pathname always starts from the root directory or the drive letter (C or D etc.). For example, to locate file any file in lib directory, the absolute path of the file is: C:\usr\local\lib\filename

Relative pathname
The pathname, which identifies a file or a directory in a way that depends on the state of the user i.e. users current directory. Relative pathname identifies files with respect to user current directory. Consider the following diagram.

Current Directory (Working Directory)

thesis chapter4.tex

To refer a file chapter4.tex in the in the subdirectory thesis with respect to the current directory, we use pathname. thesis/chepter4.tex

DOS Commands:
Color It changes the color of console background and foreground Syntax: Example: C:\>COLOR <attr> C:\>color FC

Introduction to Computing Operating System Shell/Commands

Lab-12 Introduction to DOS

Color attributes are specified by TWO hex digits -- the first corresponds to the background; the second the foreground. Each digit can be any of the following values: 0 = Black 1 = Blue 2 = Green 3 = Aqua 4 = Red 5 = Purple 6 = Yellow 7 = White 8 = Gray 9 = Light Blue A = Light Green B = Light Aqua C = Light Red D = Light Purple E = Light Yellow F = Bright White

Copy It copy one or more files to the location specified & can also be used to combine. Syntax: Example: C:\> COPY <source> <target> C:\> COPY C:\Users\Riphah\Myfile.txt D:\Itc_lab_12 C:\Users\Riphah\> COPY Myfile.txt D:\Itc_lab_12

or

MOVE it moves a file from source to destination. The destination can specify a new file name, and also means a change of name. MOVE essentially means copying and deleting the source file. The syntax is almost the same as the copy: Syntax: Example: C:\>MOVE <source> <target> C:\>MOVE C:\Users\Riphah\Myfile.txt D:\Itc_lab_12 C:\Users\Riphah\>MOVE Myfile.txt D:\Itc_lab_12 or

Del It deletes the files specified. Syntax: Example: C:\>del <drive:> <path> <filename> C:\>DEL D:\Itc_lab_12\Myfile.txt D:\Itc_lab_12\>DEL Myfile.txt

or

Prompt It chanes the appearance of the command prompt or displays the current prompt. Syntax: Example: C:\>prompt <text> C:\> prompt mydos It will change the C:\> to mydos Type It displays the contents of a text file or view the contents of any text file without modifying it. Syntax: C:\>type <drive:> <path> <filename> Example: D:\Itc_lab_12\>Type Myfile.txt

Introduction to Computing Operating System Shell/Commands

Lab-12 Introduction to DOS

Externel Commands
Note: in case an external command does not exist an error message will be displayed for example;

Xcopy It is a powerful version of the copy command with additional features. It has the ability to move files, directories and even whole drives from one destination to another. It also can preserve file attributes and long file names. Syntax: XCOPY <source> <destination>

/P Prompts you before creating each destination file. /S Copies directories and subdirectories except empty ones. /E Copies directories and subdirectories, including empty ones. /W Prompts you to press a key before copying. /C Continues copying even if errors occur. /I If destination does not exist and copying more than one file, assumes that destination must be a directory. /F Displays full source and destination file names while copying. /L Displays files that would be copied. /H Copies hidden and system files also. /R Overwrites read-only files. /U Updates the files that already exist in destination. /Y Overwrites existing files without prompting. /-Y Prompts you before overwriting existing files. C:\>xcopy h:\*.* /a /e /k Copies everything located on the H drive to the current drive.

Examples:

C:\>xcopy c:\windows c:\desktop /a /e /f /h /k Copies all files and folders in the C:\Windows folder to the C:\Desktop folder.

Introduction to Computing Operating System Shell/Commands

Lab-12 Introduction to DOS

Attrib It lets you display or alter the attributes assigned to a file or directory. Syntax: C:\>attrib <+A/-A><+H/-H><+R/-R><+S/-S> +A: - add archive attributes -A: - remove archive attribute +H : - add hidden attributes -H: - remove hidden attribute +R: - add read-only attributes -R: - remove read-only attribute +S: - add system attributes -S: - remove system attribute Example: D:\Itc_lab_12\>attrib Myfile.txt display current attribute of file D:\Itc_lab_12\>attrib Myfile.txt +r +h D:\Itc_lab_12\>attrib Myfile.txt -h

Chkdsk It checks a disks file allocation table entries for errors & find whether the files are o.k. or not. Syntax: C:\>chkdsk <d:> <path> <filename> Example: D:\Itc_lab_12\>chkdsk Myfile.txt D:\Itc_lab_12\>chkdsk C: Format It creates a new directory & file allocation table for the disk. Syntax: Example: C:\>format <drive name> C:\>format A:

Scandisk It checks a drive for errors and corrects any problems that it finds. Syntax: Example: C:\> scandisk <drive name> C:\>scandisk D:

Tree The structure of the specified drive from the specified directory down, listing all the subdirectories it encounters is displayed graphically. Syntax: Example: C:\>tree <drive name> C:\>tree C:

Introduction to Computing Operating System Shell/Commands

Lab-12 Introduction to DOS

Deltree It deletes a directory and all the files and sub-directories contained within it. Syntax: Example: C:\>deltree <drive><path> C:\>deltree A:

Print It prints a text file. Syntax: Example: C:\>print <filename> C:\>print myfile.txt

Label It lets you create, modify or delete the label assigned to a disk. Syntax: Example: C:\>label <drive name> D:\>label university

Getmac It Returns the media access control (MAC) address and list of network protocols associated with each address for all network cards in each computer, either locally or across a network. Syntax: C:\>getmac Ping It Test / send information to another network computer or network device. Syntax: Example: C:\>ping <host address> C:\>ping www.google.com

Ipconfig It displays all your IP information for all adapters. With ipconfig /all you can also find out your DNS Server and MAC Address. Syntax: Example: C:\>ipconfig <attr> C:\>ipconfig /all C:\>ipconfig /displaydns

Introduction to Computing Operating System Shell/Commands

Lab-12 Introduction to DOS

Lab Task/Activity:
(Note: You need to implement the following tasks and write the commands on notebook as well.)
1. You are required to create two directories namely directory1 and directory2. 2. Create a file called project.txt inside directory1. 3. Rename the directory1 you just created to ITC. (Note: If the directory already exists you have to delete it first). 4. Hide the directory ITC. 5. Now unhide ITC. 6. Now copy the file project.txt into directory2. 7. Delete the directory ITC. 8. Write the IP address and mac address of your computer on your notebook using appropriate commands.

Mr. Uzair Muhammad Lab Instructor, Faculty of Computing, Riphah International University email: uzair.muhammad@riphah.edu.pk Teaching Assistants: Zeeshan Bin Iqbal, Zia Ur Rehman

You might also like