0% found this document useful (0 votes)
115 views19 pages

End Term Question Paper Linux For Devices 2021 Solutions

The document discusses the layout and purpose of key directories in the Linux file system. It describes directories such as /bin, /boot, /dev, /etc, /home, /lib, /lost+found, /media, /mnt, /opt, /proc, /root, /run, /sbin, /selinux, /srv, /tmp, and /usr, explaining what types of files and programs are typically contained within each directory and their general functions.

Uploaded by

Keshav
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)
115 views19 pages

End Term Question Paper Linux For Devices 2021 Solutions

The document discusses the layout and purpose of key directories in the Linux file system. It describes directories such as /bin, /boot, /dev, /etc, /home, /lib, /lost+found, /media, /mnt, /opt, /proc, /root, /run, /sbin, /selinux, /srv, /tmp, and /usr, explaining what types of files and programs are typically contained within each directory and their general functions.

Uploaded by

Keshav
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/ 19

Course Title: Linux For Devices Course Code: CSE 438

Examination: End Semester Nov-Dec 2021

Programme: B.Tech CSE


Name of the Examiner: Dr Debjani Ghosh, Dr Vibha Nehra, Dr Ashok Kumar Yadav

Sr. Model Answers Distribution


No. of Marks
Section A
1 How data Partition and swap partition can be created in 2 MARKS
Linux? Discuss the layout of linux file system. FOR
Ans: creation of
Data partition: normal Linux system data, including the root DATA
partition containing all the data to start up and run the system; PARTITIO
and N AND
Swap partition: expansion of the computer's physical memory, SWAP
extra memory on hard disk. PARTITIO
Swap space (indicated with swap) is only accessible for the N.
system itself, and is hidden from view during normal operation. 4 MARKS
Swap is the system that ensures, like on normal UNIX systems, FOR ANY 4
that you can keep on working, whatever happens. On Linux, CORRECT
you will virtually never see irritating messages like Out of DIRECTOR
memory, please close some applications first and try again, IES
because of this extra memory. The swap or virtual memory
procedure has long been adopted by operating systems outside
the UNIX world by now.

Create root, swap and home


– The root should be at least 15 GB for a comfortable use
If you have more disk space, increase the root size
Suppose you have 100 GB of disk space, you can easily devote
30 GB of space to root
Create Root Partition

• Choose the free space available and click on +

Create Root Partition

• Choose the size of root directory (keep it 20 GB or


more), choose ext4file system, and mount point as /
(i.e. root)

 Create Swap Partition

• Advised that Swap should be double of your system’s

RAM size

 Create Home Partition

•Try to allocate the maximum size to Home


– this is where you’ll be downloading and
keeping the files

/bin

This directory contains basic commands and programs


that are needed to achieve a minimal working
environment upon booting. These are kept separate
from some of the other programs on the system to allow
you to boot the system for maintenance even if other
parts of the filesystem may be damaged or unavailable.

If you search this directory, you will find that both ls


and pwd reside here. The cd command is actually built
into the shell we are using (bash), which is in this
directory too.
/boot

This directory contains the actual files, images, and


kernels necessary to boot the system. While /bin
contains basic, essential utilities, /boot contains the core
components that actually allow the system to boot.

If you need to modify the bootloader on your system, or


if you would like to see the actual kernel files and initial
ramdisk (initrd), you can find them here. This directory
must be accessible to the system very early on.

/dev

This directory houses the files that represent devices on


your system. Every hard drive, terminal device, input or
output device available to the system is represented by a
file here. Depending on the device, you can operate on
the devices in different ways.

For instance, for a device that represents a hard drive,


like /dev/sda, you can mount it to the filesystem to
access it. On the other hand, if you have a file that
represents a line printer like /dev/lpr, you can write
directly to it to send the information to the printer.

/etc

This is one area of the filesystem where you will spend


a lot of time if you are working as a system
administrator. This directory is basically a configuration
directory for various system-wide services.

By default, this directory contains many files and


