DEV Community

Anass Assim
Anass Assim

Posted on • Edited on

4

SysInfo Script

SysInfo 🖥️: Track System Information 📊

  • This script gathers various system information such as disk usage, RAM usage, processes, IP addresses, last login details, SSH login information, and currently logged-in users.

Image description

Description 📝

The script utilizes several Linux commands to fetch and calculate system metrics, providing a snapshot of the system's current state.

Prerequisites ⚙️

Before running the script, ensure you have bc installed. If you're using Debian or a Debian-based distribution (like Ubuntu), you can install it with:

sudo apt-get update
 sudo apt-get install bc
Enter fullscreen mode Exit fullscreen mode

Installation 📥

Clone the repository:

 git clone https://github.com/ciscoAnass/SysInfo.git
 cd SysInfo
Enter fullscreen mode Exit fullscreen mode

Make the script executable:

chmod +x SysInfo.sh
Enter fullscreen mode Exit fullscreen mode

Running the Script on Every Terminal Launch (Optional) 🚀

  • If you want the script to run every time you open a terminal session, you can append the script path to ~/.bashrc using the following command:
echo "~/SysInfo/SysInfo.sh" >> ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
  • This command appends the path to your script to the end of ~/.bashrc.

  • After appending, source ~/.bashrc to apply the changes:

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
  • Now, the script will run automatically every time you open a new terminal session.

Creating a Command Alias 🔧

  • If you want to create a command alias so you can execute the script by simply typing sysinfo, follow these steps:
echo "alias sysinfo='~/SysInfo/SysInfo.sh'" >> ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

-Source ~/.bashrc to apply the changes:*

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Now, you can simply type sysinfo in your terminal to run the script.

Example Output 🖨️

After running the script, you will see output similar to:

System Information of <current_date>

Usage of / :             <DiskPer> of <DiskCapacity>
Memory Usage :           <RAM>%
Memory Swap :            <Swap>%
Total Processes :        <Processes>
Root Processes :         <RootProcesses>
IPv4 address  :         <ipv4>
IPv6 address :          <ipv6>
Last Login :            <lastlog>

<ssh_info>

Logged Users :           <LoggedUsers>
Enter fullscreen mode Exit fullscreen mode

Contributing 🤝

  • Contributions are welcome! Feel free to fork the repository and submit pull requests.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay