:global-flags-link: For more flags, see <<elastic-agent-global-flags>>.

[[elastic-agent-cmd-options]]
[role="xpack"]
= {agent} command line options

++++
<titleabbrev>Command line options</titleabbrev>
++++

beta[]

{agent} provides commands for running the agent and doing common tasks:

* <<elastic-agent-enroll-command,enroll>>
* <<elastic-agent-help-command,help>>
* <<elastic-agent-inspect-command,inspect>>
* <<elastic-agent-install-command,install>>
* <<elastic-agent-restart-command,restart>>
* <<elastic-agent-run-command,run>>
* <<elastic-agent-uninstall-command,uninstall>>
* <<elastic-agent-upgrade-command,upgrade>>
* <<elastic-agent-version-command,version>>

NOTE: You might need to log in as a root user to run these commands.

++++
<hr>
++++

[discrete]
[[elastic-agent-enroll-command]]
== elastic-agent enroll

Enroll the {elastic-agent} in {fleet}.

We recommend that you run this command as the root user because some
integrations require root privileges to collect sensitive data. This command
overwrites the `elastic-agent.yml` file in the agent directory.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent enroll <kibana_url> <enrollment_token> [--ca-sha256 <string>]
                     [--certificate-authorities <string>] [--force] [--help]
                     [--insecure] [global-flags]
----

[discrete]
=== Options

`kibana_url`::
Required. URL of the {kib} endpoint where {fleet} is running.

`enrollment_token`::
Required. Enrollment token generated by {fleet}. You can use the same
enrollment token for multiple agents.

`--ca-sha256 <string>`::
Comma-separated list of certificate authority hash pins used for certificate
verification.

`--certificate-authorities <string>`::
Comma-separated list of root certificates used for server verification.

`--force`::
Force overwrite of current configuration without prompting for confirmation.
This flag is helpful when using automation software or scripted deployments.

`--help`::
Show help for the `enroll` command.

`--insecure`::
Allow an insecure connection to {kib}. When this flag is specified, API keys are
sent in clear text. We strongly recommend that you use a secure connection.

{global-flags-link}

[discrete]
=== Example

[source,shell]
----
elastic-agent enroll http://localhost:5601 ZnmNIdzVITUJua2QIdU5FTWROVjY6dHY2N1EybWNTMUdPejg5ODbYcVpNUQ==
----

++++
<hr>
++++

[discrete]
[[elastic-agent-help-command]]
== elastic-agent help

Show help for a specific command.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent help <command> [--help] [global-flags]
----

[discrete]
=== Options

`command`::
The name of the command.

`--help`::
Show help for the `help` command.

{global-flags-link}

[discrete]
=== Example

[source,shell]
----
elastic-agent help enroll
----

++++
<hr>
++++

[discrete]
[[elastic-agent-inspect-command]]
== elastic-agent inspect

Show the current {agent} configuration.

If no parameters are specified, shows the full {agent} configuration.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent inspect [--help] [global-flags]
elastic-agent inspect output [--output <string>] [--program <string>]
                             [--help] [global-flags]
----

[discrete]
=== Options

`output`:: Display the current configuration for the output. This command
accepts additional flags:
+
--
`--output <string>`::
The name of the output to inspect.

`--program <string>`::
The type of program to inspect. For example, `filebeat`. This option must be
combined with `--output`.
--

`--help`::
Show help for the `inspect` command.

{global-flags-link}

[discrete]
=== Examples

[source,shell]
----
elastic-agent inspect
elastic-agent inspect output --output default
elastic-agent inspect output --output default --program filebeat
----

++++
<hr>
++++

[discrete]
[[elastic-agent-install-command]]
== elastic-agent install

Install {agent} permanently on the system and manage it by using the system's
service manager. The agent will start automatically after installation is
complete. On Linux, this command requires a system and service manager like
systemd.

You must run this command as the root user (or Administrator on Windows)
to write files to the correct locations. This command overwrites the
`elastic-agent.yml` file in the agent directory.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent install [--ca-sha256 <string>] [--certificate-authorities <string>]
                      [--enrollment-token <string>] [--force] [--help]
                      [--insecure] [--kibana-url <string>]
                      [global-flags]
----

[discrete]
=== Options

`--ca-sha256 <string>`::
Comma-separated list of certificate authority hash pins used for certificate
verification.

`--certificate-authorities <string>`::
Comma-separated list of root certificates used for server verification.

`--enrollment-token <string>`::
Enrollment token generated by {fleet}. You can use the same enrollment token for
multiple agents.

`--force`::
Force overwrite of current configuration without prompting for confirmation.
This flag is helpful when using automation software or scripted deployments.

`--help`::
Show help for the `install` command.

`--insecure`::
Allow an insecure connection to {kib}. When this flag is specified, API keys are
sent in clear text. We strongly recommend that you use a secure connection.

`--kibana-url <string>`::
URL of the {kib} endpoint where {fleet} is running.

{global-flags-link}

[discrete]
=== Examples

[source,shell]
----
elastic-agent install -f --kibana-url=https://yourhost:5601 \
  --enrollment-token=OEV0bmauVUI0a3dmdWc1T3Bad1o6VGxCa3U4UEFTQ0NycbBSUFwoazVBdx==
----

++++
<hr>
++++

[discrete]
[[elastic-agent-restart-command]]
== elastic-agent restart

Restart the currently running Elastic Agent daemon.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent restart [--help] [global-flags]
----

[discrete]
=== Options

`--help`::
Show help for the `restart` command.

{global-flags-link}

[discrete]
=== Examples

[source,shell]
----
elastic-agent restart
----

++++
<hr>
++++

[discrete]
[[elastic-agent-run-command]]
== elastic-agent run

Start the `elastic-agent` process.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent run [global-flags]
----

[discrete]
[[elastic-agent-global-flags]]
=== Global flags

These flags are valid whenever you run `elastic-agent` on the command line.

`-c <string>`::
The configuration file to use. If not specified, {agent} uses
`{path.config}/elastic-agent.yml`.

`--e`::
Log to stderr and disable syslog/file output.

`--environment <environmentVar>`::
The environment in which the agent will run.

`--path.config <string>`::
The directory where {agent} looks for its configuration file. The default
varies by platform.

`--path.home <string>`::
The root directory of {agent}. `path.home` determines the location of the
configuration files and data directory.
+
If not specified, {agent} uses the current working directory.

`--path.logs <string>`::
Path to the log output for {agent}. The default varies by platform.

`--v`::
Set log level to INFO.

[discrete]
=== Example

[source,shell]
----
elastic-agent run -c myagentconfig.yml
----

++++
<hr>
++++

[discrete]
[[elastic-agent-uninstall-command]]
== elastic-agent uninstall

Permanently uninstall {agent} from the system.

You must run this command as the root user (or Administrator on Windows)
to remove files. 

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent uninstall [--force] [--help] [global-flags]
----

[discrete]
=== Options

`--force`::
Uninstall {agent} and do not prompt for confirmation. This flag is helpful
when using automation software or scripted deployments.

`--help`::
Show help for the `uninstall` command.

{global-flags-link}

[discrete]
=== Examples

[source,shell]
----
elastic-agent uninstall
----

++++
<hr>
++++

[discrete]
[[elastic-agent-upgrade-command]]
== elastic-agent upgrade

Upgrade the currently running {agent} to the specified version.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent upgrade <version> [--source-uri <string>] [--help] [flags]
----

[discrete]
=== Options

`version`::
The version of {agent} to upgrade to.

`--source-uri <string>`::
The source URI to download the new version from. By default, {agent} uses the
Elastic Artifacts URL.

`--help`::
Show help for the `upgrade` command.

{global-flags-link}

[discrete]
=== Examples

[source,shell]
----
elastic-agent upgrade 7.10.1
----

++++
<hr>
++++

[discrete]
[[elastic-agent-version-command]]
== elastic-agent version

Show the version of {agent}.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent version [--help] [global-flags]
----

[discrete]
=== Options

`--help`::
Show help for the `version` command.

{global-flags-link}

[discrete]
=== Example

[source,shell]
----
elastic-agent version
----

++++
<hr>
++++
