Skip to main content

Get Started with cnquery

Welcome to cnquery, an open source project created by Mondoo!

-> Learn about cnquery

Download and install cnquery​

Install cnquery with our installation script:

Linux and macOS

bash -c "$(curl -sSL https://install.mondoo.com/sh)"

(You can read the Linux/macOS installation script.)

Windows

Set-ExecutionPolicy Unrestricted -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString('https://install.mondoo.com/ps1/cnquery'));
Install-Mondoo -Product cnquery;

(You can read the Windows installation script.)

Install manually

Manual installation packages are available on GitHub releases.

note

If you install cnquery on machines that can't download and install updates (because they're air-gapped or don't give cnquery write access), you must install cnquery providers. To learn more, read Manage cnquery Providers.

Run queries in the cnquery shell​

The easiest way to discover cnquery's capabilities is to use the interactive shell, which has auto-complete to guide you:

cnquery shell

Once inside the shell, you can enter MQL queries. For example, this query returns the name of the current machine and the platform it's running:

asset { name title }

Get help in the cnquery shell​

To see what information cnquery can retrieve, use the help command. These are some examples of how the help can guide you:

This command...Describes the queryable resources for...
helpAll of cnquery
help k8sKubernetes
help k8s.statefulsetKubernetes Cluster StatefulSets
help azureAzure
help terraformTerraform

Exit the cnquery shell​

To exit cnquery shell, either press Ctrl + D or type exit.

Run queries in your own shell​

To run standalone queries in your shell, use the cnquery run command:

cnquery run TARGET -c "QUERY"
For...Substitute...
TARGETThe asset to query, such as local or a transport to a remote machine.
QUERYThe MQL query that specifies the information you want.

For example, this command runs a query against your local system. It lists the services installed and whether each service is running:

cnquery run local -c "services.list { name running }"

For a list of supported targets, use the help command:

cnquery help run

Explore your infrastructure in Mondoo Platform​

To more easily explore your infrastructure, sign up for a Mondoo Platform account. Mondoo's web-based console allows you to navigate, search, and inspect all of your assets.

To get started, contact Mondoo.

To learn about Mondoo Platform, read the Mondoo Platform docs or visit mondoo.com.

Learn more​