Os Lab 03
Os Lab 03
You can see that our Ubuntu device currently has two active network interfaces.
The first network interface that is listed is the loopback device. This interface has the name “lo”
and is used for your computer to communicate with itself. The second network interface
utilizes the name “enp0s3“. As this interface starts with “en“, we can tell that it is our Ethernet
network interface. This interface is the one that we want to set the static IP address for.
Note: Before proceeding, make sure that you make a note of your network interface’s name.
From this example, the network name we want to set a static IP address for will be called
“ens33“.
Using Netplan to Define a Static IP Address
We can use this tool to make the operating system request a specific IP address from the router
when it connects.
1. As your Ubuntu Server installation might come with different configuration files, we need to
list the files out of the config directory. We can use the ls command to list the files in the
“/etc/netplan/” directory.
ls /etc/netplan
In our clean installation of Ubuntu Server 22.04, this file was called “01-network-manager-
all.yaml“.
2. We can begin editing the Netplan configuration file by utilizing the nano text editor. Make
sure you change the filename in the following command
sudo nano /etc/netplan/ 01-network-manager-all.yaml
3. In this file, you should have text similar to what we have shown below. Using this file, we
can control the behavior of our network interfaces.
network: – When modifying a network interface’s behaviour, the file must
always start with “network:“.
All settings that modify the network will be stored underneath this block.
version: – Netplan requires you to specify what version of its configuration
markup that you are using.
ethernets: – This block is where we define settings that will modify our ethernet
interfaces’ behavior.
If you are trying to modify a wireless connection, you should see the text “wifi”
instead.
ens33: – Finally, you should see the name of your network interface. Settings
defined under this block only affects that device.
dhcp4: – This option allows us to control whether Netplan will automatically
fetch an IP address from the router using the DHCP client.
By default, the DHCP client will be enabled with the setting set to “yes“.
4. Now that you understand the default configuration, we can now modify it to suit our needs.
Please note that indentation is crucial to the Netplan configuration file. Anything inside a
block needs to have an extra two spaces added before it.
a) Our first task will be to disable the network interface from retrieving an IP address
automatically from the router’s DHCP server. Disabling the DHCP client is as simple
as changing the value of this setting from “yes” to “no“.
b) With the DHCP client disabled, we can now define a static IP address for our Ubuntu
22.04 device. We need to add a new option, that being “addresses:“. Using this
option, we can specify the IP address you want to retrieve. The IP addresses you
specify here must be surrounded by square brackets ([ ]. If you add multiple IPs, you
must separate them using a comma (,). With our example below, we will be telling
our device to try and use the IP address 192.168.0.123. Remember you can get your
current ip address by using the ip a command. Now set your static ip address
c) Since we have disabled the DHCP client, we need to add an option so that we can
specify the gateway address. This option is “gateway4:“. Using this, we can specify
the IP we want to route through. Typically, this IP address will be the internal IP of a
device such as your network router. For our example, we will be using the IP address
for our network router, “192.168.1.1“.
gateway4: 192.168.1.1
d) Additionally, we need to define the IP address for our nameservers. Since the
“nameservers” block has several options, so everything after this block will be on a
new line.
e) Within this block, we need to define the nameservers that we want to connect to by
using the “addresses:” option. Inside the nameservers block, we need to define the
DNS servers’ IP addresses that you want to connect to. This option will be started
with “addresses:“. To showcase how this works, we will be using Google DNS
servers. In this case, the two IP addresses would be “8.8.4.4” and “8.8.8.8“.
5. At the end of these steps, you should have a configuration file that looks like we have
below. The IP addresses and network interface names will likely differ from what we have
here.
You can save your changes to the configuration file by pressing CTRL + X, followed by Y, then
the ENTER key.
6. Now to check whether your configuration has been accepted or not, type the below
commands
sudo netplan try
which will show you the below output
7. With the configuration file modified, we need to get the Netplan tool to apply the changes.
Applying the changes is as simple as using the following command on your Ubuntu device.
sudo netplan apply
8. Verifying that the Ubuntu 22.04 operating system is now utilizing a static IP address, we can
use the ip command again.
ip a
From this command, you should end up finding a result for your Ethernet device. As you can
see, our ip address changed to 196.162.0.128 as we added in the configuration file above.
DISADVANTAGES OF STATIC IP
Static IP address has a few drawbacks:
The router will never guarantee that the IP is actually available. As there is no
reservation in place, the IP can be assigned to another device.
Additionally, suppose the static IP address is not available when your Ubuntu 22.04
device connects. In that case, it will fail to connect to the router.
As your device asks for a specific IP, the router will not fall back to assigning an IP from
the router’s pool.
SAMBA FEATURES
Samba is a powerful and versatile server application. Even seasoned system administrators
must know its abilities and limitations before attempting installation and configuration.
What Samba can do:
Serve directory trees and printers to Linux, UNIX, and Windows clients
Assist in network browsing (with or without NetBIOS)
Authenticate Windows domain logins
Provide Windows Internet Name Service (WINS) name server resolution
Act as a Windows NT®-style Primary Domain Controller (PDC)
Act as a Backup Domain Controller (BDC) for a Samba-based PDC
Act as an Active Directory domain member server
Join a Windows NT/2000/2003 PDC
Note some lines would have ; signs. These a line comments so remove
them as show below these can be like this
Browsing/Identification
The Browsing subsection contains the workgroup and server string parameters:
workgroup = WORKGROUP
server string = samba_server
Networking
Use the Networking subsection to configure network interfaces that Samba binds
to. Networking contains two parameters:
The first parameter, interfaces, sets the network interface for Samba to bind to.
The second parameter, bind interfaces only, ensures that Samba only binds to the
interfaces listed in the file. The parameter should always be set to yes.
To set the interfaces parameter, first check the available interfaces with the ip command:
ip link
The example output indicates Samba binds to two interfaces: lo, the loopback interface,
and enp0s3, the network interface.
interfaces = lo enp0s3
bind interfaces only = yes
Debugging
The Debugging subsection has four parameters. Set them as follows:
3. Save and exit the file and run the Samba utility testparm to check for syntax errors:
testparm
The output shows the Loaded services file OK message, which signifies no syntax errors.
With Global Settings configured, the Samba server is ready to use.
Note: The Program might issue a warning for now you can ignore them as its for the bad
name interface we assigned earlier
Then at the very bottom of the file write these commands
Here assign the same password as your local machine. Afterwards assign admin access to the main
user via this command
This will display who is the actual user , then type ipconfig to reveal the windows ip
In our case the ip of windows is 192.168.100.80
Then on windows assign a folder to be share in our example we will take downloads
Then assign the username and password of windows user (use the whoami user and windows
password)
Congratulations You have successfully accessed windows share on linux and vice versa
How to install virtual box 7.0 in Ubuntu 22.04
Note: Follow this tutorial if you have no other option then dual
boot otherwise skip
1. Update Ubuntu packages
sudo apt update –y
2. Install VMA
sudo apt install virtualbox virtualbox-ext-pack -y
3. Select OK, and press Enter after reading the VirtualBox Extension Pack Personal Use and
Evaluation License (PUEL) terms.
4. Now, select Yes, and press Enter to accept the Oracle Binary Code License Agreement for
the VirtualBox Extension Pack.
5. Finally, run the following command to start using VirtualBox or open it from the
Applications menu.
virtualbox
The main VirtualBox Manager window appears, as shown below, where you can manage
your VMs.
Name – Provide a name for your VM. This tutorial’s choice is W10.
Machine Folder – Choose the folder where you want your VM to reside.
Type – Select the type of OS for your VM. This example will use Windows 10 (32-
bit).
Click Next to continue.
3. Now, specify how much memory (RAM in MB) you want to allocate for your VM, and click
Next.
4. Select the Create a virtual hard disk now option on the next screen, and click Create. This
option lets you create a virtual hard disk (a file) that stores all the data for your VM,
including the operating system, applications, and files.
5. Next, choose the VDI (VirtualBox Disk Image) option, which is a good choice for most users,
and click Next.
6. On the next screen, choose the storage type for your virtual hard disk. But for this tutorial,
select the default option (Dynamically allocated) and click Next. Why use dynamic
allocation? This option is more efficient with storage space because it only allocates the
amount of disk space the VM uses.
7. Choose a name for the virtual hard disk, allocate the storage space for your VM, and click
Create. You can choose the storage size you prefer, but this example’s choice is 50 GB.
8. Once the VM is created, you’ll see the VM listed in the left pane of the VirtualBox window
with all details.
3. Select Choose disk file from the dropdown menu to look up your bootable media (ISO).
4. We will use Win10 32bit disk file. Download the Win10 disk file using the following steps.
a) Visit the following site to download W10 ISO file.
https://www.microsoft.com/en-us/software-download/windows10ISO
b) Select the Windows10 option and click confirm.
d) Select the 32bit as when creating our Virtual Machine, we selected Windows 32 bit.
Now, locate and select your ISO image file.
T
Exercises:
1. Perform the above illustrated samba configuration with screenshots attached
2. Write a C Program inside the Downloads folder of your windows directory via the
ubuntu OS (either via the GUI text editor or nano) in which there exists two nested
structures one OS_Class and other student with the properties OS_type as string, no
of PC as int in OS_Class and in student rollno in string and semester enrolled in int
and print them
Note: Compile the answer on ubuntu via the network share and should be present
on the terminal
3. As the above stated question do the vice versa in this case use the share folder in
ubuntu and access via windows on a software (either VSCode or Dev C++) and
compile the answer on windows
4.Write a script that locates and returns all files in the windows Desktop folder with
the extension .C on ubuntu
5.Write a script that reads a script on the windows folder share (can be any folder
you assigned) and executes the script. Then asks for a file name to be created and
move the file from the windows share to your ubuntu share (note the mv command
must be in the ubuntu script the windows script should only have either the touch
command or cat command )