1
TOPIC 1
DISK OPERATING SYSTEM (DOS)
LEARNING OUTCOME
At the end of the topic, students will be able to:
1. understand some basic commands in DOS using Command Shell and PowerShell
2. differentiate between GUI and command-line approaches
CONTENT
1.1. Introduction
DOS stands for Disk Operating System was the first commercial operating system developed by Microsoft. This operating system comes in package with the new Windows operating systems for troubleshooting and as a failover mechanism for Windows.
1.2. Windows Command Shell
The Command shell was the first shell built into Windows to automate routine tasks, for example user account management or nightly backups. With Windows Script Host, more sophisticated scripts could be run in the Command shell.
Windows has two command shells: The Command shell and PowerShell.
Similarities between the two shells are: each shell is a software program that
provides direct communication between users and the operating system or
application, and providing an environment to automate IT operations.
2 Differences between the two shells are:
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets provide a more extensible scripting language than Windows commands.
Windows Commands and PowerShell cmdlets can be run in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
1.3. Common DOS Commands
To access the Windows command prompt in Windows 8 and 10, navigate to the Start screen and type Command Prompt. Click Command Prompt.
In Windows 7, click Start and type Command Prompt in the Search programs and files field. Click Command Prompt to continue.
Figure 1.3 Example of a command prompt screen
At the command prompt, type
helpand press Enter. A list of commands is displayed. For more information on a specific command, type the command followed by
/?. Example:
date /?Next section presents some common DOS commands.
3 1.3.1. Create and Change Directory
1. Type
cdat the command prompt to displays the current directory. The current directory is different to each workstation. Write your current directory.
2. Type
dirto list the files and folders that is in the current directory.
3. In the current directory, use the
mdcommand to create three new folders:
OS1, OS2, and OS3. Type md OS1 and press Enter. Repeat the step for OS2 and OS3.
4. Command
dircan be used to verify the success of creating the folders.
Type
dirto verify the folders have been created. Show the screenshot of the output.
5. Type
cd OS3at the command prompt and press Enter. Has the current directory changed? Write your directory.
6. Type
cd ..to change the current directory. What is your directory now?
Remark: Each
..is a shortcut to move up one level in the directory tree.
<Screenshot>
4 1.3.2. Create text files
1. Navigate to the OS1 directory.
2. Type
echo I love Operating Systems > doc1.txtat the command prompt.
echo: to display a message at the command prompt.
>: to redirect the message from the screen to a file.
For example, in the first line, the message
I love Operating Systemsis redirected into a new file named
doc1.txt.
3. Use the
echocommand to create these files:
doc2.txt, file1.txt, and
file2.txt
by using the same message
I love Operating Systems.
4. Use the
dircommand to verify the files are in the OS1 folder. Show the screenshot of the output.
1.3.3. Move, copy and delete files
1. Navigate to the OS1 directory.
2. Type
move doc2.txt C:\<your directory path>\OS2to move the file
doc2.txtto the OS2 directory.
<Screenshot>
5
3. Type
cd C:\<your directory path>\OS2to change the directory to OS2.
Verify that
doc2.txthas been moved using the
dircommand.
4. Type
copy doc2.txt doc2_copy.txtto create a copy of
doc2.txt.
5. Now use the move command to move
doc2_copy.txtto OS1. Type
move doc2_copy.txt ..\OS1.
6. Change the current directory to OS1. Type
cd ..\OS1at the prompt.
7. Move
file1.txtand
file2.txtinto OS3. To move all the files that contain the word file into OS3 with one command, use a wildcard (
*) character to represent one or more characters. Type move
file*.txt ..\OS3.
8. Now delete
doc2_copy.txtfrom the OS1 directory. Type
del doc2_copy.txt.9. Write the current files in the OS1, OS2, and OS3 directory.
Directory OS1 OS2 OS3
Current files
1.4. Common PowerShell Commands
In Windows 10, from the taskbar, in the search text field, type powershell.
Then, click or tap the ‘Windows PowerShell’ result.
In Windows 7, click Start and type powershell in the Search programs and files field. Click Windows PowerShell to continue.
To run PowerShell as administrator, right-click (touchscreen users: tap and
hold) on the Windows PowerShell search result, then click or tap ‘Run as
administrator’.
6
Figure 1.4 Example of a Windows PowerShell screen
1.4.1 File system directory
1. Type
dirat the prompt. Is the output similar to the Command Shell output? Write the difference is the answer is NO.
2. Type
Get-ChildItemat the prompt. Is the output similar to the step (1)?
Write the difference is the answer is NO.
3. In PowerShell, when you run the
DIRcommand, you are really running the
Get-ChildItem
cmdlet.
4. By default Get-ChildItem lists the mode (Attributes), LastWriteTime, file size (Length), and the Name of the item. Attributes in the Mode property are as follows:
Mode Description l link
d directory a archive r read-only h hidden s system
A cmdlet -- pronounced command-let -- is a small, lightweight command that is used in the Windows PowerShell environment.
7
5. Type Get-Location at the prompt to display the current working directory.
6. Type
Set-Location –Path “<directory path>:\”cmdlet to sets the current working directory to a specified directory.
Example:
Set-Location –Path “D:\”– this command sets the current directory to the D directory.
1.4.2 List active processes on a computer
1. Type cmdlet
Get-Processto display all active processes on a local computer.
2. To get data about a process, use
ProcessNameor
Idparameter to the
Get-Process
cmdlet.
Figure 1.4.2. Example of Get-Process cmdlet output
1.4.3. Create a directory and files
1. Sets your preferred working directory using the
Set-Locationcmdlet.
2.
New-Itemis the cmdlet to create directories and files.
3. To create a directory:
New-Item -Path "<directory path>" -Name "<directory name>"
-ItemType "directory"
Example:
New-Item -Path "D:\" -Name "OSShell" -ItemType "directory"
8 4. To create a file:
1.4.4. Set and display file content
1.
Set-Contentis the cmdlet to write new content or replace the existing content.
2. Use
Add-Contentcmdlet to append a value to text files.
3.
Get-Contentis the cmdlet to display content at the specified file.
New-Item -Path “<directory path>” -Name "<file name>.<file format>" -ItemType "file"
Example:
New-Item –Path “D:\OSShell” -Name "fileOS1.txt" -ItemType
"file"
Set-Content -Path .\<file name>.<file format> -Value '<type the value>'
Remark: . represents the current directory. You can use . as a shortcut rather than write the full current directory path.
Example:
Set-Content -Path .\fileOS1.txt -Value 'I love operating systems'
Add-Content -Path .\<file name>.<file format> -Value 'type the value'
Example:
Add-Content -Path .\fileOS1.txt -Value 'I love Universiti Tun Hussein Onn Malaysia'
Get-Content -Path .\<file name>.<file format>
Example:
Get-Content -Path .\fileOS1.txt
9 1.4.5. Delete items
The
Remove-Itemcmdlet deletes one or more items. The cmdlet can be used to delete many different types of items, including files, folders, registry keys, variables, aliases, and functions.
Remove-Item <directory path>
Example:
Remove-Item D:\OSShell\fileOS1.txt OR Remove-Item .\fileOS1.txt
10
TOPIC 1: DISK OPERATING SYSTEM (DOS) Activity 1
Name : ………
Matric Number : ………..
Instruction: Please detach this activity page(s) from the booklet and attach as a cover for your answer sheets.
1. In order to better understanding of DOS, you are required to define what are:
a) Syntax:
b) Paths
c) Command line interface d) Batch files
2. Using the
helpcommand in a Command Shell, differentiate the following commands:
a)
COPYand
XCOPYb)
ERASEand
RMDIR3. Do the following steps using the Windows Powershell. Show the screenshot for each of the step.
a) Create a new directory
MyOS.
b) Set the current directory location to the
MyOS.
c) Create two text files:
OSText1.txtand
OSText2.txt.
d) Insert the following values to the
OSText1.txt. The values must be in separate five lines.
Tips for taking online classes Part 1
1. Treat an online course like a real course.
2. Hold yourself accountable 3. Practice time management.
4. Create a regular study space and stay organized.
11
e) Insert the following values to the
OSText2.txt. The values must be in separate five lines.
f) Display the content from
OSText1.txt. g) Display the content from
OSText2.txt.
h) Identify the use of
TotalCountparameter with the
Get-Contentcmdlet to display the first 3 lines from both of the text files.
Tips for taking online classes Part 2 1. Eliminate distractions.
2. Figure out How You Learn Best 3. Actively participate.
4. Leverage your network.