Skip to content

osquery

85 commands

Exposes the operating system as a SQL database: query processes, users, ports, packages and more across Linux, macOS and Windows.

  • endpoint visibility
  • SQL
  • detection

Install osquery

sudo apt install osquery

Interactive Query Shell7

osqueryi

Launches the interactive osquery shell for live ad-hoc system querying.

osqueryi --help

Displays the list of available command-line flags and options for the interactive shell.

.help

Lists the available meta-commands within the interactive shell environment.

.tables

Lists all available tables that can be queried on the current operating system.

.schema

Displays the structure and column definitions for a specific table.

Link
.mode

Sets the output display mode to pretty-print, line, list, or csv for better readability.

Link
.quit

Exits the interactive osquery shell safely.

System Information4

SELECT version FROM osquery_info;

Retrieves the currently installed version of the osquery agent.

SELECT * FROM system_info;

Queries core hardware and operating system details including hostname and memory.

Link
SELECT * FROM uptime;

Checks how long the system has been running since the last reboot.

Link
SELECT * FROM os_version;

Details the specific operating system version and build number.

Link

User & Account Auditing4

SELECT * FROM users;

Lists all local user accounts present on the system.

Link
SELECT * FROM groups;

Lists all local groups defined on the system.

Link
SELECT * FROM logged_in_users;

Identifies users currently logged into the system and their source.

Link
SELECT * FROM last;

Reviews the history of system logins and reboots.

Link

Process Monitoring4

SELECT * FROM processes;

Enumerates all currently running processes on the host.

Link
SELECT * FROM process_envs;

inspects the environment variables associated with a specific process ID.

Link
SELECT * FROM process_open_files;

Lists all file descriptors currently opened by a specific process.

Link
SELECT * FROM process_memory_map;

Examines the memory map of a process to see loaded shared libraries.

Link

Network Analysis5

SELECT * FROM listening_ports;

Identifies ports that are currently in a listening state on the host.

Link
SELECT * FROM process_open_sockets;

Maps active network sockets to the processes that own them.

Link
SELECT * FROM interface_addresses;

Lists the IP addresses assigned to network interfaces.

Link
SELECT * FROM dns_resolvers;

Checks the DNS servers configured for the system.

Link
SELECT * FROM etc_hosts;

Reads the static host definitions from the hosts file.

Link

File System Inspection3

SELECT * FROM file;

Retrieves metadata for a specific file on the disk.

Link
SELECT * FROM hash;

Calculates the cryptographic hash (MD5, SHA1, SHA256) of a specific file.

Link
Recursive File Search

Performs a wildcard search for files within a specific directory.

Link

Software & Packages3

SELECT * FROM deb_packages;

Lists installed Debian-based packages (Ubuntu/Debian systems).

Link
SELECT * FROM rpm_packages;

Lists installed RPM-based packages (RHEL/CentOS systems).

Link
SELECT * FROM python_packages;

Enumerates globally installed Python libraries.

Link

Persistence Mechanisms4

SELECT * FROM startup_items;

Checks for items configured to run automatically at system boot.

Link
SELECT * FROM crontab;

Audits scheduled cron jobs for all users.

Link
SELECT * FROM systemd_units;

Inspects systemd services and their current status on Linux systems.

Link
SELECT * FROM kernel_modules;

Lists loaded kernel modules or drivers which could indicate rootkits.

Link

Daemon Configuration4

osqueryd --flagfile

Starts the osquery daemon using a specific flag file for configuration.

Link
osqueryd --config_check

Validates the syntax of the configuration file without starting the daemon.

Link
osqueryd --verbose

Enables verbose logging to standard output for debugging daemon issues.

Link
osqueryd --pidfile

Specifies the location to write the daemon's process ID file.

Link

Logging & Output4

osqueryi --json

Executes a query and outputs the result in strict JSON format.

Link
osqueryi --csv

Executes a query and outputs the result in CSV format.

Link
osqueryd --logger_plugin

Configures the daemon to write logs to the local filesystem.

Link
osqueryd --logger_path

Sets the specific directory where filesystem logs will be stored.

Link

Performance Tuning3

osqueryd --watchdog_level

Sets the strictness of the watchdog process that monitors daemon resource usage.