subdirectories. It contains the configuration files for
most of the activities on the system, regardless of their
function. In cases where multiple configuration files are
needed, many times a application-specific subdirectory
is created to hold these files. If you are attempting to
configure a service or program for the entire system,
this is a great place to look.

/home

This location contains the home directories of all of the


users on the system (except for the administrative user,
root). If you have created other users, a directory
matching their username will typically be created under
this directory.

Inside each home directory, the associated user has


write access. Typically, regular users only have write
access to their own home directory. This helps keep the
filesystem clean and ensures that not just anyone can
change important configuration files.

Within the home directory, that are often hidden files


and directories (represented by a starting dot) that allow
for user-specific configuration of tools. You can often
set system defaults in the /etc directory, and then each
user can override them as necessary in their own home
directory.

/lib

This directory is used for all of the shared system


libraries that are required by the /bin and /sbin
directories. These files basically provide functionality to
the other programs on the system. This is one of the
directories that you will not have to access often.

/lost+found

This is a special directory that contains files recovered


by /fsck, the Linux filesystem repair program. If the
filesystem is damaged and recovery is undertaken,
sometimes files are found but the reference to their
location is lost. In this case, the system will place them
in this directory.

In most cases, this directory will remain empty. If you


experience corruption or any similar problems and are
forced to perform recovery operations, it’s always a
good idea to check this location when you are finished.

/media

This directory is typically empty at boot. Its real


purpose is simply to provide a location to mount
removable media (like cds). In a server environment,
this won’t be used in most circumstances. But if your
Linux operating system ever mounts a media disk and
you are unsure of where it placed it, this is a safe bet.

/mnt

This directory is similar to the /media directory in that it


exists only to serve as a organization mount point for
devices. In this case, this location is usually used to
mount filesystems like external hard drives, etc.

This directory is often used in a VPS environment for


mounting network accessible drives. If you have a
filesystem on a remote system that you would like to
mount on your server, this is a good place to do that.

/opt
This directory’s usage is rather ambiguous. It is used by
some distributions, but ignored by others. Typically, it
is used to store optional packages. In the Linux
distribution world, this usually means packages and
applications that were not installed from the
repositories.

For instance, if your distribution typically provides the


packages through a package manager, but you installed
program X from source, then this directory would be a
good location for that software. Another popular option
for software of this nature is in the /usr/local directory.

/proc

The /proc directory is actually more than just a regular


directory. It is actually a pseudo-filesystem of its own
that is mounted to that directory. The proc filesystem
does not contain real files, but is instead dynamically
generated to reflect the internal state of the Linux
kernel.

This means that we can check and modify different


information from the kernel itself in real time. For
instance, you can get detailed information about the
memory usage by typing cat /proc/meminfo.

/root

This is the home directory of the administrative user


(called “root”). It functions exactly like the normal
home directories, but is housed here instead.

/run

This directory is for the operating system to write


temporary runtime information during the early stages
of the boot process. In general, you should not have to
worry about much of the information in this directory.

/sbin

This directory is much like the /bin directory in that it


contains programs deemed essential for using the
operating system. The distinction is usually that /sbin
contains commands that are available to the system
administrator, while the other directory contains
programs for all of the users of the system.

/selinux

This directory contains information involving security


enhanced Linux. This is a kernel module that is used to
provide access control to the operating system. For the
most part, you can ignore this.

/srv

This directory is used to contain data files for services


provided by the computer. In most cases, this directory
is not used too much because its functionality can be
implemented elsewhere in the filesystem.

/tmp

This is a directory that is used to store temporary files


on the system. It is writable by anyone on the computer
and does not persist upon reboot. This means that any
files that you need just for a little bit can be put here.
They will be automatically deleted once the system
shuts down.

/usr

This directory is one of the largest directories on the


system. It basically includes a set of folders that look
similar to those in the root / directory, such as /usr/bin
and /usr/lib. This location is basically used to store all
non-essential programs, their documentation, libraries,
and other data that is not required for the most minimal
usage of the system.

This is where most of the files on the system will be


