Series 4: Ep 7: Debugging Your Code episode artwork

EPISODE · Oct 31, 2025 · 9 MIN

Series 4: Ep 7: Debugging Your Code

from Learn As I Learn · host Akanksha Pathak

Don't let errors stop you! This episode focuses on practical debugging techniques for both PowerShell and Bash scripts. We'll intentionally introduce common errors (like typos or wrong parameters) and walk through how to identify and fix them, building crucial troubleshooting skills.Powershell Script:#Script to log multiple event IDs$BeginTime = (Get-Date).AddMinutes(-20)Get-EventLog -LogName "Securityy" -After $BeginTime |Where-Object { $_.EventID -in '4624', '4625'} |Select-Object TimeGenerated, EventID, Message |Format-Table -AutoSize |Out-Files C:\EventLogs_MultipleEvents.txtBASH Script:#!/bin/bash#VariablesUSERNAME="testuser" # User accountnamePASSWORD="P@ssw0rd" # User passwordGROUP="testgroup" # Custom groupnameSSH_DIR="/home/$USERNAME/.ssh"PUB_KEY="ssh-rsa AAAAB3...your-public-key... user@kali"#Step 1: Check ifuser already existsif id "$USERNAME" &>/dev/null; then  echo "Error: User '$USERNAME'already exists!"  exit 1fi#Step 2: Create userand set passwordecho "Creating user '$USERNAME'..."useradd -m -n -s /bin/bash "$USERNAME" # Error 1: -n is an invalidoptionif [ $? -ne 0 ]; then  echo "Error: Failed to create user'$USERNAME'"  exit 1fiecho "$USERNAME:$PASSWORD" | chpasswdecho "Password set for user '$USERNAME'."#Step 3: Add user tosudoersecho "Granting sudo access to '$USERNAME'..."usermod -aG sudo "$USERNAME"if [ $? -ne 0 ]; then  echo "Error: Failed to add'$USERNAME' to sudoers"  exit 1fi#Step 4: Createcustom group and add userecho "Creating group '$GROUP' and adding user..."groupadd "$GROUP" 2>/dev/nullusermod -aG "wronggroup" "$USERNAME" # Error 2:"wronggroup" does not existif [ $? -ne 0 ]; then  echo "Error: Failed to add'$USERNAME' to group '$GROUP'"  exit 1fi#Step 5: Setup SSHkey-based authenticationecho "Setting up SSH key-based authentication..."mkdir -p "$SSH_DIR"echo "$PUB_KEY" > "$SSH_DIR/authorized_keys"chmod 600 "$SSH_DIR/authorized_keys"chmod 700 "$SSH_DIR"chown -R "$USERNAME:$USERNAME" "$SSH_DIR"if [ $? -ne 0 ]; then  echo "Error: Failed to set up SSHkeys"  exit 1fiecho "SSH keys configured for '$USERNAME'."#Step 6: Setpassword expiry to 30 daysecho "Setting password expiry policy for '$USERNAME'..."chage -M 30 "$USERNAME"if [ $? -ne 0 ]; then  echo "Error: Failed to setpassword expiry"  exit 1fi#Step 7: Logactivity to/var/log/user_setup.logLOG_FILE="/var/log/user_setup.log"echo "$(date) - User '$USERNAME' created and configured" >>"$LOG_FILE"if [ $? -ne 0 ]; then  echo "Error: Failed to write logto $LOG_FILE"  exit 1fi#Step 8:Confirmation Messageecho "Testing SSH connection to '$USERNAME'@localhosts..."ssh "$USERNAME@localhost"if [ $? -ne 0 ]; thenecho "Error: SSH connection failed."exit 1fiecho "User '$USERNAME' created and configured successfully!"

Episode metadata supplied by the publisher feed · Published Oct 31, 2025