Link
osqueryd --watchdog_memory_limit

Limits the memory (in MB) the daemon can use before being restarted.

Link
osqueryd --watchdog_utilization_limit

Limits the CPU utilization percentage the daemon is allowed to consume.

Link

Event Auditing5

SELECT * FROM process_events;

Queries the real-time event buffer for process executions (requires audit enabling).

Link
SELECT * FROM file_events;

Queries the event buffer for file system changes monitored by FIM configurations.

Link
SELECT * FROM socket_events;

Queries the event buffer for network socket connections and binds.

Link
osqueryd --disable_events=false

Ensures the eventing subsystem is enabled for table based auditing.

Link
osqueryd --events_expiry

Sets the time in seconds before events expire from the internal buffer.

Link

TLS & Remote Logging3

osqueryd --tls_hostname

Defines the remote TLS server hostname for configuration and log shipping.

Link
osqueryd --enroll_secret_path

Points to the file containing the shared secret used for authenticating to the TLS server.

Link
osqueryd --config_plugin tls

Instructs the daemon to pull its configuration from the remote TLS server.

Link

SOC Monitoring Workflow2

JOIN Processes and Users

Correlates running processes with the specific user account running them.

Link
JOIN Listening Ports and Processes

Identifies exactly which process binary is responsible for an open port.

Link

Blue Team Validation4

Verify Firewall Rules

Audits the current iptables ruleset to ensure firewall policy compliance.

Link
Check Mount Points

Verifies that filesystems are mounted with correct options (e.g., noexec on tmp).

Link
Audit SSH Keys

Lists all public keys authorized to SSH into user accounts.

Link
Detect World Writable Files

Scans critical directories for files that are writable by any user.

Link

Purple Team Simulation4

Detect Reverse Shells

Hunts for common bash reverse shell patterns in command lines.

Link
Detect Suspicious Parentage

Identifies web server processes spawning unexpected shells.

Link
Detect Deleted Executables

Finds processes running from binaries that have been deleted from the disk.

Link
Detect High Port Traffic

Monitors for connections to non-standard high ports often used for C2.

Link

Threat Hunting3

Hunt for Netcat

Scans active processes for the presence of the netcat utility.

Link
Hunt for Base64 Commands

Searches user shell history for potentially obfuscated base64 commands.

Link
Hash Running Processes

Calculates the SHA256 hash of the binary for every running process.

Link

Incident Response4

Dump Process List JSON

Exports the full process state to JSON for offline analysis during an incident.

Link
Dump Open Files JSON

Captures a snapshot of all files held open by processes for forensic review.

Link
Identify Malware Path

Quickly inspects temporary directories for dropped executable payloads.

Link
Check Sudoers Changes

Verifies the metadata of the sudoers file to check for unauthorized modification.

Link

Automation & Scripting3

Batch Query Execution

Feeds a file containing multiple SQL queries directly into the osquery shell.

Link
Pack Configuration

Introspects the currently loaded query packs defined in the configuration.

Link
Schedule Introspection

Displays the execution schedule and performance stats of configured queries.

Link

Advanced Configuration2

Extensions Loading

Loads an external extension to add new tables or capabilities to osquery.

Link
Custom Socket Path

Connects the shell to a daemon running on a non-standard socket path.

Link

Container Monitoring2

Docker Info

Retrieves high-level information about the Docker daemon if present.

Link
Docker Containers

Lists active Docker containers and their current running status.

Link

MacOS Specific2

Launchd Agents

Audits macOS launch daemons and agents for persistence.

Link
Gatekeeper Status

Checks if macOS Gatekeeper security assessment is enabled.

Link

Windows Specific2

Services Inspection

Lists installed services and their running state on Windows.

Link
Registry Auto-Start

Queries the Windows registry for keys that execute programs at startup.

Link

Cleanup3

Flush Logs

Forces the daemon to flush logs to the configured backend immediately.

Link
Kill Daemon

Terminates the osquery daemon process (Linux/Unix).

Link
Remove Pidfile

Manually removes the pidfile if the daemon crashed or did not exit cleanly.

Link

Verification1

Check Daemon Status

Verifies from the system shell that the osquery daemon is running.

Link