stored. Some important subdirectories are /usr/local,
which is an alternative to the /opt directory for storing
locally compiled programs. Another interesting thing to
check out is the /usr/share directory, which contains
documentation, configuration files, and other useful
files.

/var

This directory is supposed to contain variable data. In


practice, this means it is used to contain information or
directories that you expect to grow as the system is
used. For example, system logs and backups are housed
here. Another popular use of this directory is to store
web content if you are operating a web server.

2 Give the command for the following: i) Partitioning disk ii) 1 Marks for
Enabling the swap area iii) Creation of a filesystem iv) each
Displaying the system space v) Forcefully kill the process vi) command
Name 1000 directories in one go with a pattern like Photo-1-
OfMyBirthday, Photo-2-OfMyBirthday, Photo-3-
OfMyBirthday…. Photo-4-OfMyBirthday.
Answer: i) fdisk –l
ii) sapon –a
iii) mkfs -t ext4 /dev/sda2
iv) df –H
v) kill -9 pid
vi) mkdir Photo-{1..1000}-OfMyBirthday
3 Discuss the fundamental component of Docker. Compare 3 marks for
the Docker container with the virtual machine. any three
Answer: components.
3 marks for
Docker Engine the atleast 3
It is the core part of the whole Docker system. Docker Engine comparison
is an application which follows client-server architecture. It is
installed on the host machine. There are three components in
the Docker Engine:

Server: It is the docker daemon called dockerd. It can create


and manage docker images. Containers, networks, etc.
Rest API: It is used to instruct docker daemon what to do.
Command Line Interface (CLI): It is a client which is used to
enter docker commands.

Docker Client
Docker users can interact with Docker through a client. When
any docker commands runs, the client sends them to dockerd
daemon, which carries them out. Docker API is used by Docker
commands. Docker client can communicate with more than one
daemon.

Docker Registries
It is the location where the Docker images are stored. It can be
a public docker registry or a private docker registry. Docker
Hub is the default place of docker images, its stores’ public
registry. You can also create and run your own private registry.

When you execute docker pull or docker run commands, the


required docker image is pulled from the configured registry.
When you execute docker push command, the docker image is
stored on the configured registry.

Docker Objects
When you are working with Docker, you use images,
containers, volumes, networks; all these are Docker objects.

Images
Docker images are read-only templates with instructions to
create a docker container. Docker image can be pulled from a
Docker hub and used as it is, or you can add additional
instructions to the base image and create a new and modified
docker image. You can create your own docker images also
using a dockerfile. Create a dockerfile with all the instructions
to create a container and run it; it will create your custom
docker image.

Docker image has a base layer which is read-only, and the top
layer can be written. When you edit a dockerfile and rebuild it,
only the modified part is rebuilt in the top layer.

Containers
After you run a docker image, it creates a docker container. All
the applications and their environment run inside this container.
You can use Docker API or CLI to start, stop, delete a docker
container.

Below is a sample command to run a ubuntu docker container:

docker run -i -t ubuntu /bin/bash


Volumes
The persisting data generated by docker and used by Docker
containers are stored in Volumes. They are completely
managed by docker through docker CLI or Docker API.
Volumes work on both Windows and Linux containers. Rather
than persisting data in a container’s writable layer, it is always a
good option to use volumes for it. Volume’s content exists
outside the lifecycle of a container, so using volume does not
increase the size of a container.

You can use -v or –mount flag to start a container with a


volume. In this sample command, you are using geekvolume
volume with geekflare container.

docker run -d --name geekflare -v geekvolume:/app


nginx:latest
Networks
Docker networking is a passage through which all the isolated
container communicate. There are mainly five network drivers
in docker:

Bridge: It is the default network driver for a container. You use


