Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save onlyfave/9f1eb74dfebf1d2945872b38bc7d6b5b to your computer and use it in GitHub Desktop.

Select an option

Save onlyfave/9f1eb74dfebf1d2945872b38bc7d6b5b to your computer and use it in GitHub Desktop.

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:

  1. 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
  2. Use if-else statements to:

    • Check if the user running the script is root
    • If they are, print a warning message
  3. 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! πŸ’»β˜οΈ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment