#!/bin/bash

# Define variables
username="ENTER_USER_NAME"
hostname="ENTER_USER_HOSTNAME"

# Check if hostname is valid and present
if grep -q "^$hostname:" /etc/passwd; then
    # Check if user is valid and present
    if id "$username" &>/dev/null; then
        # Unlock user account
        sudo passwd -u "$username"
        echo "User $username has been unlocked."
    else
        echo "User $username does not exist."
        exit 1
    fi
else
    echo "Hostname $hostname not found. Exiting..."
    exit 1
fi