--- title: "Unlock Folders" slug: "unlock-folders" updated: 2024-10-10T09:37:34Z published: 2024-10-10T09:37:34Z canonical: "help.scalefusion.com/unlock-folders" --- > ## 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 Folders Use this script to lock the following folders: Documents, Downloads, Music, Pictures, Videos, snap, Public, Templates for both Standard and Sudo Users 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)**. ![](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/image-OGJWY6DP.png) 2. Or click [here](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/UnLock_Folder_Script.sh) to download the file. ```bash #!/bin/bash # Define directories to unlock DIRECTORIES=("Documents" "Downloads" "Music" "Pictures" "Videos" "snap" "Public" "Templates") # Function to unlock folders for a given user unlock_folders() {    local user="$1"    local home_dir="/home/$user"        echo "Processing user: $user"    # Check if home directory exists    if [ ! -d "$home_dir" ]; then        echo "Error: Home directory $home_dir not found for user $user"        return    fi        # Loop through each directory and unlock it    for DIR in "${DIRECTORIES[@]}"; do        local folder="$home_dir/$DIR"        if [ -d "$folder" ]; then            sudo chattr -i "$folder"            if [ $? -eq 0 ]; then                echo "Unlocked $folder for user $user"            else                echo "Failed to unlock $folder for user $user"            fi        else            echo "Directory $folder does not exist for user $user"        fi    done } # Check if script is run with root privileges if [ "$(id -u)" != "0" ]; then    echo "This script must be run with root privileges. Exiting."    exit 1 fi # Discover all user directories under /home except for system users (UID >= 1000) for user_dir in /home/*; do    user=$(basename "$user_dir")    if [ "$user" != "lost+found" ] && [ $(id -u "$user") -ge 1000 ]; then        unlock_folders "$user"    fi done echo "All specified directories are now unlocked for all users." ``` ```plaintext ``` 3. 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.