this network when your application is running on standalone
containers, i.e. multiple containers communicating with same
docker host.
Host: This driver removes the network isolation between
docker containers and docker host. It is used when you don’t
need any network isolation between host and container.
Overlay: This network enables swarm services to communicate
with each other. It is used when the containers are running on
different Docker hosts or when swarm services are formed by
multiple applications.
None: This driver disables all the networking.
macvlan: This driver assigns mac address to containers to make
them look like physical devices. The traffic is routed between
containers through their mac addresses. This network is used
when you want the containers to look like a physical device, for
example, while migrating a VM setup.
Virtual Machine Docker Container

Hardware-level process
OS level process isolation
isolation

Each VM has a separate OS Each container can share OS

Boots in minutes Boots in seconds

Containers are lightweight


VMs are of few GBs
(KBs/MBs)

Ready-made VMs are Pre-built docker containers


difficult to find are easily available

VMs can move to new host Containers are destroyed and


easily re-created rather than moving

Creating VM takes a Containers can be created in


relatively longer time seconds

More resource usage Less resource usage

4 Give different services work to share or mount NFS. 3 marks


Discuss the two methods for mounting the remote file listing of
system automatically at boot time. service to
mount NFS
3 Marks for
Answer: To share or mount NFS file systems, the following listing
services work together, depending on which version of NFS is methods for
implemented: mounting
Remote file
o nfs — (/sbin/service nfs start) starts the NFS server and system
the appropriate RPC processes to service requests for
shared NFS file systems.
o nfslock — (/sbin/service nfslock start) is a mandatory
service that starts the appropriate RPC processes to
allow NFS clients to lock files on the server.
o portmap — accepts port reservations from local RPC
services. These ports are then made available (or
advertised) so the corresponding remote RPC services
access them. portmap responds to requests for RPC
services and sets up connections to the requested RPC
service. This is not used with NFSv4.

Red Hat Enterprise Linux offers two methods for mounting


remote file systems automatically at boot time:
the /etc/fstab file and the autofs service.

Mounting NFS File Systems using /etc/fstab

One way to mount an NFS share from another machine is to


add a line to the /etc/fstab file. The line must state the
hostname of the NFS server, the directory on the server being
exported, and the directory on the local machine where the NFS
share is to be mounted. You must be root to modify
the /etc/fstab file.

The general syntax for the line in /etc/fstab is as follows:


server:/usr/local/pub /pub nfs defaults 0 0

autofs service

One drawback to using /etc/fstab is that, regardless of how


infrequently a user accesses the NFS mounted file system, the
system must dedicate resources to keep the mounted file system
in place. This is not a problem with one or two mounts, but
when the system is maintaining mounts to many systems at one
time, overall system performance can be affected.
An alternative to /etc/fstab is to use the kernel-
based automount utility. An automounter consists of two
components:

 a kernel module that implements a file system, and

 a user-space daemon that performs all of the other


functions.

autofs uses /etc/auto.master (master map) as its default primary


configuration file. This can be changed to use another
supported network source and name using the autofs
configuration (in /etc/sysconfig/autofs) in conjunction with the
Name Service Switch (NSS) mechanism.

5 (a) Discuss the HAL daemon, HAL device manager and 3 + 3


HAL configuration.
(b) Give the steps to set up DHCP in a Linux server.

Answer: The Linux Hardware Abstraction Layer


(HAL) implements a coherent description of all the hardware
on a system, including hot-plugged devices such as on USB
(Universal Serial Bus). It works by merging information
presented by the operating system, the physical hardware,
device drivers, subsystems such as CUPS (Common Unix
Printing System), and even from system administrators. This
information is collated and made available to application
programs via a HAL programming interface. The haldaemon
service invokes the HAL daemon process hald to obtain the
kernel-level data via the kernel D-BUS communication channel
to collect and to distribute this information. This abstraction
layer is simply an interface that makes it possible to add
support for new devices and new ways of connecting devices to
the computer, without modifying every application that uses the
device. It maintains a list of devices that currently exist, and
can provide information about those upon request.

(b) Step 1: Installing DHCP Server in Ubuntu


