Hi Everyone! I have completed a small task on shell scripting which gives knowledge of a few commands. Please find the task below :)
Shell Script based on the below criteria
✦ Welcome the user, with greetings to his/her username
✦ Show the date and time
✦ Show the uptime of the server and the last logins
✦ Show the disk space and RAM utilization
✦ Show the top CPU processes
✦ Add more beautification and commands if you know them
#To display the current user we use the $whoami command
#command which shows the date and time $date
#uptime is used to find out how long the system is active (running) $uptime
#to find last login details $last if we want first no.of details then we can use $head
#memory command which gives details about disk space is $df -H
#memory command which gives details about RAM is $free
Disk Space: Out of the overall size of 8.2G(8th arg) used is 2.1G(9th arg)and available is 6.2G(10th arg)
#The available disk space is $10 / $8
df -H | xargs | awk '{ print $10 "/" $8 }'
CPU Utilization: free
#we need available /total ($13/$8)
free | xargs |awk '{print $13 "/" $8}'
#Show the top CPU processes, we use $top command
Script:
output: