BCSL 63
BCSL 63
BCSL 63
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
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="[email protected]"
## sending mail to
to="[email protected]"
## send carbon copy to
also_to="[email protected]"
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
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: