Sei sulla pagina 1di 8

Q1.

a) Run following command and write output:

Ans:

i) Ping www.google.com
PING www.google.com (172.217.167.36) 56(84) bytes of data.
64 bytes from del03s16-in-f4.1e100.net (172.217.167.36): icmp_seq=1 ttl=54 time=9.95 ms
64 bytes from del03s16-in-f4.1e100.net (172.217.167.36): icmp_seq=2 ttl=54 time=7.03 ms
64 bytes from del03s16-in-f4.1e100.net (172.217.167.36): icmp_seq=3 ttl=54 time=9.98 ms
64 bytes from del03s16-in-f4.1e100.net (172.217.167.36): icmp_seq=4 ttl=54 time=8.69 ms
64 bytes from del03s16-in-f4.1e100.net (172.217.167.36): icmp_seq=5 ttl=54 time=183 ms
64 bytes from del03s16-in-f4.1e100.net (172.217.167.36): icmp_seq=6 ttl=54 time=7.08 ms
--- www.google.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 20ms
rtt min/avg/max/mdev = 7.026/37.671/183.306/65.140 ms
ii) Arp
Address HWtype HWaddress Flags Mask Iface
_gateway ether 04:95:e6:81:6c:c8 C eth0

iii) Finger root


Login: root Name: root
Directory: /root Shell: /bin/bash
On since Mon Sep 30 11:21 (EDT) on :1 from :1 (messages off)
No mail.
No Plan.

iv) diskperf –help


DISKPERF [-Y[D|V] | -N[D|V]] [\\computername]

-Y Sets the system to start all disk performance counters


when the system is restarted.

-YD Enables the disk performance counters for physical drives.


when the system is restarted.
-YV Enables the disk performance counters for logical drives
or storage volumes when the system is restarted.
-N Sets the system to disable all disk performance counters
when the system is restarted.

-ND Disables the disk performance counters for physical drives.


-NV Disables the disk performance counters for logical drives.
\\computername Is the name of the computer you want to
see or set disk performance counter use.
The computer must be a Windows 2000 system.
v) Rcp
usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program] source ... target

>> To copy a single file


rcp rahulpc:/usr/data/customers.txt .

>> To copy folder


rcp -r rahulpc:/usr/data .

Q1. b) Explore the following directories and write its contents:

i) Ls /bin
'[' ndisasm
0trace.sh neato
2to3-2.7 neotoppm
411toppm neqn
7z net
7za netaddr
7zr netcat
.
.
.
.
ncurses6-config zmore
ncursesw5-config znew
ncursesw6-config zsh
ndiff zsh5

ii) Ls /usr/bin
'[' ndisasm
0trace.sh neato
2to3-2.7 neotoppm
411toppm neqn
7z net
.
.
.
ncurses5-config zless
ncurses6-config zmore
ncursesw5-config znew
ncursesw6-config zsh
ndiff zsh5
iii) Ls /sbin
a2disconf grpconv pvremove
a2dismod grpunconv pvresize
a2dissite grub-bios-setup pvs
a2enconf grub-install pvscan
.
.
.
groupmems pvcreate zramctl
groupmod pvdisplay
grpck pvmove

iv) Ls /tmp
ssh-rShCJzz7804J
systemd-private-f904e7f19c0141858735a41eeb5100d7-bolt.service-gvLr4G
systemd-private-f904e7f19c0141858735a41eeb5100d7-colord.service-AtNzDB
systemd-private-f904e7f19c0141858735a41eeb5100d7-fwupd.service-exDrd9
systemd-private-f904e7f19c0141858735a41eeb5100d7-haveged.service-zZSHf4
systemd-private-f904e7f19c0141858735a41eeb5100d7-ModemManager.service-k8FgLb
systemd-private-f904e7f19c0141858735a41eeb5100d7-rtkit-daemon.service-6p1yLC
systemd-private-f904e7f19c0141858735a41eeb5100d7-upower.service-sSJRay
tracker-extract-files.0

v) Ls /boot
grub
config-4.19.0-kali4-amd64
initrd.img-4.19.0-kali4-amd64
vmlinuz-4.19.0-kali4-amd64
System.map-4.19.0-kali4-amd64

Q2. a) Write a shell script that determines whether the given file exists in the home directory or not.

Ans:

