Hey DevCloud Ninjas! π Time for a fun Bash scripting challenge that'll help you level up your cloud skills! π
Your mission, should you choose to accept it, is to create a Bash script called vm_info.sh that gives us some basic info about our virtual machine. Here's what I want you to do:
-
Create a script that does the following:
- Prints a welcome message
- Checks and displays the number of CPU cores
- Shows the total amount of RAM
- Displays the available disk space
- Lists the top 3 processes using the most CPU
-
Use if-else statements to:
- Check if the user running the script is root
- If they are, print a warning message
-
Implement a simple while loop that:
- Asks the user if they want to see current CPU usage
- If yes, show the CPU usage every 5 seconds until the user presses Ctrl+C
- If no, exit the script with a goodbye message
Here's a template to get you started:
#!/bin/bash
echo "Welcome to VM Info Script!"
# Your code here
echo "Script finished. Keep rocking, DevCloud Ninjas!"Remember to make your script executable with chmod +x vm_info.sh before running it.
Bonus points if you can add error handling or make the output colorful! π
Drop your scripts in the comments when you're done. Let's see what you've got, Ninjas! And remember, if you get stuck, our community is here to help. Happy scripting! π»βοΈ