Cockpit CLI Reference
The Cockpit Command-Line Interface (cockpit-cli) is a text-based tool used to set up, manage, and fix your Cockpit server.
- 💡 Analogy: The Backstage Remote Control Think of the CLI like a remote control that lets you access the "backstage" of Cockpit. If you accidentally lock yourself out of the web dashboard, or if you want to automate server setup using scripts, you can run these commands directly on the server's terminal.
1. Setup & Starting the Service
Initialize Cockpit Database (cockpit-cli init)
- What it does: Prepares the database for use by creating necessary tables and asking you to create the first administrator account.
- When to use: Run this once when installing Cockpit for the first time.
bash
cockpit-cli init --config /etc/cockpit/cockpit.confStart the Server (cockpit-cli run)
- What it does: Starts Cockpit's central manager service.
bash
cockpit-cli run --config /etc/cockpit/cockpit.conf2. Managing User Accounts
Create a User (cockpit-cli user create)
- What it does: Creates a new local user account without using the web browser.
bash
cockpit-cli user create --username "admin" --email "admin@corp.awan.io" --role "super-admin"Reset a Password (cockpit-cli user reset-password)
- What it does: Changes a user's password.
- When to use: If you forget your admin password or your account gets locked due to too many failed logins.
bash
cockpit-cli user reset-password --username "admin" --password "newsecurepassword"3. Registering Physical Servers
List Servers (cockpit-cli host list)
- What it does: Shows all physical Vapor servers registered in the Cockpit database and displays if they are connected or offline.
bash
cockpit-cli host listAdd a Server (cockpit-cli host add)
- What it does: Connects a new physical Vapor host to Cockpit.
- Options: Pass the server address (
--hostnameor--ip) and its unique security--token.
bash
cockpit-cli host add --hostname "vapor-node-01.corp.awan.io" --ip "192.168.122.203" --token "VaporAPITokenString"4. Diagnostics & Troubleshooting
Check Database & System Health (cockpit-cli cluster status)
- What it does: Checks if Cockpit can reach the PostgreSQL database, verifies if the tables are up-to-date, and counts active connections.
bash
cockpit-cli cluster statusCheck Connection Locks (cockpit-cli locks list)
- What it does: Lists which Cockpit management server is currently talking to each physical Vapor host. Useful to diagnose connection issues in multi-instance setups.
bash
cockpit-cli locks list