Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Linux shell scripting, make a file in vi and have it execute with the followi

ID: 3882558 • Letter: I

Question

In Linux shell scripting, make a file in vi and have it execute with the following:

Ask the user to enter first and last name and greet the user.

c. Display the OS release and its Linux flavor.

d. Display the record log of your past login times (your id only).

e. Display the server available memory.

f. Display all currently running processes on the server excluding root user processes.

g. Display the server IP address only.

h. Display the server current file system.

i. Display all user IDs and owner (field 1 and field 5 from /etc/passwd file).

j. Tell the user "Good bye" and display the current date and time.

Explanation / Answer

NOTE: Script output is big, so not able to share the output. Sorry for that.Please test the script in your system and let me know if there are any concerns. I will revert back within 24 hours.

Script:

#!/bin/bash

echo "Enter the first and last name"
read name
echo "Welcome to the program $name"

# command gives os release and its linux flavour
os_details=`uname -mrs`
echo "OS Release and its flavour: $os_details"

# $USER gives the current user login id
id=`echo $USER`
echo "Past login times of user $id are:"
# last command shows all the last logins of user in $USER
last|grep $id

# displays server available memory
echo "Server available memory is: "
# we can also use "free -m" command if it is working in your system as an alternative
cat /proc/meminfo|head -2

# displays currently running processes on server excluding root user processes.
echo "All running processes except root:"
ps -ef|grep -v root

# displays server ip address only
echo "Server IP Address is:"
ifconfig -a|grep inet

# displays server current file system
echo "Server current file system is:"
df|awk 'NR>1{print $NF}'

# displays all user IDs and owner(field 1 and field 5 from /etc/passwd file)
echo "User IDs and Owner in your system are:"
cat /etc/passwd|grep -v '^#'|awk -F":" '{print $1, $5}'

# displays current date and time
echo "Good bye"
echo "Current date and time are: " `date`

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote