MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Elastic Agent Commands Reference

Elastic Agent runs as an operating system service, so you start and stop it with systemd on Linux, launchd on macOS and the Service Control Manager on Windows. This page adds what the start and stop commands above leave out: restart and status commands, enabling the agent at boot, the built-in elastic-agent CLI, install and uninstall commands, and fixes for common errors, including a corrected Windows command.

Start Elastic Agent


# Mac
$ sudo launchctl load /Library/LaunchDaemons/co.elastic.elastic-agent.plist

# Linux
$ sudo service elastic-agent start

#Windows
$ Start-Service Elastic Agent

# Debian
$ sudo systemctl start elastic-agent

#RPM
$ sudo systemctl start elastic-agent
Code language: PHP (php)

Stop Elastic Agent


# Mac
$ sudo launchctl unload /Library/LaunchDaemons/co.elastic.elastic-agent.plist

# Linux
$ sudo service elastic-agent stop

#Windows
$ Stop-Service Elastic Agent

# Debian
$ sudo systemctl stop elastic-agent
$ sudo service elastic-agent stop

#RPM
$ sudo systemctl stop elastic-agent
$ sudo service elastic-agent stop
Code language: PHP (php)


How Elastic Agent runs on each platform

Elastic Agent is one agent that replaces separately installed Beats such as Filebeat and Metricbeat. It manages its components (including Beats-based inputs) by itself, so day-to-day you control a single service. How it is installed decides where it lives and which commands apply:

Install methodService managerService nameInstall location
Linux tar.gz + elastic-agent installsystemdelastic-agent/opt/Elastic/Agent
DEB or RPM packagesystemdelastic-agent/usr/share/elastic-agent, config in /etc/elastic-agent
macOS tar.gz + elastic-agent installlaunchdco.elastic.elastic-agent/Library/Elastic/Agent
Windows zip/MSI + installService Control ManagerElastic AgentC:\Program Files\Elastic\Agent

In the example above, the separate "Linux", "Debian" and "RPM" entries all control the same systemd unit. On any modern systemd distribution, sudo service elastic-agent start just passes the request to systemctl. Use systemctl directly so you get clearer errors and status output.

Corrected start and stop commands

The Windows commands above fail as written. Start-Service takes the service name as a single positional argument. Without quotes, PowerShell reads Elastic and Agent as two arguments and stops with *A positional parameter cannot be found that accepts argument 'Agent'*. Put the name in quotes and run the commands from an elevated (Run as Administrator) PowerShell window. The $ prompt is also a Unix convention: PowerShell shows PS>.

# Windows (elevated PowerShell)
PS> Start-Service "Elastic Agent"
PS> Stop-Service "Elastic Agent"
PS> Restart-Service "Elastic Agent"
PS> Get-Service "Elastic Agent"Code language: PHP (php)

On macOS, launchctl load and unload still work but are legacy subcommands. Current macOS releases use bootstrap and bootout with the system domain, and kickstart to restart:

# macOS: start (load the daemon)
sudo launchctl bootstrap system /Library/LaunchDaemons/co.elastic.elastic-agent.plist

# macOS: stop (unload the daemon)
sudo launchctl bootout system /Library/LaunchDaemons/co.elastic.elastic-agent.plist

# macOS: restart a loaded daemon
sudo launchctl kickstart -k system/co.elastic.elastic-agent

# macOS: check whether it is loaded and running
sudo launchctl print system/co.elastic.elastic-agent | grep -E 'state|pid'Code language: PHP (php)

Linux, for all install methods:

sudo systemctl start elastic-agent
sudo systemctl stop elastic-agent
sudo systemctl restart elastic-agent
sudo systemctl status elastic-agent

Enable Elastic Agent at boot

Running elastic-agent install from a tar.gz registers and enables the service for you. The DEB and RPM packages put the files in place but do not necessarily enable or start the service. After you enroll a package-installed agent, enable it explicitly:

sudo systemctl enable --now elastic-agent
systemctl is-enabled elastic-agent   # expected: enabled
systemctl is-active elastic-agent    # expected: activeCode language: PHP (php)

