OS Lab 1
OS Lab 1
LAB # 1
BS IT (Part-III)
SENG- 529 Operating Systems
DOS COMMAND
DIR /A: Suppose you want to display all files and directories in a directory, including hidden or system
files. To specify this display, type the following command:
DATE: Prints and Sets the date you specify. Values for day, month, and year must be separated by periods
(.), hyphens (-), or slash marks (/).
TIME: Display and set your computer's clock
PROMPT: displays typed messages on command prompt the following command displays a two-line prompt
in which the current time appears on the first line and the current date appears on the second line:
prompt time is: $t$_date is: $d
COLOR: used to change background color and fore color of the command prompt type: color 17
First value is for background color second is for font color
COPY: The following command copies a file and ensures that an end -of-file character is at the end of the
copied
file: copy memo.doc letter.doc
To copy the NOTE.TXT file from the current drive and directory to the directory MYNOTES, and
to prevent MS-DOS from prompting you before overwriting the destination file (if it already
exists), type the following command: copy note.txt mynotes /y
To copy a file named ROBIN.TYP from the current drive and directory to an existing directory
named
BIRDS that is located on drive C, type the following command: copy robin.typ c:\birds
If the BIRDS directory doesn't exist, MS-DOS copies the file ROBIN.TYP into a file named
BIRDS that is located in the root directory on the disk in drive C.
To copy several files into one file, list any number of files as source parameters on the COPY
command line. Separate filenames with a plus sign (+) and specify a filename for the resulting
combined file, as the following example shows: copy mar89.rpt + apr89.rpt + may89.rpt
report
DEPARTMENT OF INFORMATION TECHNOLOGY
FACULTY OF ENGINEERING AND TECHNOLOGY
UNIVERSITY OF SINDH, JAMSHORO
This command combines the files named MAR89.RPT, APR89.RPT, and MAY89.RPT from the
current drive and directory and places them in a file named REPORT in the current directory on the
current drive. When files are combined, the destination file is created with the current date and time.
If you omit destination, MS-DOS combines the files and stores them under the name o f the first
specified file. For example, if a file named REPORT already exists, you can use the following
command to combine all four files in REPORT: copy report + mar89.rpt + apr89.rpt +
may89.rpt
You can also combine several files into one by using wildcards, as the following example shows:
copy *.txt combin.doc
The following COPY command copies what you type at the keyboard to the OUTPUT.TXT file:
copy con output.txt
After you type this command and press ENTER, MS-DOS copies everything you type to the file
OUTPUT.TXT. When you are finished typing, press CTRL+Z to indicate that you want to end the
file. The CTRL+Z character will appear on the screen as "Z". You can also end a COPY CON
command by pressing the F6 key. When you press F6, it generates the CTRL+Z character, wh ich
appears on the screen as Z. The following example copies information from the keyboard to the
printer connected to LPT1: copy con lpt1
REN : used to rename file or change its extension Suppose you want to change the extensions of all the
filenames in the current directory that have the extension .TXT; for example, suppose you want to
change the .TXT extensions to .DOC extensions. Tomake this change, type the following command:
ren *.txt *.doc
To rename a file named CHAP10 (on drive B) to PART10, type the following command:
ren b:chap10 part10
DEL: To delete the CAT.TMP file from the TEST directory on drive C, you can use either of the
following
commands:
del c:\test\cat.tmp
erase c:\test\cat.tmp
To delete all the files in a directory named TEST on drive C, you can use either of the following
commands:
del c:\test
del c:\test\*.*
UNDELETE: The following command specifies that UNDELETE is to recover all deleted files in the current
directory one at a time, to prompt for confirmation on each file, and to use the highest available
level of delete tracking:
undelete
DEPARTMENT OF INFORMATION TECHNOLOGY
FACULTY OF ENGINEERING AND TECHNOLOGY
UNIVERSITY OF SINDH, JAMSHORO
The following command specifies that UNDELETE is to recover all deleted files with the .TXT
extension in the root directory of drive C, without prompting for confirmation on each file:
undelete c:\*.txt /all
Undelete: The following command loads the memory-resident portion of the UNDELETE program into
memory, creates a hidden directory named SENTRY, and specifies that UNDELETE move files
you delete on drive C to that directory:
undelete /sc
mkdir: Suppose you want to create a directory on the dis k in the current drive and use the directory to
store all your tax information. To create a directory named TAXES, type the following command:
mkdir \taxes or md \taxes
Copy: If you are working on drive D and you want to copy all files in the \PUBLIC\JONES directory on
drive C to the root directory on drive D, type the following commands:
cd c:\public\jones
copy c:*.* d:\
Tree : To display the names of all the subdirectories on the disk in your current drive, type the following
command:
tree \
To display, one screen at a time, the files in all the directories on drive C, type the following
command:
tree c:\ /f | more
Move: Suppose C:\LETTERS is a directory. To move the files ED.TXT and SIGRID.TXT from
the current
directory to the LETTERS directory on drive C, type the following at the command prompt:
move ed.txt, sigrid.txt c:\letters
To move the BILL.TXT file from the current directory to the LETTERS directory on drive C and
rename it
ANN.TXT, type the following at the command prompt:
move bill.txt c:\letters\ann.txt
Chkdsk: To find out how much data is stored on drive C and how much space is still free, and to check the
disk for errors, type the following command:
chkdsk c:
CHKDSK pauses and displays messages if it encounters errors.
To redirect the output of CHKDSK to a file named STATUS, type the following command:
chkdsk a: > status
Unformate : To determine whether UNFORMAT can restore a formatted disk in drive A, type the following
command:
unformat a: /test
DEPARTMENT OF INFORMATION TECHNOLOGY
FACULTY OF ENGINEERING AND TECHNOLOGY
UNIVERSITY OF SINDH, JAMSHORO
Attrib: To display the attributes of a file named NEWS86 located on the current drive, type the following
command:
attrib news86
To assign the Read-Only attribute to the file REPORT.TXT, type the following command:
attrib +r report.txt
To remove the Read-Only attribute from files in the \PUBLIC\JONES directory on a disk in drive
B and from files in any subdirectories of \PUBLIC\JONES, type the following command:
attrib -r b:\public\jones\*.*
XCOPY The following example copies all the files and subdirectories (including any empty subdirectories)
from the disk in drive A to the disk in drive B:
xcopy a: b: /s /e
Sys: To copy the MS-DOS system files and command interpreter from the disk in the current
drive to a disk in drive A, type the following command:
sys a: