Skip to content
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 - Technology, Product and Cybersecurity · 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.txt BASH Script: #!/bin/bash #Variables USERNAME="testuser" # User accountname PASSWORD="P@ssw0rd" # User password GROUP="testgroup" # Custom groupname SSH_DIR="/home/$USERNAME/.ssh" PUB_KEY="ssh-rsa AAAAB3...your-public-key... user@kali" #Step 1: Check ifuser already exists if id "$USERNAME" &>/dev/null; then echo "Error: User '$USERNAME'already exists!" exit 1 fi #Step 2: Create userand set password echo "Creating user '$USERNAME'..." useradd -m -n -s /bin/bash "$USERNAME" # Error 1: -n is an invalidoption if [ $? -ne 0 ]; then echo "Error: Failed to create user'$USERNAME'" exit 1 fi echo "$USERNAME:$PASSWORD" | chpasswd echo "Password set for user '$USERNAME'." #Step 3: Add user tosudoers echo "Granting sudo access to '$USERNAME'..." usermod -aG sudo "$USERNAME" if [ $? -ne 0 ]; then echo "Error: Failed to add'$USERNAME' to sudoers" exit 1 fi #Step 4: Createcustom group and add user echo "Creating group '$GROUP' and adding user..." groupadd "$GROUP" 2>/dev/null usermod -aG "wronggroup" "$USERNAME" # Error 2:"wronggroup" does not exist if [ $? -ne 0 ]; then echo "Error: Failed to add'$USERNAME' to group '$GROUP'" exit 1 fi #Step 5: Setup SSHkey-based authentication echo "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 1 fi echo "SSH keys configured for '$USERNAME'." #Step 6: Setpassword expiry to 30 days echo "Setting password expiry policy for '$USERNAME'..." chage -M 30 "$USERNAME" if [ $? -ne 0 ]; then echo "Error: Failed to setpassword expiry" exit 1 fi #Step 7: Logactivity to/var/log/user_setup.log LOG_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 1 fi #Step 8:Confirmation Message echo "Testing SSH connection to '$USERNAME'@localhosts..." ssh "$USERNAME@localhost" if [ $? -ne 0 ]; then echo "Error: SSH connection failed." exit 1 fi echo "User '$USERNAME' created and configured successfully!"

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

Embed this episode

Ready to play

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.

No similar episodes found.

Frequently Asked Questions

How long is this episode of Learn As I Learn - Technology, Product and Cybersecurity?

This episode is 9 minutes long.

When was this Learn As I Learn - Technology, Product and Cybersecurity episode published?

This episode was published on October 31, 2025.

Can I download this Learn As I Learn - Technology, Product and Cybersecurity episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.
URL copied to clipboard!