1. Run the command below to install the DCHP server
package
$ sudo apt install isc-dhcp-server
2. When the installation completes, edit the file
/etc/default/isc-dhcp-server to define the interfaces
DHCPD should use to serve DHCP requests, with the
INTERFACES option.
For example, if you want the DHCPD daemon to listen on
eth0, set it like so:
INTERFACES="eth0"
Step 2: Configuring DHCP Server in Ubuntu
3. The main DHCP configuration file is
/etc/dhcp/dhcpd.conf, you must add all your network
information to be sent to clients here.
And, there are two types of statements defined in the DHCP
configuration file, these are:
parameters – specify how to perform a task, whether to
carry out a task, or what network configuration options to
send to the DHCP client.
declarations – define the network topology, state the clients,
offer addresses for the clients, or apply a group of
parameters to a group of declarations.
4. Now, open and modify the main configuration file, define
your DHCP server options:
$ sudo vi /etc/dhcp/dhcpd.conf
Set the following global parameters at the top of the file,
they will apply to all the declarations below (do specify
values that apply to your scenario):
option domain-name "tecmint.lan";
option domain-name-servers ns1.tecmint.lan,
ns2.tecmint.lan;
default-lease-time 3600;
max-lease-time 7200;
authoritative;
5. Now, define a subnetwork; here, we’ll setup DHCP for
192.168.10.0/24 LAN network (use parameters that apply
to your scenario).
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option domain-search "tecmint.lan";
option domain-name-servers 192.168.10.1;
range 192.168.10.10 192.168.10.100;
range 192.168.10.110 192.168.10.200;
}
7. Next, start the DHCP service for the time being, and
enable it to start automatically from the next system boot,
like so:
------------ SystemD ------------
$ sudo systemctl start isc-dhcp-server.service
$ sudo systemctl enable isc-dhcp-server.service
------------ SysVinit ------------
$ sudo service isc-dhcp-server.service start
$ sudo service isc-dhcp-server.service enable
8. Next, permit DHCP service (DHCPD daemon listens on
port 67/UDP) on firewall as below:
$ sudo ufw allow 67/udp
$ sudo ufw reload
$ sudo ufw show
Step 4: Configuring DHCP Client Machines
9. Configure your clients computers automatically receive
IP addresses from the DHCP server.
Login to the client computers and edit the Ethernet
interface configuration file as follows
$ sudo vi /etc/network/interfaces
And define the options below:
auto eth0
iface eth0 inet dhcp
Save the file and exit. And restart network services like so
(or reboot the system):

Section B
6 6. (a) Give the timekeeping architecture in Linux. Discuss 5+5
the use of jiffy.
Linux kernel periodically conduct following:
 Updates the time elapsed since system startup.
 Updates the time and date.
 Determines, for every CPU, how long the current process
has been running, and preempts it if it has exceeded the
time allocated to it. The allocation of time slots (also
called quanta )
 Updates resource usage statistics.
 Checks whether the interval of time associated with each
software timer has elapsed.

Linux’s timekeeping architecture is the set of kernel data


structures and functions related to the flow of time. Actually,
Intel-based multiprocessor machines have a timekeeping
architecture that is slightly different from the timekeeping
architecture of uniprocessor machines:
 In a uniprocessor system, all time-keeping activities are
triggered by interrupts raised by the Programmable Interval
Timer.
 In a multiprocessor system, all general activities (like
handling of software timers) are triggered by the interrupts
raised by the PIT, while CPU-specific activities (like
monitoring the execution time of the currently running
process) are triggered by the interrupts raised by the local
APIC time
Usage of Jiffy: Jiffy is an informal term for any unspecified
short period of time
global variable with the jiffies which holds the number of ticks
that have occurred since the system booted. The Linux kernel
sets this variable to zero.

(b) Present the USB subsystem in Linux. Discuss the


