# Getting Started with Bash Scripting: My Weekly Dev Journey 🚀

Hey everyone! 👋 I'm Nishant, and this week I took my first steps into the world of **Bash scripting**. It was a great experience that helped me understand how powerful the command line can be. Here's a quick breakdown of what I worked on!

---

## 🔰 Level 1: Basic System Info Script

### 🎯 Goal:

To get familiar with basic Linux commands, variables, and how to output useful system info with a simple script.

### 📌 What the Script Does:

* Shows the **hostname** of the machine
    
* Displays the **OS name & version**
    
* Prints the system **uptime**
    
* Displays **free RAM and disk space**
    
* Lists currently **logged-in users**
    

### 💡 Commands Used:

```
hostname
uname -a
uptime
free -h
df -h
who
```

### 📜 Script:

```
#!/bin/bash

echo "📍 Host Name:"
hostname

echo "📦 OS Name and Info:"
uname -a

echo "⏱️ Uptime:"
uptime

echo "🧠 Free RAM and Disk Space:"
free -h
df -h

echo "👥 Logged-in Users:"
who
```

### 📝 Takeaway:

These basic commands give you a powerful summary of your system with just a few lines of code. I now understand how Bash can help automate routine checks easily!

---

## 🧰 Level 2: Backup Script

### 🎯 Goal:

To get hands-on with conditionals, loops, and simple automation.

### 📌 What the Script Does:

* Takes a target folder (e.g. `/home/nishant/Documents`)
    
* Creates a compressed `.tar.gz` backup file
    
* The filename includes the **current date**
    

### 💡 Concepts Learned:

* Using `tar` for compression
    
* Getting the current date using `date`
    
* `if` statements to check if directories exist
    
* Using `mkdir` to create folders
    
* Bonus: Learned how to schedule backups using `cron`
    

### 📜 Script:

```
#!/bin/bash

echo "Welcome to the backup program"

BACKUP_FILE="backup_$(date +'%Y-%m-%d_%H-%M-%S').tar.gz"
TARGET_DIR="/mnt/f/Programming/Linux/"

if [ -d "$TARGET_DIR" ]; then
    echo "Backing up..."
    tar -cvpzf "$BACKUP_FILE" "$TARGET_DIR"
    echo "Backup Done ✅"
else
    echo "❌ Cannot create backup"
    echo "Directory $TARGET_DIR does not exist"
    exit 1
fi
```

### 📚 Resource:

I followed [this helpful YouTube video](https://youtu.be/9Xl1ZTk3BQw?si=E8eVG49nW21cZ5UW) and articles on GeeksforGeeks to guide me.

---

## ✅ What's Next?

I'm planning to dive deeper into Bash with more real-world scripts and maybe even explore cron jobs and log monitoring.

📢 I’ll be posting more on **Monday**, so stay tuned for the next update!

If you're new to Linux or Bash scripting, these projects are a great place to start. Simple, fun, and very practical!

Thanks for reading 🙌

Connect with me on [LinkedIn](https://www.linkedin.com/in/nishant-kumar-b8aa6b313/) 😊

#bash #linux #scripting #devops #nishantcodes #learning