On Windows the installer sets the service to start automatically. To check, or to fix it if someone changed it:

PS> Get-Service "Elastic Agent" | Select-Object Name, Status, StartType
PS> Set-Service "Elastic Agent" -StartupType AutomaticCode language: JavaScript (javascript)

Built-in elastic-agent CLI commands

The service commands only start and stop the process. The elastic-agent binary talks to the running daemon and reports what it is actually doing. Run it as root or Administrator. For tar.gz installs the binary is also put on the PATH. If it is not found, call it by its full path inside the install directory.

CommandWhat it does
elastic-agent statusShows overall health, the Fleet connection and the state of each component and unit
elastic-agent status --output jsonSame information in machine-readable form for scripts and monitoring
elastic-agent inspectPrints the effective configuration the agent is running, including policy received from Fleet
elastic-agent diagnosticsWrites a zip archive of logs, configuration and state for troubleshooting or a support case
elastic-agent restartRestarts the agent daemon without going through the service manager
elastic-agent versionShows the binary version and, if reachable, the running daemon version
elastic-agent enrollEnrolls an already installed agent into Fleet
elastic-agent upgrade <version>Upgrades a standalone agent (Fleet-managed agents are upgraded from Fleet)
elastic-agent uninstallRemoves the service and the installed files
# Quick health check on Linux or macOS
sudo elastic-agent status

# Machine-readable status for scripts
sudo elastic-agent status --output json

# Collect a diagnostics bundle in the current directory
sudo elastic-agent diagnosticsCode language: PHP (php)

Note: The JSON field names and the format of the state value have changed between releases. Check the output of your own version before you build alerting on it.

Install, enroll and uninstall

Fleet-managed install from a tar.gz or zip archive. Copy the Fleet Server URL and enrollment token from Fleet > Add agent in Kibana:

# Linux / macOS, from the extracted archive directory
sudo ./elastic-agent install \
  --url=https://fleet-server.example.com:8220 \
  --enrollment-token=<ENROLLMENT_TOKEN>

# Windows, elevated PowerShell, from the extracted directory
PS> .\elastic-agent.exe install --url=https://fleet-server.example.com:8220 --enrollment-token=<ENROLLMENT_TOKEN>Code language: PHP (php)

Packages install first and enroll afterwards:

sudo elastic-agent enroll \
  --url=https://fleet-server.example.com:8220 \
  --enrollment-token=<ENROLLMENT_TOKEN>
sudo systemctl enable --now elastic-agentCode language: JavaScript (javascript)

To uninstall, use the method that matches the install. Archive installs use the agent's own uninstaller. Packages are removed with the package manager.

# Linux tar.gz install
sudo /opt/Elastic/Agent/elastic-agent uninstall

# macOS
sudo /Library/Elastic/Agent/elastic-agent uninstall

# Windows (elevated PowerShell)
PS> & "C:\Program Files\Elastic\Agent\elastic-agent.exe" uninstall

# DEB / RPM
sudo apt-get remove elastic-agent      # Debian/Ubuntu
sudo dnf remove elastic-agent          # RHEL/Fedora family

# If the agent policy has tamper protection enabled
sudo /opt/Elastic/Agent/elastic-agent uninstall --uninstall-token <TOKEN>Code language: PHP (php)

Common errors and fixes

SymptomLikely causeFix
Unit elastic-agent.service could not be foundThe agent was run from the extracted archive but never installed as a serviceRun sudo ./elastic-agent install ... from the archive directory
A positional parameter cannot be found that accepts argument 'Agent'Service name not quoted in PowerShellUse Start-Service "Elastic Agent"
Access denied when controlling the service on WindowsPowerShell is not elevatedReopen PowerShell with Run as Administrator
elastic-agent status cannot connect to the daemonThe service is stopped or failed during startupStart it, then check sudo journalctl -u elastic-agent -n 100
Package-installed agent stops after a rebootService never enabledsudo systemctl enable --now elastic-agent
Agent shows Offline or Unhealthy in FleetService stopped, Fleet Server unreachable, or a failing integrationRun elastic-agent status locally and check network access to port 8220
Uninstall refusedTamper protection is on in the agent policyGet the uninstall token from Fleet and pass --uninstall-token

The agent writes detailed logs under its install directory, in a versioned data/elastic-agent-*/logs folder. On Linux, journalctl -u elastic-agent is most useful for failures that happen before the agent's own logging starts. When the cause is still unclear, elastic-agent diagnostics gathers these logs together with the running configuration.

Best practices

  • Use systemctl, launchctl bootstrap/bootout and quoted PowerShell service names consistently in runbooks so commands are copy-paste safe.
  • Check elastic-agent status after a restart. A running service does not mean that every integration is healthy.
  • For Fleet-managed agents, change configuration in the agent policy in Kibana, not by editing elastic-agent.yml on the host. Local edits are overridden by the policy.
  • Turn on tamper protection for endpoint security policies so local users cannot easily stop or remove the agent.
  • Treat enrollment tokens as secrets. Do not commit them to repositories or leave them in shell history; pass them through your configuration management tool's secret store.
  • Expect the host to appear offline in Fleet whenever you stop the service for maintenance, and tell whoever watches Fleet alerts.

For more on systemd service management and general server administration, see the Linux tutorials.

Frequently asked questions

How do I check if Elastic Agent is running?

Use sudo systemctl status elastic-agent on Linux, Get-Service "Elastic Agent" on Windows, or sudo launchctl print system/co.elastic.elastic-agent on macOS. To check health as well as whether the process is running, run sudo elastic-agent status.

How do I restart Elastic Agent?

Run sudo systemctl restart elastic-agent on Linux, Restart-Service "Elastic Agent" in elevated PowerShell on Windows, or sudo launchctl kickstart -k system/co.elastic.elastic-agent on macOS. The elastic-agent restart command also restarts the running daemon.

Why does Start-Service Elastic Agent fail in PowerShell?

The service name contains a space, so PowerShell treats Elastic and Agent as two separate arguments. Put the name in quotes, Start-Service "Elastic Agent", and run PowerShell as Administrator.

Where are Elastic Agent logs stored?

Logs are written under the install directory, for example /opt/Elastic/Agent on Linux, in a versioned data/elastic-agent-*/logs folder. On Linux, journalctl -u elastic-agent shows service startup errors, and elastic-agent diagnostics collects all logs into a single archive.

Do I still need Filebeat or Metricbeat if I use Elastic Agent?

Usually not. Elastic Agent runs the needed data collection components itself, based on the integrations in its policy, so you manage one agent instead of several Beats.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

How to configure Elastic filebeat 8.3 with Elasticseach?

This guide shows how to install Filebeat 8.3 from the tarball, collect log files with the filestream input, and send them to an Elasticsearch 8 cluster that…

Read More

Jira on Linux: Installation and Configuration with Safer Service and Firewall Setup

Learn how to install Jira on Linux using Atlassianโ€™s installer, manage it as a service, and expose port 8080 safely. This revision keeps the original references but updates the process for clearer, production-minded operations.

Read More

MySQL Basic Troubleshooting Guide: Service, Port 3306, Logs, and Crash Repair

This Linux-first runbook helps you troubleshoot common MySQL issues quickly, from startup failures to port conflicts and slow performance. You will learn practical checks for service health, configuration, logging, and table repair.

Read More

RHCSA EX200 Self-Study Curriculum and Hands-On Lab Manual

Gold-standard home-study roadmap for the Red Hat Certified System Administrator (RHCSA) exam EX200 Research cut-off: 2026-10-06 Primary authority: current official Red Hat EX200 page, Red Hat Certification…

Read More

How to install & configure Elastic Filebeat?

Filebeat client is a lightweight, resource-friendly tool that collects logs from files on the server and forwards these logs to your Logstash instance for processing. Filebeat is…

Read More

Linux Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Linux Administrator is responsible for the reliability, security, and day-to-day operational health of Linux-based infrastructure that supports enterprise applications, internal developer platforms, and shared IT services. This role ensures Linux systems are consistently configured, patched, monitored, backed up, and recoverableโ€”while meeting organizational standards for availability, performance, and compliance.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x