Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views33 pages

OS Practicals

The document provides a comprehensive guide on setting up virtual machines using VirtualBox, including the installation of Windows and Linux operating systems. It details step-by-step procedures for creating virtual machines, configuring settings, and performing basic operations using command-line interfaces in both Windows and Linux environments. Additionally, it covers essential commands for file management, system information, and using the vi editor in Linux.

Uploaded by

Lee Sue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views33 pages

OS Practicals

The document provides a comprehensive guide on setting up virtual machines using VirtualBox, including the installation of Windows and Linux operating systems. It details step-by-step procedures for creating virtual machines, configuring settings, and performing basic operations using command-line interfaces in both Windows and Linux environments. Additionally, it covers essential commands for file management, system information, and using the vi editor in Linux.

Uploaded by

Lee Sue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

PRACTICAL 1

Virtual Machine Setup and Installation


a. Installation of Virtual Machine Software
Downloading and Installing VirtualBox
To download VirtualBox, go to the official site virtualbox.org and download the latest version
for windows.
Beginning with the Installation:
• Getting Started:

Select Installation Location:


Creating Entries and Shortcuts: select multiple images in word

Ready to Install:

Installing Files and packages:


Installing Certificates:

Finished Installation:

When you will open virtualbox it will look like as shown below:
b. Installation of Windows OS on a VM
Step 1: After opening Oracle VM VirtualBox, you can start the VM wizard. To do this, you can
go to the Machine menu from the user interface. You can also click on the New option under
the menu. However, you can also click on the New button in the section with the large icons.

Step 2: In the virtual machine wizard, you should write the system name in the Name
section. Also, the Type and Version sections will be set automatically. These settings are
determined according to the platform you write.
Write “Windows 10” in the Name section. Also, select your external SSD, HDD, or host disk in
the Folder section. New-generation computers usually have NVMe drives. This significantly
increases VM performance.

Step 3: To add the Windows 10 22H2 ISO file to the virtual machine, go to the ISO Image
section. First, click on Other from the drop-down menu. Then, select the image file you
downloaded to your computer in the window that opens. Finally, open the file.
Step 4 VirtualBox 7 offers new features with its unattended installation settings. If you want to use
the old method, select the Skip Unattended Installation option. Then, click the Next button.

Step 5: Set the virtual memory size for the Win10 virtual machine according to the RAM capacity. If
your host device has 16 GB RAM, you should configure 8 GB or 4 GB memory size in the Memory Size
window.
Step 6: In the Virtual Hard Disk configuration window, you can select your existing virtual disk file. If
you have previously created a virtual disk, you can use the existing file.
However, if you want to install Windows 10 from scratch, click Create a Virtual Hard Disk Now.
Specify the disk size and click the Create button.

Step 7: In the Summary window, check the virtual hardware settings for Win10. Also, review the
settings and close the window.

Step 8: Click Settings to configure the guest machine’s settings most professionally.
Step 9:Wait while the setup gets ready to install Windows 10.

Step 10: The installation wizard will restart your system after the specified time. However, if you do
not want to wait this time, click the “Restart Now” button. This way, you can restart immediately.

Step 11: After the system has copied the files, wait while the services start.
Step 12: Wait while the devices are being prepared.

Step 13: Configure the region settings in Windows 10 according to the location where you live. Then,
you confirm the settings by selecting “Yes”.

Step 14: If you want to change your keyboard layout in the setup screen, follow this step. First, go to
the “Keyboard Layout” screen. Then, you can change the necessary settings here. In this way, you can
update the keyboard design.
Step 15:If you want to add a second keyboard layout, click the Add Layout button. However, if you do
not wish to add a design, you can click the Skip button. As a result, you can continue with this step.

Step 16: In this window, you can choose how you will use your emulated system. If your VM will be
used in an organization, select the option “Set up for an organization.” This will make it a member of
the Active Directory environment.
However, you can also use your VM with a local account without a Microsoft account. However, you
should select the option “Set up for personal use.”

Step 17: If you are going to use a guest system synchronized with a Microsoft account, you can log in
with your account. If you do not own a Microsoft account, you can create a new account with the
Create Account option.
However, you may want to add an account without a Microsoft account or later. Now proceed with
the Offline Account option on this screen.
Step 18: Windows suggests using cloud services. With a Microsoft subscription, you can easily access
your apps on any device.
If you don’t want to use these services, choose the Limited Experience option.

Step 19: Type a new user account name for your Windows 10 OS and click Next.
Step 20: Create a strong password to protect your Win10 VM. But make sure it’s also easy for you to
remember.

Step 21: You can change your Windows 10 privacy settings to match what you like. Therefore, turn
options on or off and adjust them to fit your needs.

Step 22: You can set up your guest PC based on your experience. Choose the category that fits you. If
you prefer, you can also click the Skip button.
Step 23: If you want to use Cortana, click the Accept button. However, if you do not want to use
Cortana, click the Not Now button.

Step 24: Wait while your desktop and required system settings are configured, and do not turn off
your VM.

Step 25: Windows 10 desktop view and system features are as follows.
c. Installation of Linux OS on a VM
Provisioning a machine
Once VirtualBox is installed on your machine, start the program and you should see the VirtualBox
Manager window open.

In this screen you will see options to create and add VMs to VirtualBox, as well as any VMs you have
previously created.
Select the “New” button to create a new VM. The prompt will ask for a name for the VM, a file
path for where to save the VM files. There are options for the “type” of OS you would like to install
on your VM, such as Windows, macOS, or Linux. It will also ask for the “version” of the OS you will
install, such as Ubuntu or Debian.
select Linux for the “Type”, Ubuntu (64-bit) for the “Version”, and select “Next”.

The following screen will ask to select the memory size to allocate for your machine. This will set
aside a certain amount of RAM on your host machine to be used for your VM when it is running.
Please allocate 1024 MB and select “Next”.
The next step is to create a virtual hard disk for your VM which is where files and programs will be
saved when operating your VM. Please select “Create a virtual hard disk now” and then click the
“Create” button.

You will then be prompted to select the type of hard disk file. Select “VDI (VirtualBox Disk Image)”
and click on “Next”.
Select whether the new virtual disk should be of a “fixed size” or dynamically allocate space as it fills
up. Select “Dynamically allocated” and click “Next”.

Then set the maximum size for the disk to store file data, and then click “Create” to finish
provisioning the VM.

VirtualBox will bring you back to the main screen where you can see your newly created VM.
Download Ubuntu
In order to install an OS to a VM you will need to install the OS just like you would on a regular
computer. You’ll need to download a copy of the installation.
Installing the OS
Now you should have everything ready to install Ubuntu. From the VirtualBox Manager screen,
double click the VM you created on the left and a prompt will appear asking to select the start-up
disk. Use the dropdown menu to select the Ubuntu image that you downloaded in the previous step
and click “Start” to boot the VM.

VirtualBox will open a new window where you can see the display for your VM! From this point on,
all these instructions take place in the VirtualBox window loading Ubuntu.

In the next screen, select “Erase disk and install Ubuntu”. Don’t worry! This takes place inside your
VM and won’t affect your primary disk. Click “Install now” to continue. Ubuntu will prompt you to
select your location and create a username and password. Afterwards, the installation will begin.
The installation can take a bit of time depending on your installation type and your internet speed:

When the installation finishes, restart the VM in order to use it:


After restarting the VM you can log into your account and use your Ubuntu machine! Since our
Ubuntu installation is completely contained within a VM, it’s practically impossible to screw up your
host computer.
PRACTICAL 2
Windows (DOS) Commands
Date
• Definition: Displays or sets the system's date.

o To view the current system date, type date and press Enter. This command will also
prompt you to enter a new date if you wish to change it.

Time
• Definition: Displays or sets the system's time.
o To view the current system time, type time and press Enter. This command will also
prompt you to enter a new time if you wish to change it.

Prompt
• Definition: Changes the command prompt.
o To change your command prompt to display the word "User", type prompt User$G
and press Enter.

Md (Make Directory)
• Definition: Creates a new directory.
o To create a new directory called "NewFolder", type md NewFolder and press Enter.

Cd (Change Directory)
• Definition: Changes the current directory
o To change the current directory to "NewFolder", type cd NewFolder and press Enter.

Rd (Remove Directory)
• Definition: Removes a directory.
o To remove a directory named "OldFolder", make sure it is empty and type rd
OldFolder and press Enter.
Path
• Definition: Sets or displays a search path for executable files.
o To add the directory "C:\Program Files\MyApp" to the system path, type path
%path%;C:\Program Files\MyApp and press Enter.

B) File Operations
COPY
• Definition: Copies one or more files from one location to another.
o To copy a file named example.txt from the current directory to the directory
C:\Backup, you would type copy example.txt C:\Backup and press Enter.

XCOPY
• Definition: Copies files and directories, including subdirectories (if specified), from one
location to another.
o To copy all files and subdirectories from the directory C:\Data to C:\Backup\Data,
including empty directories, type xcopy C:\Data C:\Backup\Data /E and press Enter.

DEL (or DELETE)


• Definition: Deletes one or more files.
o To delete a file named oldfile.txt from the current directory, type del oldfile.txt and
press Enter.

CLS
• Definition: Clears the command prompt screen of all previously entered commands and text.
o To clear the screen, simply type cls and press Enter.

ECHO
• Definition: Displays messages or turns command echoing on or off.

o To display the message "Hello World" in the command prompt, type echo Hello
World and press Enter.
o To turn off the display of commands in a batch file, type echo off.
COPY CON
Definition: The COPY CON command is used to create a new file and write data directly to it. The
data can be entered from the keyboard until the user signals that they are done.

After typing the text, pressing Ctrl + Z and then Enter will save the file.

FC (File Compare)
Definition: The FC command compares two files or sets of files and displays the differences between
them.

FIND
Definition: The FIND command searches for a specific string of text in a file or files.

This command looks for the word "sample" in example.txt.

RENAME (or REN)


Definition: The RENAME command is used to change the name of a file or directory.

This command renames example.txt to example_renamed.txt.

TYPE
Definition: The TYPE command is used to display the contents of a text file.

VER
Definition: The VER command displays the current version of the operating system.
PRACTICAL 3
Linux Commands
a. Basic Navigation and File/Directory Management
pwd (Print Working Directory):
Definition: Displays the full path of the current working directory.

This command shows that the user is currently in the /home/user/Documents directory.

cd (Change Directory):
Definition: Changes the current directory to the one specified.

This command navigates from the current directory to /home/user/Desktop and then verifies the
location using pwd.

ls (List Directory Contents):


• Definition: Lists the files and directories in the current directory.

This lists the contents of the current directory, showing files and directories.

mkdir (Make Directory):


• Definition: Creates a new directory.

This creates a new directory named new_folder and lists the directory contents to confirm it
was created.

rmdir (Remove Directory):


• Definition: Removes an empty directory.

This removes the new_folder and shows that it's no longer listed in the current directory.
b. File Operations
touch:
o Definition: Creates a new empty file or updates the timestamp of an existing file.

This creates a new file named newfile.txt.

rm (Remove):
• Definition: Deletes a file.

This deletes newfile.txt and verifies it no longer exists in the directory.

cp (Copy):
• Definition: Copies a file from one location to another.

This copies file1.txt to a new file backup.txt.

mv (Move):
• Definition: Moves files.

This renames file1.txt to renamed_file.txt.

cat (Concatenate and Display Files):


• Definition: Displays the contents of a file.

This displays the content of file2.txt.

chmod (Change Mode):


• Definition: Changes file permissions.

This gives script.sh execute permissions.


c. Process Management
ps (Process Status):
• Definition: Displays a snapshot of current processes.

This shows running processes with their Process IDs (PIDs).


top:
• Definition: Provides a real-time view of running processes.

Running top shows live information about CPU usage, memory usage, and active processes.
kill:
• Definition: Terminates a process by its PID.

This terminates the process with PID 2345.

bg (Background):
• Definition: Resumes a suspended job in the background.
fg (Foreground):
• Definition: Brings a background job to the foreground.
Jobs:
• Definition: The jobs command will list all jobs on the system; active, stopped, or
otherwise.

d. Search and Locate


grep:
Definition: Searches for patterns in files.

This searches for the word "pattern" in file2.txt.


find:
• Definition: Searches for files in a directory hierarchy.

• :
This searches for .txt files in the /home/user directory.
e. System Information and Utilities
uname:
• Definition: Displays system information.

This displays detailed system information.


df (Disk Free):
• Definition: Displays disk space usage.

free:
• Definition: Displays the amount of free and used memory in the system.

This shows memory usage in human-readable format.

f. Compression
tar (Tape Archive):
o Definition: Archives multiple files into a single file.

This creates an archive named archive.tar containing file1.txt and file2.txt.


gzip:
• Definition: Compresses files using the gzip compression algorithm.

This compresses file1.txt into file1.txt.gz.


PRACTICAL 4
Working with Linux desktop and utilities
The vi Editor
• Definition: vi is a text editor available on almost all UNIX-like operating systems, including
Linux. It's a modal editor, meaning it has different modes for inserting text and issuing
commands.
1. Open a file with vi

Insert mode: Press i to start editing.


Save and exit: Press Esc to exit Insert mode, then type :wq to save and quit.
Exit without saving: Press Esc and type :q!

Graphics User Interface (GUI) in Ubuntu


• Definition: Ubuntu uses the GNOME desktop environment by default, providing a graphical
interface for interacting with files, applications, and system settings.
o Accessing the Applications Menu: Press the Super (Windows) key and type the
name of the application, e.g., Firefox to open the browser.
o Using the File Manager: Click on the Files icon in the dock to open the file manager
and browse your directories in a graphical way.
o System Settings: Access the system settings by clicking on the top-right corner of the
screen and selecting Settings.

Adjusting Display Resolution in Ubuntu


• Definition: You can adjust the display resolution to fit your screen or preferences using both
the GUI and command line.
• Example (Using GUI):
1. Click on Settings (found in the system menu in the top-right corner).
2. Go to Displays.
3. Under Resolution, select your preferred resolution (e.g., 1920x1080).
4. Click Apply to set the resolution.

Using the Browsers in Ubuntu


• Definition: Browsers like Firefox and Google Chrome are used to access the web from
Ubuntu.
• Example (Using GUI):
1. Press the Super key, type Firefox, and press Enter to open the browser.
• Example (Using Terminal):

Creating Users in Ubuntu


• Definition: You can create users and manage file shares with tools like Samba for sharing files
between Linux and Windows machines.
• Example (Creating a New User):
PRACTICAL 5
Installing utility software on Linux
Step 1: Update package lists
Before installing any software, it’s always a good idea to update the package index to make sure
you're getting the latest versions:

Step 2: Install the software package


To install a software package using apt, you can use the following command:

The most common way to install software on Windows is through downloadable .exe files from
software vendors.
Step 1: Download the installer
• Go to the software's official website (e.g., Google Chrome).
• Find the download link for the .exe file.
• Click "Download" to save the installer file to your computer.
Step 2: Run the installer
• Navigate to the folder where the .exe file was downloaded (usually the Downloads folder).
• Double-click the .exe file to run the installer.
Step 3: Follow the installation prompts
• Follow the on-screen instructions. Most installers will have an "Install" button and may offer
options like selecting installation directories.
• Click "Next" or "Install" and wait for the process to complete.
Step 4: Launch the software
• Once installed, the software can typically be launched from the Start Menu or a shortcut
created on the desktop.
PRACTICAL 6
Running C, C++, and Python programs in the Ubuntu
terminal.
1. Running a C Program in Ubuntu
Step 1: Install the GCC compiler
If GCC (GNU Compiler Collection) isn't installed on your system, you can install it using the following
command:

Step 2: Write a C program


Create a C file using a text editor like nano or vi:

Inside the file, write the following C code:

Save and exit the file (Ctrl + X, then Y, and Enter for nano).
Step 3: Compile the C program
To compile the hello.c program:

This will produce an executable file named hello.


Step 4: Run the C program
Run the compiled program:
2. Running a C++ Program in Ubuntu
Step 1: Install the G++ compiler
If G++ (GNU C++ Compiler) isn't installed, you can install it using the following command:

Step 2: Write a C++ program


Create a C++ file:

Inside the file, write the following C++ code:

Save and exit the file.


Step 3: Compile the C++ program
To compile the hello.cpp program:

This will produce an executable file named hello_cpp.


