--- title: "Unlock User account" slug: "unlock-user-account" updated: 2024-10-10T09:36:10Z published: 2024-10-10T09:36:10Z canonical: "help.scalefusion.com/unlock-user-account" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.scalefusion.com/llms.txt > Use this file to discover all available pages before exploring further. # Unlock User account Use this script to unlock a user account on Linux machines. 1. Copy and save the contents below to a **UTF-8** editor like **notepad++** OR **Sublime Text** in Windows or **gedit** in Ubuntu. 1. If you are using **notepad++** then use the bottom right panel to change the type to **Unix (LF)**. 2. Or click [here](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/Unlock_User_Account.sh) to download the file. 3. In the script, replace the following placeholder: 1. Provide the username and hostname of the user whose account you want to unlock. # Define variables username="ENTER_USER_NAME" hostname="ENTER_USER_HOSTNAME" ```bash #!/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 ``` 1. If Hostname is invalid the script will not execute. 2. If Hostname is valid, it will next check Username and if Username is invalid or not present, script will not execute. 3. If both Hostname and Username are valid then only script will be executed. ![](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/image-80WVOU7Q.png) 4. Follow [our guide](/docs/deploy-linux-shell-scripts-using-scalefusion#step-1-upload-and-deploy-the-script) to upload & publish the script using Scalefusion Dashboard. > [!CAUTION] > Note: > > 1. Some of the scripts and their contents are sourced from internet and yes, our new friend ChatGPT. > 2. Please validate the scripts on a test machine before deploying them on all your managed devices. > 3. Scalefusion has tested these scripts, however Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the usage of these scripts.