0% found this document useful (0 votes)
9 views6 pages

Linux Unit 5

Bsc it unit 5 Q&A

Uploaded by

mefalim212
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)
9 views6 pages

Linux Unit 5

Bsc it unit 5 Q&A

Uploaded by

mefalim212
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/ 6

LINUX UNIT 5

1. What is a shell shell script? What are the elements of a good shell are script? How is a script
executed?
Ans
1) A shell script is a text file that contains a sequence of commands. Basically, anything that can run a
bunch of commands is considered a shell script.
2) Nevertheless, there are some rules to ensure that you create quality shell scripts scripts that not only
work well for the task for which they are written but that also will be readable by others.
Elements of a Shell Script
✓Has a unique name
✓Includes the shebang (#!) to tell the shell which subshell should execute the script
✓Includes comments—lots of comments
✓Uses the exit command to tell the shell executing the script that it has executed successfully.
✓Is Executable
Executing the Script
There are three different ways to execute Shell Scripts
1.Making the Script Executable The most common way to run a shell script is by making it executable. To
do this with the hello script from Example, use the following command:
chmod +x hello
2.Running the Script as an Argument of the Bash Command The second option for running a script is to
specify its name as the argument of the bash command. For example, the script hello would run using
the command bash hello. The advantage of running the script this way is that there is no need to make it
executable first
3.Sourcing the Script The third way of running a script is completely different. You can source the script.
By sourcing a script, you don’t run it as a subshell. Rather, you include it in the current shell. This can be
useful if the script contains variables that you want to be active in the current shell.

2. What is high availability? State and explain the requirements of high availability.
Ans
1) High availability (HA) refers to a system's ability to operate continuously without interruptions or
downtime for an extended period. It ensures that critical services remain accessible even in the event of
hardware failures, software issues, or other disruptions.
2) High availability is essential for systems that support vital functions in industries such as healthcare,
finance, and e-commerce.
3) The goal of high availability is often quantified as a percentage, such as 99.999% uptime ("five nines"),
equating to only about 5 minutes of downtime per year.
Requirements of High Availability
To achieve high availability, specific components and strategies are essential:
1. Redundant Systems
Description: Critical servers and resources should have backups to handle failures without disrupting
access.
Purpose: Ensures continuous operation by automatically switching to backup components when a failure
occurs.

2. Failover Mechanisms
Description: The ability to automatically switch to a standby system or resource in case of a failure in the
primary system.
Purpose: Reduces downtime and maintains service continuity.

3. Load Balancing
Description: Distributing incoming traffic or workloads across multiple servers or resources to prevent
overload and ensure optimal resource utilization.
Purpose: Prevents system overload and improves response times and reliability.

4. Monitoring and Alerting


Description: Continuous monitoring of system components and immediate alerting in case of failures or
performance issues.
Purpose: Helps identify and address issues proactively to avoid extended downtime.

5. Scalability
Description: The ability of the system to scale up (add resources) or scale out (add more nodes) to
handle increased load.
Purpose: Ensures consistent performance even during high demand.

3. How will you setup bonding?


Ans
1)Setting Up BondingTo set up a bonded network interface, you’ll have to accomplish these steps:
1. Identify the physical network cards that you want to configure in the bonding interface.
2. Change the configuration for the physical network cards to make them slaves for the bonding interface.
make sure that its configuration file follows theexample shown here:
DEVICE=em1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3. Create a configuration file for the bonding interface. Which would be
/etc/sysconfig/networkscripts/ifcfg-bond0 for bond device bond0 would appear as follows:
DEVICE=bond0
IPADDR=192.168.1.100
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="mode=1 miimon=100”
4. Make sure the bonding kernel module is loaded. To do this, create a file with the name
/etc/modprobe.d/bonding.conf, and put in the line alias bond0 bonding.
After per forming all of these steps, your bond device is ready for use. Restart the network, and use the ip
a command to verify that it is indeed available.

4. Write a short note on kick-start file.


Ans
1)You have created an environment where everything you need to install your server is available on
another server. This means you don’t have to work with optical discs anymore to perform an installation,
however you still need to answer all the questions which are part of the normal installation process. Red
Hat offers an excellent solution for this challenge: the kickstart file.
2)To specify that you want to use a kickstart file to install a server, you need to tell the installer where to
find the file.
3)If you want to perform an installation from a local Red Hat installation disc, add the linux ks= boot
parameter while installing. (Make sure you include the exact location of the kickstart file after the = sign.)
4)As an argument to this parameter, add a complete link to the file. For example, if you copied the
kickstart file to the server1.example.com web server document root, add the following line as a boot
option while installing from a DVD:
linux ks=http://server1.example.com/anaconda-ks.cfg

5. What is boot loader? Explain content of grub.conf file.


Ans
1)A boot loader is loaded for this purpose. On Red Hat Enterprise Linux, the GRUB boot loader is used.
Ona standard installation, the first part of the boot loader program is installed in the master boot record,
and from there the rest of the boot procedure is executed.
2)The purpose of GRUB is to load the kernel and the initial RAM fi le system. The kernel is the heart of
the operating system, which ensures that the hardware in the computer can be used. The initial RAM fi le
system contains modules that are needed by the kernel to access the fi le system and load other
modules.
3)To load the kernel and initial RAM file system, different sections can be included in grub.conf. Only one
section is used in the above sample file. It is defined in the line that starts with title Red Hat Enterprise
Linux and the three lines beneath that one.
4)Theimportant boot parameters are listed:
ro = This parameter indicates that the root fi le system should be mounted as read-only.

root= This parameter specifies the name of the device that contains the root file system.

