Swif.ai allows administrators to run commands with administrator (sudo) privileges on managed Linux devices. This capability is commonly used when installing, configuring, validating, or maintaining software that requires elevated permissions.
This article explains:
How sudo execution works on Linux with Swif.ai
Which account is used to run sudo commands
Where and how scripts can be used on the Software (Applications) page
How sudo Works on Linux with Swif.ai
On Linux devices enrolled in Swif.ai:
Commands are executed using a privileged system context (root or sudo-capable service account)
Scripts run non-interactively, without prompting for a password
The end user is not interrupted
Commands run securely in the background via the Swif agent
This allows administrators to safely run commands that normally require sudo, such as:
Installing system packages
Managing services and daemons
Writing to protected directories (for example,
/usr,/etc,/opt)Running vendor installation or configuration tools
No manual sudo password entry is required.
Running sudo Commands via Software Deployment
When managing Linux applications through
βDevice Management β Applications, Swif.ai provides multiple script execution points that run with elevated privileges.
All scripts listed below execute with sudo / root-level permissions.
1. Pre-Install Script
When it runs:
Before the installer or package is executed.
Typical use cases:
Preparing the system environment
Removing existing versions of a package
Installing dependencies
Updating repositories
Example:
#!/bin/bash apt-get update apt-get remove -y old-package exit 0
2. Installer File
The Installer File is executed with administrator privileges.
Depending on the distribution, this may include:
.debpackages.rpmpackagesCustom shell installers
Binary installers
Swif.ai automatically handles privilege escalation.
3. Post-Install Command Script
When it runs:
After the installation completes successfully.
Typical use cases:
Activating licenses
Registering agents
Starting or restarting services
Running vendor CLI tools
Example:
#!/bin/bash /opt/vendor/bin/agentctl activate --key XXXXXXXX systemctl enable agentd systemctl start agentd if systemctl is-active --quiet agentd; then exit 0 else exit 1 fi
4. Install Check Script (Validation Rule)
When it runs:
To verify that the application is installed and functioning correctly.
Configured under Validation Rules with Rule Type = Script.
Purpose:
Detect existing installations
Prevent redundant installs
Support compliance reporting
Example:
#!/bin/bash if command -v agentctl >/dev/null 2>&1; then exit 0 else exit 1 fi
exit 0β Application detectedexit 1β Application not found
5. Uninstaller File and Uninstall Script
When it runs:
When an application is removed or unassigned from a device.
Typical use cases:
Stopping services
Removing packages
Cleaning up configuration files
Example:
#!/bin/bash systemctl stop agentd apt-get remove -y agent-package rm -rf /opt/agent exit 0
Script Execution Order on Linux
When deploying an application, scripts execute in the following order:
Pre-Install Script
Installer File
Post-Install Command Script
Install Check Script (validation)
All steps run with sudo-level privileges.
Important Notes and Best Practices
Always include
#!/bin/bashat the top of scriptsUse non-interactive flags (for example,
-yfor package managers)Use absolute paths for binaries and configuration files
Return proper exit codes (
0= success, non-zero = failure)Account for distro differences (APT vs YUM/DNF)
Summary
Swif.ai enables secure, automated execution of sudo commands on Linux devices through the Swif agent. Using the Software (Applications) page, administrators can run privileged scripts throughout the application lifecycle, including:
Pre-install preparation
Installation
Post-install configuration
Validation
Uninstallation
This allows Linux software to be deployed and managed at scale without user interaction, while maintaining security, consistency, and auditability.
For Windows Devices
If you're working with a Windows device, you can run a command as an administrator. For more information, visit the Windows command guide.
For Mac Devices
If you're working with a Mac device, you can run a command as sudo. For more information, visit the Mac command guide.
