Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Please follow the instructions..

1 answer below »
Answered Same Day Dec 27, 2021

Solution

Ria answered on Jan 12 2021
131 Votes
11646357/Abid_11646357_Assessment_3.docx
Assessment item 3
Installing and Managing Linux
y Saad Sultan Mehmood Abid
Submission date: 12-Jan-2020
Submission ID:
File name: Abid_11646357_Assessment_3.docx
Lecturer’s name:
Contents
Section A: Shell scripting and file system ……………………………………………………………………………………………………… Page 3
Section A.1: Create an ASCII table ………………………………………………………………………………………………… Page 3
Section A.2: Determine mounted file system’s type ………………………………………………………………………. Page 7
Section B: Networking and scripting ………………………………………………………………………………………………………… Page 12
Section C: Account Management …………………………………………………………………………………………………………….. Page 14
Section C.1: Add new users ……………………………………………….………………………………………………………… Page 14
Section C.2: Show users ………………………………………………………………………………………………………………. Page 17
Section D: Implementing the file system and storage …………………………………………………………………………………… Page 18
Section A: Shell scripting and file system
Section A.1:
Shell script:
#!
in
ash
# ASCII characters from 0 to 127 in decimal, octal and hexadecimal
echo -e "\nASCII Table:\n"
echo "-----------------------------------------------------------------"
echo "|    dec    |    oct    |    hex    |    char    |"
echo "-----------------------------------------------------------------"
table=(nul soh stx etx eot enq ack bel bs tab nl vt np cr so si dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us sp) #a
ay
#for 0 to 127 loop
for ((dec=0; dec<=127; dec++))
do
oct=$(echo "obase=8;$dec" | bc) #for octal
hex=$(echo "obase=16;$dec" | bc) #for hex
if test $dec -le 32 #if the decimal number is less than equal to 32
then
    char=${table[$dec]}
else
    if test $dec -eq 42 #if the decimal number is 42
    then
        char="*"
    elif test $dec -eq 127 #if the decimal number is 127
    then
        char="del"
    elif test $dec -gt 32 #if the decimal number is greater than 32
    then
        char=$(printf \\$(printf '%03o' $dec))
    fi
fi
echo "|    $dec    |    $oct    |    $hex    |    $char    |"
done
echo "-----------------------------------------------------------------";echo
Explanation:
table=(nul soh stx etx eot enq ack bel bs tab nl vt np cr so si dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us sp)
· It’s an a
ay with 33 values
oct=$(echo "obase=8;$dec" | bc)
· Decimal to octal
hex=$(echo "obase=16;$dec" | bc)
· Decimal to hexadecimal
char=$(printf \\$(printf '%03o' $dec))
· Decimal to characte
Terminal:
Section A.2:
In this task, you are required to determine the mounted file system’s type. To complete this task, you should write a shell script to:
a. Mount a USB flash drive at the mount point of /mnt/studentID.
. List all mounted filesystems and redirect the list to a file called $studentID.dat.
c. Read StudentID.dat and display the file system’s type.
Shell script:
#!
in
ash
# create mnt/11646357
sudo mkdir mnt
cd mnt
sudo mkdir 11646357
cd
echo -e "\n1. Created directory mnt/11646357\n"
# mount a USB flash drive at the mount point of mnt/11646357
sudo mount /dev/sdb1 mnt/11646357
echo -e "2. Mounting successful at the mount point of mnt/11646357\n"
# create 11646357.dat
touch 11646357.dat
echo -e "3. Created file 11646357.dat\n"
# list all mounted file systems and redirect the list to a called 11646357.dat
df -Th > 11646357.dat
echo -e "4. List all mounted file systems and redirect the list to a called 11646357.dat and the content of the file:\n"
cat -n 11646357.dat
echo
# determine mounted file system's type
echo -ne "5. Display the file system's type: "
type=$(cat 11646357.dat | grep "^/dev/sdb1")
echo $type | cut -d" " -f 2
echo
Explanation:
sudo mkdir mnt
· Created directory mnt
cd mnt
· Change directory to mnt
sudo mkdir 11646357
· Created directory 11646357
cd
· Change directory close
sudo mount /dev/sdb1 mnt/11646357
· Mount a USB flash drive at the mount point of mnt/11646357
touch 11646357.dat
· Create 11646357.dat
df -Th > 11646357.dat
· List all mounted file systems and redirect the list to a called 11646357.dat
cat -n 11646357.dat
· Display the content of the file
type=$(cat 11646357.dat | grep "^/dev/sdb1")
· Get the USB flash details from the 11646357.dat file and store it into ‘type’
echo $type | cut -d" " -f 2
· Cut the type of the USB flash which is in the field 2 and display it
Terminal:
Figure 1: Run mount-11646357.sh and display 11646357.dat
Figure 2: Created 11646357.dat file and the USB is mounted. And created mnt/ directory.
Figure 3: Created 11646357/ directory into mnt/ directory. It is mounted.
Figure 4: The files of 11646357 folder which is mounted.
Figure 5: Contents of 11646357.dat file.
Section B: Networking and scripting
Shell script:
#!
in
ash
# displaying all the IP addresses to which the server is connected
ip addr show enp0s3 | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/'
Explanation:
ip addr show
· List all the IP addresses
ip addr show enp0s3
· List all the IP addresses except the default one.
ip addr show enp0s3 | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/'
· List all the IP addresses except the default one with
· ‘inet’ in it
· $2 place
· Delimiter is ‘/’ and field is 1
Terminal:
Figure 1: >ip addr show (ip addesses show) in where we know that first one is default and we need the second one (enp0s3). So in shell script we take it and cut it and displaying only the IP address.
Section C: Account...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here