default This specifies which of the proposed operating systems to load, and it refers to the sections that
are defined below the generic section in grub.conf.
timeout During boot, the user can press Tab to open the GRUB menu and add or change kernel
parameters. The timeout boot option is used to specify how much time a user has to get into the GRUB
menu.
splash image This parameter refers to a fi le containing a graphical background, which isloaded while
GRUB is displayed.
hiddenmenu This option makes sure that no GRUB menu is shown while booting. To enter the GRUB
menu, the administrator has to press the Enter key at the right moment.

6. Write a script to accept the number from user and print its multiplication table.
Ans
# Prompt the user for a number
read -p "Enter a number: " number

# Validate if the input is a valid number


re='^[0-9]+$
'if ! [[ $number =~ $re ]]; then
echo "Invalid input.
Please enter a valid number."
exit 1
fi

# Print the multiplication table


echo "Multiplication table for $number:"
for ((i=1; i<=10; i++))
do
result=$((number * i))
echo "$number x $i = $result"
done

Save the script in a file, for example, multiplication_table.sh. Then, make the file executable by running
the following command in the terminal:
chmod +x multiplication_table.sh

7. Write steps for Configuring the DHCP Server for PXE Boot.
Ans
option space pxelinux;
option pxelinux.magic code 208 = string;
option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32 ;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1 ;
range 192.168.1.200 192.168.1.250 ;
class "pxeclients"
{
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 192.168.1.70;
filename "pxelinux/pxelinux.0";
}
}

8. Discuss the steps to setup fencing.


Ans
1)Fencing is what you need to maintain the integrity of the cluster.
2)To set up fencing, you need to perform two different steps. First you need to configure the fence
devices, and then you associate the fence devices to the nodes in the network. To define the fence
device, you open the Fence Devices tab in the Conga management interface.
3)After clicking Add, you’ll see a list of all available fence devices. A popular fence device type is IPMI
LAN. This fence device can send instructions to many integrated management cards, including the HP
ILO and Dell Drac.
4)After selecting the fence device, you need to define its properties. These properties are different for
each fence device, but they commonly include a username, a password, and an IP address.
5)After defining the fence devices, you need to connect them to the nodes. From the top of the Luci
management interface, click Nodes, and then select the node to which you want to add the fence device.
Scroll down on the node properties screen, and click the Add Fence Method button.
6)The benefit is that this guarantees that, no matter what happens, there will always be one fence device
that works, which can fence your nodes if anything goes wrong.

9. Explain the steps to setup a quorum disk.


Ans
1)Quorum is an important mechanism in the cluster that helps nodes determine whether they are part of
the majority of the cluster. By default, every node has one vote, and if a node sees at least half of the
nodes plus one, then there is quorum.
2)A quorum disk involves two parts. First you’ll need a shared storage device that can be accessed by all
nodes in the cluster. Then you’ll need heuristics testing. Heuristics testing consists of at least one test
that a node has to perform successfully before it can connect to the quorum disk.
3)To set up a quorum disk, you have to perform these steps:
1. Create a partition on the shared disk device.
2. Use mkqdisk to mark this partition as a quorum disk
3. Specify the heuristics to use in the Conga management interface.
4) After creating the quorum device, you can use the cman_tool status command to verify that it works as
expected.

10. What is pattern matching? Write a shell script that isolates the directory name from a
complete file name.
Ans
• A pattern-matching operator can be used to search for a pattern in a variable and if that pattern is
found, modify the variable.
• It allows to define a variable in exactly the way you want.
• Pattern-matching operators always try to locate a given string.
# Prompt the user for a file name
read -p "Enter a complete file name (including the path): " file_name
# Extract the directory name from the file name
directory_name=$(dirname "$file_name")
# Print the directory name
echo "Directory name: $directory_name”
Save the script in a file, directory_name.sh then make the file executable by running following command
in terminal:
chmod +x directory_name.sh

11. Write a shell script to add ten users, remove their passwords and add them to the group
students. Use for loop.
Ans
# Add ten users
for ((i=1; i<=10; i++))
do
username="user$i"
sudo useradd -m $username
# Remove password for the user
sudo passwd -d $username
# Add the user to the "students" group
sudo usermod -a -G students $username
echo "User $username added to the 'students' group"
done
Save the script in a file, “add_users.sh” then make the file executable by running following command in
terminal:
chmod +x add_users.sh

12. How is the network server configured as an installation server? Enumerate the steps for the
same.
Ans
1) Setting Up the Network Installation Server
1. Insert the Red Hat Enterprise Linux installation DVD in the optical drive of your server.
2. Use mkdir /www/docs/server1.example.com/install to create a subdirectory in the Apache document
root for server1.example.com.
3. Use cp -R * /www/docs/server1.example.com/install from the directory where the Red Hat Enterprise
Linux installation DVD is mounted to copy all of the files on the DVD to the install directory in your web
server document root.
4. Modify the configuration file for the server1 virtual host in /etc/httpd/conf.d/server1.example.com, and
make sure that it includes the line Options Indexes. Without this line, the virtual host will show the
contents of a directory only if it contains an index.html file.
5. Use service httpd restart to restart the Apache web server.
6. Start a browser, and browse to http://server1.example.com/install. You should now see the contents of
the installation DVD.
7. Start Virtual Machine Manager, and create a new virtual machine. Give the virtual machine the name
test netinstall, and select Network Install when asked how to install the operating system.
8. When asked for the installation URL, enter http://server1.example.com/install. The installation should
now be started.
9. You may now interrupt the installation procedure and remove the virtual machine. You have seen that
the installation server is operational. It’s time to move on to the next phase in the procedure

You might also like