different types of USB endpoints
Universal Service Bus is a Bus originally designed with
intention to connect PC to the telephone, ease of use, port
expansion. The USB is strictly hierarchical and it is controlled
by one host. The host uses a master / slave protocol to
communicate with attached USB devices. This means that
every kind of communication is initiated by the host and
devices cannot establish any direct connection to other devices.
This seems to be a drawback in comparison to other bus
architectures but it is not because the USB was designed as a
compromise of costs and performance. The master / slave
protocol solves implicitly problems like collision avoidance or
distributed bus arbitration. The current implementation of the
USB allows 127 devices to be connected at the same time and
the total communication bandwidth is limited to 12Mbit/s.
Howewer use of low speed devices, management of USB
"interrupts" and other overheads mean that actual throughput
cannot exceed about 8.5Mbit/s under near ideal conditions, and
typical performance may be around 2Mbit/s.
The communication on the USB is done in two directions and
uses four different transfer types. Data directed from the host to
a device is called downstream or OUT transfer. The other
direction is called upstream or IN transfer. Depending on the
device type different transfer variants are used:
 Control transfers are used to request and send reliable
short data packets.
 Bulk transfers are used to request or send reliable data
packets up to the full bus bandwidth.
 Interrupt transfers are similar to bulk transfers which
are polled periodically. I
 Isochronous transfers send or receive data streams in
realtime with guaranteed bus bandwidth but without any
reliability.
7 7 (a) Write a linux shell script to create and manage an 5 marks for
employee data file (i) Create a new entry for the new script and for
part b 3 marks
employees, (ii) Delete a record of an existing employees, (iii) for inode
Update the record of an existing employee (Entries in the description and
employee data file are separated with sign Note: All the 2 marks for the
entries should be taken from the user at run time) figure

Answer:
Var=0
While [ $var != ‘q’ ]
Do
echo “press 1 for new record”
echo “press 2 for update”
echo “press 3 for delete”
echo “press q for quit”
if [ $var = “1” ]
then
read eid
read ename
read address1
read city
read age
read salary
echo $eid : $ename : $address1 : $city : $age : $salary
>> employee
fi
if [ $var = “2” ]
then
echo “enter the eid to be updated”
read sid
grep –I $eid employee>tmp
name=’cut –d”:” –f 2 tmp’
addr=’ cut –d”:” –f 3 tmp’
city=’cut –d”:” -f4 tmp’
age=’cut –d”:” –f 5 tmp’
echo “enter the new salary”
read salary
grep –v $eid employee>tmp2
cat tmp2>employee
echo $eid : $ename : $addr1 : $city : $age : $salary >>
employee
fi
if [ $var = “3” ]
then
echo “enter the eid to be updated”
read eid
grep –v $eid employee>tmp
cat tmp>employee
fi
done

(b) Discuss how files are accessed from the secondary


memory in Linux?

A file system relies on data structures about the files, as


opposed to the contents of that file. The former are
called metadata—data that describes data. Each file is
associated with an inode, which is identified by an integer,
often referred to as an i-number or inode number.
Inodes store information about files and directories (folders),
such as file ownership, access mode (read, write, execute
permissions), and file type. On many older file system
implementations, the maximum number of inodes is fixed at
file system creation, limiting the maximum number of files the
file system can hold. A typical allocation heuristic for inodes in
a file system is one inode for every 2K bytes contained in the
filesystem.
The inode number indexes a table of inodes in a known location
on the device. From the inode number, the kernel's file system
driver can access the inode contents, including the location of
the file, thereby allowing access to the file.

