--- title: "Block URLs/Websites" slug: "block-urlswebsites" updated: 2026-03-11T07:34:34Z published: 2026-03-11T07:34:34Z canonical: "help.scalefusion.com/block-urlswebsites" --- > ## 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. # Block URLs/Websites Use this script to block the websites defined in the script on the Linux machine. > [!CAUTION] > Note: > > This document describes a legacy script-based approach to blocking websites on Linux devices. This method is being deprecated. For improved security, scalability, and centralized management, we recommend using [Secure Web Gateway (SWG)](/docs/secure-web-gateway). 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-054FHID5.png) 2. Or click [here](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/block_websites.sh) to download the file. ```bash #!/bin/bash # Get the current username USERNAME=$(whoami) # Add the user to sudoers.d directory to restrict their permissions echo "$USERNAME ALL=(ALL) /bin/echo 'Permission denied'" | sudo tee /etc/sudoers.d/block_websites >/dev/null # Define the list of websites to block WEBSITES=(    "www.example.com"    "www.facebook.com") # Add entries to block the websites to hosts file for website in "${WEBSITES[@]}"; do    echo "0.0.0.0 $website" | sudo tee -a /etc/hosts >/dev/null done # Flush DNS cache sudo systemctl restart systemd-resolved.service echo "Websites are now blocked." ``` 3. In the script, replace the following placeholder: 1. **WEBSITES=()**: Provide a list of URLs with each URL in a new line, that you want to block. 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.