Step 4: Run the C++ program
Run the compiled program:
3. Running a Python Program in Ubuntu
Step 1: Verify Python installation
Python usually comes pre-installed on Ubuntu. Check the version of Python installed:

Step 2: Write a Python program


Create a Python file:

Inside the file, write the following Python code:

Save and exit the file.


Step 3: Run the Python program
To run the Python program:
PRACTICAL 7
Introduction to Linux Shell Scripting
a. Basic Operators
• Definition: Operators in shell scripting are used for arithmetic, relational, and logical
operations.
• Example (Arithmetic Operators):
vi file.sh

a=10
b=20
sum=$((a + b)) # Addition
echo "Sum: $sum"

product=$((a * b)) # Multiplication


echo "Product: $product"

Relational Operators: Used for comparing numbers.

if [ $a -eq $b ]; then
echo "a is equal to b"
else
echo "a is not equal to b"
fi

To Run type: bash -f file.sh

b. Decision Making
• Definition: Decision-making in shell scripts is done using if, else, elif, and case statements.
• Example (if-else statement):
num=5
if [ $num -gt 0 ]; then
echo "Number is positive"
else
echo "Number is negative or zero"
fi

echo "Enter a number between 1 and 3"


read num
case $num in
1) echo "You entered One" ;;
2) echo "You entered Two" ;;
3) echo "You entered Three" ;;
*) echo "Invalid input" ;;
Esac
c. Looping
• Definition: Loops are used to repeat a block of code multiple times. Common types of loops
are for, while, and until.
• Example (for loop):

for i in {1..5}; do
echo "Looping: $i"
done

counter=1
while [ $counter -le 5 ]; do
echo "Counter: $counter"
((counter++))
Done

counter=1
until [ $counter -gt 5 ]; do
echo "Counter: $counter"
((counter++))
Done

d. Regular Expressions
• Definition: Regular expressions (regex) are patterns used for string matching. In shell scripts,
they are often used with grep

echo "Enter a string: "


read input
if echo "$input" | grep -q "[0-9]"; then
echo "The string contains numbers."
else
echo "No numbers found."
Fi
PRACTICAL 8
Case study on windows architecture
Windows architecture
1. Windows Kernel:
Think of it as the brain of Windows. It manages your computer's hardware and
resources, like memory and processors. It also handles tasks such as starting
programs, managing files, and controlling input/output (like printing or saving files).
2. Hardware Abstraction Layer (HAL):
Acts like a translator between Windows and your computer's hardware. It helps
Windows work smoothly with different types of processors and devices (like graphics
cards or printers).
3. User Interface:
Desktop and Windows Shell:
The desktop is what you see when you first start Windows, with icons, the taskbar,
and the Start menu. The Windows Shell manages how you interact with Windows,
like opening and managing windows, files, and programs.
Graphical User Interface (GUI):
This is what makes Windows easy to use. It includes icons, menus, and buttons that
let you control and interact with programs and files using a mouse or keyboard.
4. Applications and Services:
Win32 API:
A set of instructions that software developers use to create Windows programs.
Windows Services:
These are background tasks that run without you seeing them. They handle
things like printing, network connections, and security. They keep Windows
running smoothly behind the scenes.
5. File System and Storage:
NTFS File System:
This is how Windows stores and organizes files on your hard drive. It supports
features like file permissions, encryption, and compressing files to save space.
6. Storage Management:
Windows manages how files are stored and accessed on your computer. It makes
sure your files are safe and your programs can find what they need quickly.
7. Security and Maintenance:
User Account Control (UAC):
Helps protect your computer by asking for permission before allowing programs to
make changes that could affect your system. It prevents unauthorized changes and
keeps your data safe.
8. Windows Update:
Automatically keeps Windows and your programs up-to-date with the latest security
fixes and improvements. It helps protect your computer from viruses and keeps it
running smoothly.
9. Virtualization and Compatibility:
Hyper-V:
Lets you create and run virtual machines on your Windows computer. This allows
you to use different operating systems or test software without affecting your main
system.
Compatibility Layers:
Helps older programs run on newer versions of Windows. It ensures that software
designed for previous versions of Windows can still work on the latest versions.

You might also like