#!/bin/bash
file="test.txt"
if [ ! -f "$file" ]
then
echo "${file} file not found."
else
echo "$file file exists"
fi
Q2. b) Write a shell script to check a proper utilization of disk space and send an email to the user
currently logged in.
Ans:
#!/bin/bash
## declare mail variables
##email subject
subject="Memory Status Alert"
##sending mail as
from="server.monitor@rahulpc.com"
## sending mail to
to="root@rahulpc.com"
## send carbon copy to
also_to="admin@rahulpc.com"

## get total free memory size in megabytes(MB)


free=$(free -mt | grep Total | awk '{print $4}')

## check if free memory is less or equals to 100MB


if [[ "$free" -le 100 ]]; then
## get top processes consuming system memory and save to temporary file
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head >/tmp/top_proccesses_consuming_$

file=/tmp/top_proccesses_consuming_memory.txt
## send email if system memory is running low
echo -e "Warning, server memory is running low!\n\nFree memory: $free MB" | mailx$
fi
exit 0

Q3. a) Set the execution time of two jobs so that it can run automatically tomorrow one at 11:00 a.m.
and another at 1:00 p.m. After this setting, how can you change the time of execution of the job?
Ans: To schedule a task in unix like system i.e. Ubuntu we use cron, it comes preinstalled with almost
every unix system. To schedule a task lets follow below steps:
1. To use cron for tasks meant to run only for your user profile, add entries to your own user’s
crontab file. To edit the crontab file enter:
crontab -e
2. To schedule tasks that require administrative privileges (i.e. they are generally run using sudo),
you should edit the root crontab:
sudo crontab -e
3. To run a task at 11:00 am tomorrow, enter below line
0 11 * * * /home/rahul/task1
4. To run a task at 11:00 am tomorrow, enter below line
0 13 * * * /home/rahul/task2
5. Save and quit the crontab
To edit crontab entry to re-schedule task use the same command “crontab -e” and modify the
entries as require.

Q3. b) Add different user’s and groups. Also configure their permissions.
Ans:
Group:
1. Create a group
sudo groupadd mynewgroup
2. Create a New User and Assign a Group in One Command
useradd -G ftp jsmith
3. To change password of currently created user
passwd jsmith
4. Add a User to Multiple Groups
usermod -a -G ftp,sudo,example geek
5. View All Groups on the System
getent group
6. Add an Existing User Account to a Group
usermod -a -G sudo geek
7. Change a User’s Primary Group
usermod -g groupname username
8. To change user permission we can add it in root group also

Q3. c) Share any folder available in your directory. Also configure its share permissions for different
users.
Ans:
To share folder or file in unix environment we required to install samba server, the steps to
install samba server are as follow:
1. sudo apt install samba
2. Now open “/etc/samba/smb.conf” file and edit as follow
[share]
comment = Ubuntu File Server Share
path = /home/rahul
browsable = yes
guest ok = yes
read only = no
create mask = 0755
[allusers]
comment = All Users
path = /srv/samba/allusers/
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
writable = yes

3. To add a share that is accessible by all users


sudo mkdir -p /srv/samba/
sudo chown -R root:users /srv/samba/ [brusgroup][financial]
sudo chmod -R ug+rwx,o+rx-w /srv/samba/

4. Restart the samba service


sudo service smbd restart
sudo service nmbd restart

Q3. d) Configure the DHCP Server Service.


Ans:
Step 1: Installing DHCP Server in Ubuntu
1. Run the command below to install the DCHP server package, which was formerly known as
dhcp3-server.
$ 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"
And also learn how to configure a static IP address for the interface above.

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;
}

Step 3: Configure Static IP on DHCP Client Machine


6. To assign a fixed (static) IP address to a particular client computer, add the section below where
you need to explicitly specify it’s MAC addresses and the IP to be statically assigned:
host centos-node {
hardware ethernet 00:f0:m4:6y:89:0g;
fixed-address 192.168.10.105;
}
host fedora-node {
hardware ethernet 00:4g:8h:13:8h:3a;
fixed-address 192.168.10.106;
}
Save the file and close it.

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, do not forget to 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

Q3. e) Monitor the IP Routing status.


Ans:
Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes to specific
hosts or networks via an interface after it has been configured with the ifconfig(8) program.
When the add or del options are used, route modifies the routing tables. Without these options, route
displays the current contents of the routing tables. Example command output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0

Potrebbero piacerti anche