Skip to main content

Command Palette

Search for a command to run...

Shell Scripting Mini Project | Day#6

Updated
2 min read
Shell Scripting Mini Project | Day#6
A

My name is Abhishek vishwakarma and I am very exciting with devops field. I have a great interest in cloud computing technology and devops field, CI-CD, containerization, and automation and I am constantly exploring new ways to improve the software development and deployment process. I believe to solve real life problem in a simple way that can save time and money of organization bey implementing automation tools. Join with me on my in this journey in DevOps world.

This mini project will show the current username, date and time and Disk space and RAM utilization details.

✦ Welcome the user, show the current 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

we will create a .sh file in which all script will be incorporated and then we execute .sh file and we will provide execute permission by below commands.

Commands to create a script file.

COPY

touch script.sh
chmod +x <filename.sh> //filename is script.sh

#To display the current user we use the below command

COPY

whoami

#command which shows the date and time

COPY

date

#uptime command is used to find out how long the system is active (running)

COPY

uptime

#to find the last login details we use last command

COPY

last

#memory command which gives details about disk space

COPY

df -H

#memory command which gives details about RAM

COPY

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

Here is the project implementation

CPU Utilization: free commands is used to show the utilization

#we need available /total ($13/$8)

COPY

free | xargs |awk '{print $13 "/" $8}'

#Show the top CPU processes, we use top command

COPY

top

Below are the script written in myfirst.sh script file.

Output: