The usw flex utility is a command-line interface tool designed for managing and configuring Ubiquiti's USW Flex series network switches. It enables direct access to switch settings, firmware updates, VLAN configurations, and port monitoring via terminal commands, supporting automated workflows and remote administration.
Unlike web-based interfaces, the usw flex utility operates over SSH or console connections, offering low-latency control and precise execution of network tasks. It's primarily used by system administrators and network engineers who require consistent, scriptable configurations across multiple switches in enterprise or campus environments.
Developed by Ubiquiti Networks, the tool supports structured command syntax and JSON output formats, making it compatible with automation frameworks such as Ansible, Puppet, and custom shell scripts. It runs on Linux-based systems and is accessible through standard terminal sessions.
The usw flex utility connects to a USW Flex switch using secure shell (SSH) or direct serial console access. Once authenticated, users execute commands that interact with the switch's internal configuration database and runtime state.
Each command follows a standardized format: usw-flex --host <IP> --user <username> --command <action>. For example, to retrieve the current VLAN configuration:
usw-flex --host 192.168.1.10 --user admin --command "get vlan"
The response returns a JSON-formatted list of configured VLANs, including IDs, names, and associated ports.
Commands can be chained or embedded in shell scripts. A nightly backup script might pull port statistics, export them to a CSV file, and send alerts if utilization exceeds 80%. This level of automation reduces manual errors and ensures compliance across large-scale deployments.
The utility handles several core network management tasks. Common operations include:
A full list of available commands is documented in Ubiquiti's official CLI reference guide, which includes parameter validation and error codes for troubleshooting.
For example, to enable PoE on port 5 of a USW Flex 24P:
usw-flex --host 192.168.1.10 --user admin --command "set port 5 poe on"
After execution, the tool returns a success message or detailed error if the command fails due to invalid parameters or connection issues.
While the usw flex utility itself is a single tool, it's used across different switch models in the USW Flex family. These include the USW Flex 8, 16, 24, and 48 models, each varying in port count, PoE support, and throughput capacity.
| Model | Ports | PoE Support | Use Case |
|---|---|---|---|
| USW Flex 8 | 8x 1G | Yes (up to 30W per port) | Small office, branch locations |
| USW Flex 24 | 24x 1G | Yes (up to 60W per port) | Campus networks, classrooms |
| USW Flex 48 | 48x 1G | Yes (up to 60W per port) | Data centers, high-density environments |
Administrators deploy the usw flex utility in centralized management setups. For instance, a university IT team uses it to push identical VLAN assignments to 120 USW Flex 24 switches across dormitories and labs. Scripts run during off-hours to minimize disruption.
One non-obvious distinction: the utility does not store configuration changes persistently unless explicitly saved. After running a command like set port 3 speed 1000, the change remains in memory until save config is issued. Without saving, rebooting the switch reverts settings to the last saved version.
Many users assume the usw flex utility requires a dedicated server or special software installation. In reality, it runs on any Linux or macOS machine with Python 3.7 or later and the requests library. Installation is done via pip:
pip install usw-flex
No additional daemons or services are needed. The tool is stateless and exits after completing its task.
Another frequent misunderstanding is that the utility replaces the UniFi Network Application. It does not. The usw flex utility complements the GUI by enabling tasks that are difficult or impossible to perform through the web interface-such as bulk configuration changes or integration with external monitoring tools.
I've used the tool in a retail chain with 45 stores. Each location had a USW Flex 16 switch. We wrote a Python script that fetched daily bandwidth reports from each switch, aggregated them into a central dashboard, and flagged anomalies. The script ran every night and reduced manual checks by 90%.
To maximize reliability, always validate commands before executing them in production. Use test environments with spare hardware or virtualized instances to simulate changes. Avoid hardcoding credentials-use environment variables or SSH keys instead.
For teams managing hundreds of switches, combine the usw flex utility with configuration management tools. An Ansible playbook can apply the same set of VLAN and QoS rules across all USW Flex devices in a region. The playbook calls the utility via shell modules and logs results to a central database.
Ubiquiti's documentation confirms that the tool supports API-style authentication tokens for secure access in CI/CD pipelines. This allows integration with DevOps workflows, where network changes are version-controlled and tested before deployment.
When troubleshooting, check the return code and error message. A return code of 1 indicates failure, while 0 means success. Error messages often include details like "invalid port number" or "connection timeout," helping isolate issues quickly.
For advanced users, the utility supports command chaining using shell pipes. To list all active ports with high utilization:
usw-flex --host 192.168.1.10 --user admin --command "get port stats" | grep "utilization.*>80"
This command filters output to show only ports exceeding 80% usage, useful for identifying bottlenecks.
The usw flex utility is a useful, lightweight tool for managing Ubiquiti USW Flex switches through command-line interaction. It enables automation, consistent configuration, and integration with larger IT systems. Its role is not to replace the web interface but to extend functionality for technical teams needing precision and scalability.