### Build Windows Installer Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md This script is used to produce the `.exe` graphical installer on Windows. It requires NSIS and MSYS2 to be installed and their binaries added to the system's PATH. ```bash npm run build:installer ``` -------------------------------- ### Install Development Tools for balena CLI (Linux/WSL) Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-ADVANCED.md Installs necessary development tools like curl, python3, git, make, and g++, then uses nvm to install Node.js version 22. This is recommended over using apt-get for Node.js to avoid permission issues. ```sh $ sudo apt-get update && sudo apt-get -y install curl python3 git make g++ $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash $ . ~/.bashrc $ nvm install 22 ``` -------------------------------- ### Start Services on a Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Start specified containers on one or more devices. Multiple devices and services can be provided as comma-separated lists. ```bash $ balena device start-service 23c73a1 myService ``` ```bash $ balena device start-service 23c73a1 myService1,myService2 ``` -------------------------------- ### Install Dependencies and Build balena-cli Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Install project dependencies using npm and build the CLI. This is a standard step before development or testing. ```bash npm install ``` ```bash npm run build ``` -------------------------------- ### Check SSH Client Installation Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-WINDOWS.md Verify if the SSH client is installed on Windows by running the `ssh` command. This is required for `balena device ssh`. ```bash ssh ``` -------------------------------- ### Install MSYS2 Packages Source: https://github.com/balena-io/balena-cli/blob/master/README.md Use this command to install necessary packages for MSYS2 on Windows. Ensure you have MSYS2 installed first. ```shell pacman -S git gcc make openssh p7zip ``` -------------------------------- ### Enable Secure Boot Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure a balenaOS installer image to opt-in for secure boot and disk encryption. ```bash balena os configure ../path/rpi3.img --secureBoot ``` -------------------------------- ### Install OpenSSH Client on Debian/Ubuntu Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-LINUX.md Install the openssh-client package if the ssh command-line tool is not available. This is a prerequisite for the 'balena device ssh' command. ```bash sudo apt-get install openssh-client ``` -------------------------------- ### Install windows-build-tools npm package Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-ADVANCED.md Installs the windows-build-tools npm package globally. This requires running the command in an administrator console. ```sh npm install --global --production windows-build-tools ``` -------------------------------- ### Install Avahi Daemon on Debian/Ubuntu Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-LINUX.md Install the avahi-daemon package if a multicast DNS (mDNS) service is not already present. This is required for the 'balena device detect' command. ```bash sudo apt-get install avahi-daemon ``` -------------------------------- ### Install openssh with Homebrew Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-MAC.md If the `ssh` command is not available, you can install it using Homebrew by running this command. ```bash brew install openssh ``` -------------------------------- ### Install balena CLI globally Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-ADVANCED.md Installs the balena CLI globally using npm. The --unsafe-perm flag is necessary when npm is executed as root, such as in a Docker container. ```sh npm install balena-cli --global --production --unsafe-perm ``` -------------------------------- ### Start Host OS Update for a Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Initiate a Host OS update for a specified device. Requires confirmation unless --yes is used. Supports specifying a balenaOS version and including draft versions. ```bash balena device os-update 23c73a1 ``` ```bash balena device os-update 23c73a1 --version 2.101.7 ``` ```bash balena device os-update 23c73a1 --version 2.31.0+rev1.prod ``` ```bash balena device os-update 23c73a1 --include-draft ``` -------------------------------- ### Configure Image with WiFi Settings Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure a balenaOS image using a provided WiFi configuration file. This allows for non-interactive WiFi setup. ```bash balena os configure ../path/rpi3.img --config myWifiConfig.json ``` -------------------------------- ### Installing npm-merge-driver Globally Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Automate the process of merging npm-shrinkwrap.json changes by installing the npm-merge-driver globally. ```sh npx npm-merge-driver install -g ``` -------------------------------- ### Check balena CLI Installation Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-WINDOWS.md Verify the balena CLI installation by checking its version. This command should be run in Windows PowerShell or Command Prompt. ```bash balena version ``` -------------------------------- ### Install Additional Packages with MSYS2 Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Install necessary packages for MSYS2 on Windows. This includes git, gcc, make, openssh, and p7zip. ```shell pacman -S git gcc make openssh p7zip ``` -------------------------------- ### Build Image for a Fleet Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build a Docker image for a specified fleet using the balena CLI. This is a common starting point for deploying applications to balena devices. ```bash $ balena build --fleet myFleet ``` -------------------------------- ### Install Node.js via nvm on macOS Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-ADVANCED.md Installs Node.js version 22 using nvm (Node Version Manager) on macOS. Ensure nvm is installed and sourced before running. ```sh $ curl -o- https://raw.githubusercontent.com/nvm/nvm/v0.38.0/install.sh | bash $ . ~/.bashrc $ nvm install 22 ``` -------------------------------- ### Preload a release into a balenaOS image Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Use the `balena preload` command to embed a release and optionally a splash screen into a balenaOS image file. This requires Docker to be installed and accessible. The image file must be accessible to the Docker engine. ```bash balena preload balena.img --fleet MyFleet --commit e1f2592fc6ee949e68756d4f4a48e49bff8d72a0 ``` ```bash balena preload balena.img --fleet myorg/myfleet --splash-image image.png ``` ```bash balena preload balena.img ``` -------------------------------- ### Build Using a Specific Docker Daemon (Linux/Mac) Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build an image by connecting to a specific Docker daemon socket, commonly used on Linux and macOS systems. This allows building with a remote or custom Docker installation. ```bash $ balena build --docker /var/run/docker.sock --fleet myFleet # Linux, Mac ``` -------------------------------- ### Login to balena account Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Log in to your balena account using web authorization, credentials, or a token. Interactive prompts will guide you through the process. ```bash balena login ``` ```bash balena login --web ``` ```bash balena login --token "..." ``` ```bash balena login --credentials ``` ```bash balena login --credentials --email johndoe@gmail.com --password secret ``` -------------------------------- ### Add balena CLI to secure_path Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-LINUX.md Modify the /etc/sudoers file to include the balena CLI installation directory in the secure_path. This is necessary for commands requiring sudo execution. ```text Defaults secure_path="/home/james/balena-cli:" ``` -------------------------------- ### Initialize a New Balena Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Registers a new device in a fleet, downloads the OS, configures it, and writes it to an SD card. Interactive menus are presented if fleet or drive are omitted. The latest OS version is used if not specified. ```bash balena device init ``` ```bash balena device init -f myorg/myfleet ``` ```bash balena device init --fleet myFleet --os-version 2.101.7 --drive /dev/disk5 ``` ```bash balena device init --fleet myFleet --os-version 2.83.21+rev1.prod --drive /dev/disk5 ``` ```bash balena device init --config config.json --os-version 2.101.7 --drive /dev/disk5 --yes ``` -------------------------------- ### Deploy with Build and Release Note Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploys a fleet, builds the image from a local source, and adds a descriptive note to the release. The note can be used for release tracking and identification. ```bash balena deploy myorg/myfleet --build --source myBuildDir/ --note "this is the note for this release" ``` -------------------------------- ### Pushing to a Device with Environment Variables Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploy an application to a device, setting environment variables for the host or specific services. ```bash balena push 10.0.0.1 --env MY_ENV_VAR=value --env my-service:SERVICE_VAR=value ``` -------------------------------- ### Pushing to a Fleet with Notes and Tags Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploy an application to a fleet, adding a release note and key-value tags. Tags can include empty values. ```bash balena push myFleet --source --note "this is the note for this release" ``` ```bash balena push myFleet --release-tag key1 "" key2 "value2 with spaces" ``` -------------------------------- ### Build Project from Source Directory Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build a project from a specified source directory and target a fleet. This command is useful when your project source code is not in the current working directory. ```bash $ balena build ./source/ --fleet myorg/myfleet ``` -------------------------------- ### Deploy and Build from Local Source Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Command to deploy a fleet and build the image locally using a specified source directory. Useful for local development and testing. ```bash balena deploy myorg/myfleet --build --source myBuildDir/ ``` -------------------------------- ### Initialize OS Image for Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Initialize an OS image for a device by flashing it to external storage or the device's storage medium. This command may require administrative permissions and can erase data on the target drive. ```bash balena os initialize ../path/rpi.img --type raspberry-pi ``` -------------------------------- ### Build for Emulated Device Type Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build an image for a specific device type, using QEMU for emulation. This is helpful for testing builds on architectures different from your host machine. ```bash $ balena build --deviceType raspberrypi3 --emulated ``` -------------------------------- ### Get current logged in user Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Retrieves the username and email address of the currently logged-in user. ```bash balena whoami ``` -------------------------------- ### Pushing to a Fleet by Name Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploy an application to a fleet identified by its name. ```bash balena push myorg/myfleet ``` -------------------------------- ### Download Unconfigured OS Image Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Download an unconfigured OS image for a specified device type. Use '--version' to select a balenaOS version (latest, specific, range, or interactive menu) and '--type' to specify the OS download type (e.g., 'disk-image', 'installation-media'). ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version 2.101.7 ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version 2022.7.0 ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version ^2.90.0 ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version 2.60.1+rev1 ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version 2.60.1+rev1.dev ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version 2021.10.2.prod ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version latest ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version menu ``` ```bash balena os download raspberrypi3 -o ../foo/bar/raspberrypi3.img --version menu-esr ``` ```bash balena os download generic-amd64 -o ../foo/bar/generic-amd64.img --type installation-media ``` -------------------------------- ### Join a device to a fleet Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Use the `balena join` command to provision a local device to a fleet on a balena server. The command can automatically scan the network if a device IP/hostname is not provided. Fleets can be specified by name or slug. ```bash balena join ``` ```bash balena join balena.local ``` ```bash balena join balena.local --fleet MyFleet ``` ```bash balena join balena.local -f myorg/myfleet ``` ```bash balena join 192.168.1.25 ``` ```bash balena join 192.168.1.25 --fleet MyFleet ``` -------------------------------- ### Fixing npm-shrinkwrap.json Issues Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Use these commands to resolve merge conflicts in npm-shrinkwrap.json and optimize dependencies. Always run 'npm install' after 'npm dedupe'. ```sh git checkout master -- npm-shrinkwrap.json rm -rf node_modules npm install # update npm-shrinkwrap.json to satisfy changes to package.json npm dedupe # deduplicate dependencies from npm-shrinkwrap.json npm install # re-add optional dependencies removed by dedupe git add npm-shrinkwrap.json # add it for committing (solve merge errors) ``` -------------------------------- ### Set BALENARC_NO_PROXY Environment Variable Source: https://github.com/balena-io/balena-cli/blob/master/README.md Use the BALENARC_NO_PROXY environment variable to exclude specified destinations from proxying. This example shows a comma-separated list of patterns. ```bash export BALENARC_NO_PROXY='*.local,dev*.mycompany.com,192.168.*' ``` -------------------------------- ### List balenaCloud API Keys Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Prints a list of balenaCloud API keys for the current user or a specific fleet. ```bash balena api-key list ``` -------------------------------- ### Deploy with Release Tagging Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploys an image to a fleet and applies a release tag with key-value pairs. This allows for custom metadata to be associated with the release, including values with spaces. ```bash balena deploy myFleet myRepo/myImage --release-tag key1 "" key2 "value2 with spaces" ``` -------------------------------- ### Get Full Path of Command with `which` Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Use the `which` package to find the full path of an executable without relying on the system shell, which is useful for logging and debugging before execution. ```javascript const fullPath = await which('ssh'); console.log(fullPath); # 'C:\WINDOWS\System32\OpenSSH\ssh.EXE' ``` ```javascript spawn(fullPath, ['arg1', 'arg2'], { shell: false }); ``` -------------------------------- ### Configure Squid Proxy for SSH Port 22 Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Example configuration rules for the Squid proxy server to allow proxy requests to SSH port 22 with SSL encryption. ```squidconf acl SSL_ports port 22 acl Safe_ports port 22 ``` -------------------------------- ### Create a new balena app Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Use this command to create a new balena application. You can optionally specify the organization and device type. If not specified, interactive prompts will appear if multiple options exist. ```bash balena app create MyApp ``` ```bash balena app create MyApp --organization mmyorg ``` ```bash balena app create MyApp -o myorg --type raspberry-pi ``` -------------------------------- ### Dependency Update Commit Message Example Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md When updating dependencies listed in repo.yml, include this line in the commit message body to allow versionbot to create nested changelog entries. ```text Update balena-sdk from 12.0.0 to 12.1.0 ``` -------------------------------- ### Execute balena-cli Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Run the balena CLI after building. The command may vary slightly between Unix-like systems and Windows. ```bash ./bin/balena ``` ```bash node .\bin\balena ``` -------------------------------- ### Pushing to a Device by IP Address Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploy an application to a device using its IP address. Supports specifying source directory and service. ```bash balena push 10.0.0.1 ``` ```bash balena push 10.0.0.1 --source ``` ```bash balena push 10.0.0.1 --service my-service ``` -------------------------------- ### Pushing System Applications to a Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploy a system application or a service within a system application to a device using its local hostname. ```bash balena push 23c73a1.local --system ``` ```bash balena push 23c73a1.local --system --service my-service ``` -------------------------------- ### Run All Tests Before Committing Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Execute all project tests to ensure compatibility and code quality before submitting changes. ```bash npm test ``` -------------------------------- ### Generate Balena CLI Documentation Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Run this command to generate the `docs/balena-cli.md` file, which is used for the CLI Documentation page. This command also runs as part of `npm run build`. ```bash npm run build:doc ``` -------------------------------- ### Build for Specific Device Type and Architecture with Emulation Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build an image for a specific device type and architecture, enabling emulation. This provides precise control over the build environment for cross-platform development. ```bash $ balena build --deviceType raspberrypi3 --arch armv7hf --emulated ``` -------------------------------- ### Login to balenaCloud Source: https://github.com/balena-io/balena-cli/blob/master/README.md Execute this command to initiate a login session with your balenaCloud account. This is necessary for commands that interact with your balenaCloud resources. ```shell balena login ``` -------------------------------- ### Develop with On-the-Fly Transpilation Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Execute the CLI using `ts-node/register` for on-the-fly TypeScript transpilation, simplifying the development workflow. ```bash ./bin/balena-dev ``` -------------------------------- ### Configure BalenaOS Drive or Image Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configures a balenaOS drive or image. Specify the path to the drive or image file. ```bash balena local configure /dev/sdc ``` ```bash balena local configure path/to/image.img ``` -------------------------------- ### List Device Service Environment Variables Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md List environment variables for a specific service on a given device. Requires device UUID and service name. ```bash balena env list --device 7cf02a6 --service MyService ``` -------------------------------- ### List Service Environment Variables Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md List environment variables for a specific service within a fleet. Use fleet and service names. ```bash balena env list --fleet MyFleet --service MyService ``` -------------------------------- ### List Device Environment Variables Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md List all environment variables for a specific device, identified by its UUID. ```bash balena env list --device 7cf02a6 ``` -------------------------------- ### SSH into a Local or Remote Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Initiate an SSH session to a device's host OS or a specific service container. If a fleet is specified, an interactive menu will appear to select an online device. Connections to local devices via IP or .local address use port 22222; otherwise, they traverse the balenaCloud VPN. ```bash $ balena device ssh MyFleet ``` ```bash $ balena device ssh f49cefd ``` ```bash $ balena device ssh f49cefd my-service ``` ```bash $ balena device ssh f49cefd --port ``` ```bash $ balena device ssh 192.168.0.1 --verbose ``` ```bash $ balena device ssh f49cefd.local my-service ``` ```bash $ echo "uptime; exit;" | balena device ssh f49cefd ``` ```bash $ echo "uptime; exit;" | balena device ssh 192.168.0.1 myService ``` -------------------------------- ### Build Using a Specific Docker Daemon (Windows) Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build an image by connecting to a specific Docker daemon pipe, typically used on Windows systems. This enables building with a Docker daemon accessible via a named pipe. ```bash $ balena build --docker //./pipe/docker_engine --fleet myFleet # Windows ``` -------------------------------- ### List Available BalenaOS Versions Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Show available balenaOS versions for a given device type. Use '--esr' to list Extended Support Release versions or '--include-draft' to include pre-release versions. ```bash balena os versions raspberrypi3 ``` -------------------------------- ### Configure Proxy with CLI Config File (URL String) Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure the proxy setting in the CLI config file using a URL string format. ```yaml proxy: 'http://localhost:8000' ``` -------------------------------- ### List Available Drives for OS Image Writing Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Lists available drives that can be used for writing an OS image. System drives are not included in the output. ```bash util available-drives ``` -------------------------------- ### List Fleet Environment Variables Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md List all environment variables for a specified fleet. Use fleet name or slug. ```bash balena env list --fleet myorg/myfleet ``` -------------------------------- ### Enable Support Access for Devices Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Enables balena support agent access to specified devices for a given duration. Devices are specified by a comma-separated list of UUIDs. ```bash balena support enable --device ab346f,cd457a --duration 3d ``` -------------------------------- ### Fast Build for Interactive Testing Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Use this command to skip some build steps for faster interactive testing during development. ```bash npm run build:fast ``` -------------------------------- ### Enable Development Mode Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure the balenaOS image to operate in development mode, enabling unauthenticated root SSH access and exposing network ports. ```bash balena os configure ../path/rpi3.img --dev ``` -------------------------------- ### Flash BalenaOS Image to Drive Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Flashes a balenaOS image to a specified drive. If no drive is specified, an interactive list of available drives is presented. The --yes option bypasses confirmation. ```bash balena local flash path/to/balenaos.img ``` ```bash balena local flash path/to/balenaos.img --drive /dev/disk2 ``` ```bash balena local flash path/to/balenaos.img --drive /dev/disk2 --yes ``` -------------------------------- ### Read Configuration File Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Reads the 'config.json' file from a balenaOS image file or an attached drive. If no drive is specified, it reads from the default location. ```bash balena config read ``` ```bash balena config read --drive /dev/disk2 ``` ```bash balena config read --drive balena.img ``` -------------------------------- ### List Fleet Configuration Variables Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md List only configuration variables for a specified fleet. Configuration variables control balena platform features. ```bash balena env list --fleet MyFleet --config ``` -------------------------------- ### Configure HTTP(S) Proxy with HTTPS_PROXY/HTTP_PROXY Source: https://github.com/balena-io/balena-cli/blob/master/README.md Use the HTTPS_PROXY and/or HTTP_PROXY environment variables to configure proxy settings. These variables follow the standard URL format. ```shell export HTTPS_PROXY='http://localhost:8000' ``` -------------------------------- ### Pushing to a Device without Live Updates Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Deploy an application to a device, disabling live updates for the current push. ```bash balena push 10.0.0.1 --nolive ``` -------------------------------- ### Create a New Balena Fleet Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Use this command to create a new fleet. You can optionally specify the organization and device type. If not specified, interactive prompts will appear if multiple options exist. ```bash balena fleet create MyFleet ``` ```bash balena fleet create MyFleet --organization mmyorg ``` ```bash balena fleet create MyFleet -o myorg --type raspberry-pi ``` -------------------------------- ### Configure Proxy with CLI Config File (Object Format) Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure the proxy setting in the CLI config file using an object format, specifying protocol, host, port, and authentication. ```yaml proxy: protocol: 'http' host: 'proxy.company.com' port: 12345 proxyAuth: 'bob:secret' ``` -------------------------------- ### Configure Image for Fleet and Device Type Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure a balenaOS image for a fleet and override the default device type. This is useful for fleets with mixed device types. ```bash balena os configure ../path/rpi3.img -f myorg/myfleet --device-type raspberrypi3 ``` -------------------------------- ### List All SSH Keys Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Lists all SSH keys currently registered in the user's balenaCloud account. ```bash balena ssh-key list ``` -------------------------------- ### Inject Configuration File Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Injects a 'config.json' file into a balenaOS image file or an attached drive. Specify the path to the config file and optionally the drive path. ```bash balena config inject my/config.json ``` ```bash balena config inject my/config.json --drive /dev/disk2 ``` -------------------------------- ### Build Using Remote Docker Host with TLS Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Build an image by connecting to a remote Docker host using TLS authentication. This requires specifying the host, port, and certificate files for secure communication. ```bash $ balena build --dockerHost my.docker.host --dockerPort 2376 --ca ca.pem --key key.pem --cert cert.pem -f myFleet ``` -------------------------------- ### Create Patch File with patch-package Source: https://github.com/balena-io/balena-cli/blob/master/CONTRIBUTING.md Use this command to create or update patch files after making direct edits to third-party modules in `node_modules`. Specify the patch directory and the package name. ```bash npx patch-package --patch-dir patches/all exit-hook ``` -------------------------------- ### Create a new balena block Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Use this command to create a new balena block. You can optionally specify the organization and device type. If not specified, interactive prompts will appear if multiple options exist. ```bash balena block create MyBlock ``` ```bash balena block create MyBlock --organization mmyorg ``` ```bash balena block create MyBlock -o myorg --type raspberry-pi ``` -------------------------------- ### Configure Proxy in CLI Config File (String URL) Source: https://github.com/balena-io/balena-cli/blob/master/README.md Set the proxy configuration in the balena CLI config file using a simple URL string. This is a more concise way to specify proxy settings. ```yaml proxy: 'http://localhost:8000' ``` -------------------------------- ### Sample Registry Secrets YAML Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md A sample YAML file demonstrating how to specify private Docker registry usernames and passwords for pulling base images. It includes configurations for a custom registry server, Docker Hub, and Google Container Registry. ```yaml 'my-registry-server.com:25000': username: ann password: hunter2 '': # Use the empty string to refer to the Docker Hub username: mike password: cze14 'eu.gcr.io': # Google Container Registry username: '_json_key' password: '{escaped contents of the GCR keyfile.json file}' ``` -------------------------------- ### Set or Update Device Note Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Set or update a note for a specific device. Notes can be provided directly as an argument or piped from stdin. ```bash balena device note "My useful note" --device 7cf02a6 ``` ```bash cat note.txt | balena device note --device 7cf02a6 ``` -------------------------------- ### Track Fleet Release on a Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure a specific device to track the latest pinned release of its associated fleet. ```bash $ balena device track-fleet 7cf02a6 ``` -------------------------------- ### Create a Balena Organization Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Creates a new organization with a specified name. This command is used for setting up new organizational structures within balena. ```bash balena organization create MyOrg ``` -------------------------------- ### Configure Image for a Fleet Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Configure a balenaOS image for a specific fleet using its name or slug. Fleet slugs are recommended for uniqueness. ```bash balena os configure ../path/rpi3.img --fleet myorg/myfleet ``` -------------------------------- ### List All Balena Fleets Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md This command lists all the balena fleets associated with your account. For more detailed information on a specific fleet, use the `balena fleet ` command. ```bash balena fleet list ``` -------------------------------- ### List Tags for a Release Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Lists all tags and their associated values for a specified release, identified by its ID or hash. ```bash balena tag list --release 1234 ``` ```bash balena tag list --release b376b0e544e9429483b656490e5b9443b4349bd6 ``` -------------------------------- ### Manage balena SSH Keys Source: https://github.com/balena-io/balena-cli/blob/master/INSTALL-WINDOWS.md Use the `balena key*` command set to list and manage SSH keys for your balena account. This is necessary for SSH access to devices. ```bash balena help -v ``` -------------------------------- ### Generate Device Configuration Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Generates a config.json file for a specific device. Requires the device UUID and balenaOS version. Optionally, an existing device API key or output file path can be provided. ```bash balena config generate --device 7cf02a6 --version 2.12.7 ``` ```bash balena config generate --device 7cf02a6 --version 2.12.7 --deviceApiKey ``` ```bash balena config generate --device 7cf02a6 --version 2.12.7 --output config.json ``` -------------------------------- ### List Balena Devices Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Lists all devices associated with your account. Devices can be filtered by specifying a fleet name or slug. ```bash balena device list ``` ```bash balena device list --fleet MyFleet ``` ```bash balena device list -f myorg/myfleet ``` -------------------------------- ### Extract Standalone balena CLI (Previous) Source: https://github.com/balena-io/balena-cli/blob/master/MIGRATIONS.md Use this command to extract older versions of the standalone balena CLI distributed as a zip archive. ```bash unzip balena-cli-v21.1.12-linux-x64-standalone.zip ``` -------------------------------- ### Deploy Image to Fleet Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Basic command to deploy an image to a specified fleet. This is used when an image already exists and needs to be deployed. ```bash balena deploy myFleet ``` -------------------------------- ### Deploy Specific Image to Fleet Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Command to deploy a specific image, identified by its repository and image name, to a fleet. This is useful for deploying pre-built or versioned images. ```bash balena deploy myorg/myfleet myRepo/myImage ``` -------------------------------- ### Register a New Balena Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Registers a new device with a balena fleet. A UUID can be provided, or it will be auto-assigned. Fleets can be specified by name or slug. ```bash balena device register MyFleet ``` ```bash balena device register MyFleet --uuid ``` ```bash balena device register myorg/myfleet --uuid ``` ```bash balena device register myorg/myfleet --uuid --deviceType ``` -------------------------------- ### Generate Fleet Configuration Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Generates a config.json file for a fleet, supporting development mode, secure boot, specific device types, and network configurations. Requires the fleet name/slug and balenaOS version. ```bash balena config generate --fleet myorg/fleet --version 2.12.7 --dev ``` ```bash balena config generate --fleet myorg/fleet --version 2.12.7 --secureBoot ``` ```bash balena config generate --fleet myorg/fleet --version 2.12.7 --deviceType fincm3 ``` ```bash balena config generate --fleet myorg/fleet --version 2.12.7 --output config.json ``` ```bash balena config generate --fleet myorg/fleet --version 2.12.7 --network wifi --wifiSsid mySsid --wifiKey abcdefgh --appUpdatePollInterval 15 ``` -------------------------------- ### List Tags for a Device Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Lists all tags and their associated values for a specified device, identified by its UUID. ```bash balena tag list --device 7cf02a6 ``` -------------------------------- ### Manage Device Public URL Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Output, enable, or disable the public URL for a device. The --status option can be used to determine if the URL is enabled. ```bash balena device public-url 23c73a1 ``` ```bash balena device public-url 23c73a1 --enable ``` ```bash balena device public-url 23c73a1 --disable ``` ```bash balena device public-url 23c73a1 --status ``` -------------------------------- ### Basic balena Push Command Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md This is the most basic usage of the balena push command, targeting a fleet named 'myFleet'. ```bash $ balena push myFleet ``` -------------------------------- ### Use command-line flags for Docker host Source: https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md Alternatively, specify the Docker host and port directly using command-line flags for balena commands. This avoids setting a persistent environment variable. ```bash balena build -h 127.0.0.1 -p 2375 ``` ```bash balena deploy -h 127.0.0.1 -p 2375 ``` -------------------------------- ### Interactively Reconfigure BalenaOS Image Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Use this command to interactively reconfigure a balenaOS image file or attached media. It automatically extracts the device UUID and passes it to the 'balena os configure' command. ```bash balena config reconfigure ``` ```bash balena config reconfigure --drive /dev/disk3 ``` ```bash balena config reconfigure --drive balena.img --advanced ``` -------------------------------- ### Show Device Logs Source: https://github.com/balena-io/balena-cli/blob/master/docs/balena-cli.md Display logs for a specific device. Use --tail for continuous streaming. Logs can be filtered by service or system logs. ```bash balena device logs 23c73a1 ``` ```bash balena device logs 23c73a1 --tail ``` ```bash balena device logs 192.168.0.31 ``` ```bash balena device logs 192.168.0.31 --service my-service ``` ```bash balena device logs 192.168.0.31 --service my-service-1 --service my-service-2 ``` ```bash balena device logs 23c73a1.local --system ``` ```bash balena device logs 23c73a1.local --system --service my-service ```