8 8. (a) Give the steps to configure the DNS server and client 5+5
DNS Client
1. Create the /etc/resolv.conf file.
2. Modify the /etc/nsswitch.conf file.
a. Become superuser.
b. Open the /etc/nsswitch.conf file.
c. DNS can be the only source or an additional source
for the hosts information
d. Specify DNS as a source of hosts information.
e. Save the file and reboot.
DNS Server
1. Become superuser.
2. Set the server up as a DNS client (this includes setting up the
server's resolv.conf file).
3. Set up the boot file
4. Set up the data files. Set up four data files.
a. named.ca
b. hosts
c. hosts.rev
d. named.local
5. Initialize the server.
6. Test the server.
(b) Discuss the use of the FTP service in Linux. Give the
steps to configure and secure the FTP server.
FTP stands for “File Transfer Protocol” and is a great protocol
for downloading files from a remote or local server, or
uploading files onto the server. Using FTP proves to be a pretty
basic task after it has been setup properly. It works by having a
server that is listening for connections (on port 21 by default)
from clients. The clients can access a remote directory with
their user account, and then download or upload files there,
depending on the permissions that have been granted to them.
It’s also possible to configure anonymous authorization, which
means that users will not need their own account in order to
connect to the FTP server.
On Ubuntu Linux, there are a multitude of different FTP server
and client software packages available. You can even use
default GUI and command line tools as an FTP client. A very
popular and highly configurable FTP server package is vsftpd,
available for many Linux systems, including Ubuntu.

Steps:
1. To open an ftp connection to a remote system, invoke
the ftp command followed by the remote server IP address or
domain name
ftp 192.168.42.77
2. If the connection is established, a confirmation message will
be displayed, and you will be prompted to enter your FTP
username
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 21:35. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (192.168.42.77:localuser): linuxize
3. type password
Password:
4. If the password is correct, the remote server will display a
confirmation message and the ftp> prompt.
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
Section C
9(a) Consider an organization with more than 10,000 employees. 1 marks for
One of the common system problems is about hard disk getting df command
full, which may result in larger system-related problems. What 1 marks for
if the system administrator gets an automated alert if any of the script
employee’s hard disk capacity goes more than 90% occupation? 1 marks for
Upon getting such an alert, the system administrator can inspect mail
the system and advise the employee by cleaning up/freezing up command
some space in the hard disk. Write the shell script so that the 1 marks for
pro-active alert system can be set up. setting cron
job
Answer:
#!/bin/sh

df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " "


$1 }' | while read output;

do

echo $output

usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )

partition=$(echo $output | awk '{ print $2 }' )

if [ $usep -ge 90 ]; then

echo "Running out of space \"$partition ($usep%)\" on


$(hostname) as on $(date)" |

mail -s "Alert: Almost out of disk space $usep%"


[email protected]

fi

done

Save the script as diskAlert

# cp diskAlert /etc/cron.daily/
# chmod +x /etc/cron.daily/diskAlert

10 Trace the route being taken to connect to amazon.com. Turn off 2 marks for
(b) and disable Network Manager and start the network service. describing
route and
Answer: route and traceroute are the commands by which we traceroute
can find out the route table information and route information. commands.
Using route command, we can find out the information about 1 marks
the gateways address, NIC information e.g. Wireless, VPN or each for turn
PCI slots, and flags. Flag U says the route is up, G identifies the off, disable
interface as a gateway, and an H says the target is a host, and start the
Interface p4p1 shows that PCI slot 4, port 1, wlan0 shows network
wireless interface, tun0 shows that it is a tunnelled interface. service
If you want to follow the entire route to a host from beginning
to end, you can use the traceroute command. To find the route a
packet takes from your local system to the amazon.com site,
type the following traceroute command:
# traceroute amazon.com
It will display the maximum no of hops and time taken by each
hops in milli seconds.

The command for stopping, and disabling the services in


SysVinit is:
#systemctl stop NetworkManager
#systemctl disable NetworkManager

The command to start the network services is:


#systemctl enable Network
And after enabling restart the service using the command:
#systemctl restart Network

© Write a simple driver and explain what happens when an 3 marks for
insmod is done on the module. the code, 3
marks for
Answer: giving the
#include <linux/init.h> command to
#include <linux/module.h> load the
MODULE_LICENSE("Dual BSD/GPL"); module on
the kernel
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}

static void hello_exit(void)


{
printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

% make
make[1]: Entering directory `/usr/src/linux-2.6.10'
CC [M] /home/ldd3/src/misc-modules/hello.o
Building modules, stage 2.
MODPOST
CC /home/ldd3/src/misc-modules/hello.mod.o
LD [M] /home/ldd3/src/misc-modules/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.10'
% su
root# insmod ./hello.ko

You might also like