Deploy Linux Shell scripts using Scalefusion
  • 11 Mar 2024
  • 8 Minutes to read
  • PDF

Deploy Linux Shell scripts using Scalefusion

  • PDF

Article Summary

Shell scripts are a powerful tool for automating tasks and simplifying configuration and can be used to automate almost any task in the Windows ecosystem. With a carefully designed script, you can automate various administrative tasks like adding users, installing applications, checking for OS updates to name a few. It becomes imperative for an MDM solution to provide support to be able to push scripts and then view detailed output.

Scalefusion offers you a powerful interface that lets you push scripts to all your devices and view detailed output on each of them. Follow the steps below to deploy a script and view the output.


  1. Enroll a Linux Device.
  2. Scalefusion Enterprise Plan.

Step 1: Upload and Deploy the script

  1. Navigate to Application Management > Enterprise Store , click on Upload New App and select Upload Linux Script
  2. Using the script upload wizard upload your script and click Save
    1. Script Name: Provide a name for your reference
    2. Upload Script File: Click on the upload arrow and upload the script file from your local machine.
  3. Once the script is saved you will be provide an option to publish the script. Select the profiles where you want to publish it and click Publish.
    1. Once a script is published a push is sent to the devices and on all devices which are online the execution will start.

Once a script is published to the profile, all new devices enrolled here after will automatically execute this script post enrollment.

Step 2: View Status & Unpublish

  1. All the uploaded scripts appear in the Enterprise store section. Clicking on Publish allows you to view details of the script.
    1. Publish: Use this option to publish the script to device profiles.
    2. Unpublish: Use this option to unpublish the script from device profiles.
      Please note that this option would not undo the changes that the script did. Un-publishing would cause the script not be executed on the newly enrolled devices.
    3. Summary: The summary pane gives you the information and current execution status,
      1. Size: Indicates the size of script
      2. Uploaded On: The time when this script was uploaded.
      3. Installed On: Number of devices where it is executed.
      4. Published To: Number of devices where it is published to.
        The Installed On and Published To stats are retained even after a script is unpublished.
    4. Preview: Use this option to preview the script that you uploaded.
    5. View Status: Use this option to get detailed status of the script execution on each device and the output.
      1. Click on View Detailsto check the output of the script execution.
        1. Stdout: This tab gives you the output of the script.
        2. Stderr: This tab gives you the error if any from the script execution.

Frequently Asked Questions

  1. Question: How often the script is executed?
    1. For now the script is only executed once the device receives it. We are looking at adding support for scheduling.
  2. Question: Why does not the script execute again even when we Unpublish and Publishit again on the same profile?
    1. Our current implementation requires you to delete the script completely and upload it again on the same profile if you want to execute it again.

Helper Scripts

We have curated some helper scripts, that lets you perform some administrative tasks readily. Please click on the links below to download the scripts and before using them, please replace the placeholders in them.

Please ensure that you use a UTF-8 editor like gedit on Ubuntu or notepad++ on Windows or Sublime Text so as to ensure that the generated script file is UTF-8 encoded.
  1. Click on the Script link in the Script column which opens the script in a new browser window.
  2. Copy the contents to a UTF-8 editor like notepad++ OR Sublime Text in Windows or geditin Ubuntu
    1. If you are using notepad++ then use the bottom right panel to change the type to Unix (LF)
  3. Update the script and replace the placeholders as required.
  4. Upload the script to Scalefusion Dashboard and deploy it to the devices.



Placeholders to Replace

Allow Keyboard & Mouse

Use this script to allow input devices when you choose to block the USB devices via the device profile.


Create a Local Standard UserUse this script to create a local user with standard privileges.

SET_USERNAME: Desired username

SET_PASSWORD: Desired password

Create a Local Sudo/Root UserUse this script to create a local user with sudo/root privileges.

SET_USERNAME: Desired username

SET_PASSWORD: Desired password

Change Password for a UserUse this script to change the password for a local user.

SET_USERNAME: Username for which the password has to be changed.

NEW_PASSWORD: New password for the user

List All usersUse this script to retrieve the list of users on each device.None
Install Google ChromeUse this script to install Google Chrome.


Install Any App using FlatpackUse this script to install flatpack and install any applications.ADD_APP_PACKAGE_NAME: Provide a Flatpack-compatible package name. Find the package name by navigating to , clicking on the app name and scrolling down to see the package name.
List Available UpdatesUse this script to list available OS and app updates.None
Install All Updates SilentlyUse this script to install all available updates silently.None
Block URLs/WebsitesUse this script to block the websites defined in the script.URLS_TO_BLOCK: Provide a list of URLs with each URL in a new line, that you want to block.
Unblock WebsitesUse this script to unblock the websites defined in the script, that may have been blocked earlier.URLS_TO_UNBLOCK: Provide a list of URLs with each URL in a new line, that you want to unblock.
Lock DeviceUse this script to remotely lock the device.Please note that, we don't support repeat execution of scripts, so please delete and re-upload the script and Publish each time you would want to lock device.
Update Host namesUse this script to remotely update the Host names.
  • Please enter the current host name in line:
"please enter the current hostname of the machine 1")

  • Please enter the new host name in line:
new_hostname="please enter new hostname you want set"

  • The device will need to be rebooted once. 

Delete Files/FoldersUse this script to remotely delete files and/or folders.
  • Provide the host name in the line:
  • Provide the path of the file or folder to be deleted in the lines:
    delete_file "/path/to/file.txt"
    delete_file "/path/to/file1.txt"
  • Please use caution with wildcards to avoid unintended deletions, for example, rm -r ~/*.txt will delete all .txt files in the home directory and its subdirectories.

Temporary Sudo access for specific user.Use this script to give temporary Sudo access for specific user.
  1. On executing the script, the user will get logged out automatically from ongoing session and once they log in, they will become sudo.
  2. After XX minutes (that is the time specified in the script) user will again get logged out automatically and again login back will make them Standard user.
    1. The users will need to perform the logout-login action to ensure that the sudo group setting is updated.
  3. The script also includes a command to auto detect the Time zone i.e. when the user was logged out - followed by at what time they became sudo user, followed by the time the user will be a sudo user.
  4. The script will also revert back with a message if the mentioned user is not present.
  • Provide the username in the line:
  • Provide the time in seconds in the line:
    sleep ENTER_SECONDS && 

Block Multiple apps.Use this script to block multiple apps from launching.
  • Please enter the correct process name of the applications in lines:
    # Set the process names of the applications
    # Fetch the paths to the executables
    process1_path=$(which APPLICATION_Process_NAME1)
    process2_path=$(which APPLICATION_Process_NAME2)

  • Reboot the device once the script has been published.

Allow selected applications.Use this script to allow selected applications.
  • Please enter the application process name(s) that are to be allowed in the line:

For example,

EXCLUDED_COMMANDS=("firefox" "gedit" "gnome-terminal" "sshd" "bash" "chrome" "google-chrome" "Xwayland" "xdg-desktop-portal" "gsd-xsettings" "oosplash" "dbeaver" "Postman" "filezilla" "msedge" "opera" "thunderbird" "brave" "sublime_text" "code" "peek" "zoom" "vim" "terminator" "chromium-browser" "soffice" )

Reboot of the device will be required.

Enable BluetoothUse this script to enable Bluetooth.None
Disable BluetoothUse this script to disable Bluetooth.None
Lock User accountUse this script to lock a user account.
  • Provide the username and hostname of the user whose account you want to lock.

  • If Hostname is invalid the script will not execute.
  • If Hostname is valid, it will next check Username and if Username is invalid or not present, script will not execute.
  • If both Hostname and Username are valid then only script will be executed.
Unlock User accountUse this script to unlock a user account.
  • Provide the username and hostname of the user whose account you want to unlock.
  • If Hostname is invalid the script will not execute.
  • If Hostname is valid, it will next check Username and if Username is invalid or not present, script will not execute.
  • If both Hostname and Username are valid then only script will be executed.

Delete User accountUse this script to delete a user account.
  • Provide the username and hostname of the user whose account you want to delete.

Check System serviceUse this script to check system service of the device(s).
  • Provide the service_names in the script.
  • The script will show system service status:
    • Running - Will print the status of service.
    • If service is present but not running it will mention that.
    • If service is not present, it will mention that.
  • You can check status of multiple services in one go.

Start System ServiceUse this script to start the System services.
  • Provide the service(s) name in the script.
    • For example, service_names=("ssh" "NetworkManager" "systemd-journald")

Download and set wallpaper.Use this script to download an image from a Google Drive and automatically set it as desktop wallpaper.
  1. Please make sure that the image file is accessible to all.
  2. Add the File ID in the script.
    # Google Drive sharing link for the image

  3. To obtain the file ID for a file hosted on Google Drive, follow these steps:
    1. Open Google Drive: Go to Google Drive and log in to your Google account if you're not already logged in.
    2. Locate the File: Find the file you want to share or download.
    3. Get the File ID: Right-click on the file and select "Get link" from the menu. Alternatively, you can click on the file to open it, and then the file ID will be visible in the URL in the address bar of your browser. The file ID typically appears after the id= parameter in the URL.
      1. Example URL:
      2. It's the alphanumeric string in the URL.


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.

Was this article helpful?

What's Next