Don't let errors stop you! This episode focuses on practical debugging techniques for both PowerShell and Bash scripts. We'll intentionally introduce common errors (like typos or wrong parameters) and walk through how to identify and fix them, building crucial troubleshooting skills.Powershell Script:#Script to log multiple event IDs$BeginTime = (Get-Date).AddMinutes(-20)Get-EventLog -LogName "Securityy" -After $BeginTime |Where-Object { $_.EventID -in '4624', '4625'} |Select-Object TimeGenerated, EventID, Message |Format-Table -AutoSize |Out-Files C:\EventLogs_MultipleEvents.txtBASH Script:#!/bin/bash#VariablesUSERNAME="testuser" # User accountnamePASSWORD="P@ssw0rd" # User passwordGROUP="testgroup" # Custom groupnameSSH_DIR="/home/$USERNAME/.ssh"PUB_KEY="ssh-rsa AAAAB3...your-public-key... user@kali"#Step 1: Check ifuser already existsif id "$USERNAME" &>/dev/null; then  echo "Error: User '$USERNAME'already exists!"  exit 1fi#Step 2: Create userand set passwordecho "Creating user '$USERNAME'..."useradd -m -n -s /bin/bash "$USERNAME" # Error 1: -n is an invalidoptionif [ $? -ne 0 ]; then  echo "Error: Failed to create user'$USERNAME'"  exit 1fiecho "$USERNAME:$PASSWORD" | chpasswdecho "Password set for user '$USERNAME'."#Step 3: Add user tosudoersecho "Granting sudo access to '$USERNAME'..."usermod -aG sudo "$USERNAME"if [ $? -ne 0 ]; then  echo "Error: Failed to add'$USERNAME' to sudoers"  exit 1fi#Step 4: Createcustom group and add userecho "Creating group '$GROUP' and adding user..."groupadd "$GROUP" 2>/dev/nullusermod -aG "wronggroup" "$USERNAME" # Error 2:"wronggroup" does not existif [ $? -ne 0 ]; then  echo "Error: Failed to add'$USERNAME' to group '$GROUP'"  exit 1fi#Step 5: Setup SSHkey-based authenticationecho "Setting up SSH key-based authentication..."mkdir -p "$SSH_DIR"echo "$PUB_KEY" > "$SSH_DIR/authorized_keys"chmod 600 "$SSH_DIR/authorized_keys"chmod 700 "$SSH_DIR"chown -R "$USERNAME:$USERNAME" "$SSH_DIR"if [ $? -ne 0 ]; then  echo "Error: Failed to set up SSHkeys"  exit 1fiecho "SSH keys configured for '$USERNAME'."#Step 6: Setpassword expiry to 30 daysecho "Setting password expiry policy for '$USERNAME'..."chage -M 30 "$USERNAME"if [ $? -ne 0 ]; then  echo "Error: Failed to setpassword expiry"  exit 1fi#Step 7: Logactivity to/var/log/user_setup.logLOG_FILE="/var/log/user_setup.log"echo "$(date) - User '$USERNAME' created and configured" >>"$LOG_FILE"if [ $? -ne 0 ]; then  echo "Error: Failed to write logto $LOG_FILE"  exit 1fi#Step 8:Confirmation Messageecho "Testing SSH connection to '$USERNAME'@localhosts..."ssh "$USERNAME@localhost"if [ $? -ne 0 ]; thenecho "Error: SSH connection failed."exit 1fiecho "User '$USERNAME' created and configured successfully!"

PodParley-generated summary based on available episode metadata and transcript content.

NOW PLAYING

Series 4: Ep 7: Debugging Your Code

0:00 9:05

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

Eat to Live Jenna Fuhrman, Dr. Fuhrman Our health is our most precious gift and smart nutrition can change your life. Each month, join Dr. Fuhrman and his daughter, Jenna Fuhrman as they discuss important topics in the world of nutrition. Eat to Live will change the way you eat and think about food. That Hoarder: Overcome Compulsive Hoarding That Hoarder Hoarding disorder is stigmatised and people who hoard feel vast amounts of shame. This podcast began life as an audio diary, an anonymous outlet for somebody with this weird condition. That Hoarder speaks about her experiences living with compulsive hoarding, she interviews therapists, academics, researchers, children of hoarders, professional organisers and influencers, and she shares insight and tips for others with the problem. Listened to by people who hoard as well as those who love them and those who work with them, Overcome Compulsive Hoarding with That Hoarder aims to shatter the stigma, share the truth and speak openly and honestly to improve lives. The Small Business Startup School – Business Notes | Financial Literacy | Retail Psychology – For Professionals & Entrepreneurs The Small Business Startup School Inc. Starting or buying a small business? While personal circumstances may vary, business patterns remain timeless. On The Small Business Startup School, we explore strategies, insights, and practical solutions to help entrepreneurs confidently navigate their journey.Hosted by Ola Williams—a retail entrepreneur, fintech founder, and financial coach with over two decades of experience—this podcast marries financial awareness and retail psychology with optimism to deliver actionable takeaways.Join us to learn, grow, and connect as we uncover the keys to business success.Let’s continue to learn together and be encouraged to keep on connecting! PodQuesting Dwight J Randolph- WolfShield Media PodQuesting: -By WolfShield Media and Dwight J RandolphJoin us on an exciting journey to master the world of fiction podcasting! At PodQuesting, we document our quest to improve and innovate, sharing valuable insights, strategies, and behind-the-scenes tips along the way. Whether you're an experienced podcaster or just starting your first show, our podcast is your go-to resource for everything podcasting.Discover practical advice, creative techniques, and lessons from our own experiences as we explore the ever-evolving podcasting landscape. Ready to level up your skills and embark on this adventure with us? Tune in and join the quest!Have questions or feedback? Reach out to us at [email protected] and visit our website:WolfShield.Media

Frequently Asked Questions

How long is this episode of Learn As I Learn?

This episode is 9 minutes long.

When was this Learn As I Learn episode published?

This episode was published on October 31, 2025.

What is this episode about?

Don't let errors stop you! This episode focuses on practical debugging techniques for both PowerShell and Bash scripts. We'll intentionally introduce common errors (like typos or wrong parameters) and walk through how to identify and fix them,...

Can I download this Learn As I Learn episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!