# RedHat / CentOS

This guide covers repository-based installation on RedHat Enterprise Linux (RHEL) and CentOS.

> **Note**: CentOS Stream is an upstream preview of RHEL, not a downstream stable rebuild like traditional CentOS. Installation steps are the same, but update cadence differs.

## Prerequisites

* Linux kernel 4.18+ (for eBPF support)
* Root or sudo access
* Outbound HTTPS access to `packages.linuxguard.io`

> **Note**: See [Prerequisites](/how-to-guides/how-to/prerequisites.md) for full system requirements.

## Repository Setup

The recommended installation method uses the official LinuxGuard DNF/YUM repository. This ensures you receive automatic updates and can easily manage the agent through your package manager.

### Step 1: Add Repository

Create the repository configuration file:

```bash
sudo tee /etc/yum.repos.d/linuxguard.repo <<EOF
[linuxguard]
name=LinuxGuard Repository
baseurl=https://packages.linuxguard.io/dnf/\$releasever/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.linuxguard.io/gpg/linuxguard.asc
EOF
```

### Step 2: Install Agent

Update the package cache and install the agent:

```bash
sudo dnf makecache
sudo dnf install linuxguard-agent
```

> **Note**: On CentOS 7 or RHEL 7, use `yum` instead of `dnf`:

```bash
sudo yum makecache
sudo yum install linuxguard-agent
```

### Step 3: Enable and Start Service

Enable the agent service to start at boot:

```bash
sudo systemctl enable --now linuxguard-agent
```

> **Important**: Unlike Debian/Ubuntu, RedHat-based distributions do not automatically start services after installation. You must explicitly enable and start the agent.

## Direct Download

If repository setup is not possible, you can download and install the RPM package directly:

```bash
curl -fsSL -o linuxguard-agent.rpm \
  https://packages.linuxguard.io/dnf/pool/linuxguard-agent-latest.$(uname -m).rpm
sudo rpm -ivh linuxguard-agent.rpm
```

After manual installation, remember to enable and start the service:

```bash
sudo systemctl enable --now linuxguard-agent
```

## Verification

After installation, verify the agent is correctly installed:

### Check Agent Binary

Confirm the agent binary is in your PATH:

```bash
which linuxguard-agent
```

Expected output:

```
/usr/bin/linuxguard-agent
```

### Verify Agent User

Confirm the agent user and group were created:

```bash
id linuxguard
```

Expected output:

```
uid=999(linuxguard) gid=999(linuxguard) groups=999(linuxguard)
```

> **Note**: The UID/GID numbers may vary depending on your system.

### Check Service Status

Verify the agent service is installed and running:

```bash
sudo systemctl status linuxguard-agent
```

Expected output:

```
○ linuxguard-agent.service - LinuxGuard Security Agent
     Loaded: loaded (/usr/lib/systemd/system/linuxguard-agent.service; enabled; preset: disabled)
     Active: inactive (dead)
```

The service is inactive until you complete enrollment.

## Troubleshooting

### Service Not Running After Install

If the service is not enabled after installation, DNF/YUM does not automatically start services. Enable and start it explicitly:

```bash
sudo systemctl enable --now linuxguard-agent
```

### Repository Metadata Errors

If `dnf install` fails with repository metadata errors, refresh the cache:

```bash
sudo dnf makecache
```

Or verify the repository configuration:

```bash
cat /etc/yum.repos.d/linuxguard.repo
```

### SELinux Denials

If the agent fails to start due to SELinux policy violations, check for denials:

```bash
sudo ausearch -m avc | grep linuxguard
```

If SELinux denials are found, you may need to create a custom policy or temporarily set SELinux to permissive mode while investigating.

> **Note**: See the [Troubleshooting Guide](/troubleshooting.md) for additional help.

***

**Next Step**: [Configuration →](/how-to-guides/how-to/configuration.md)

**Related**: [Installation Overview](/how-to-guides/how-to/installation.md) | [Prerequisites](/how-to-guides/how-to/prerequisites.md) | [Troubleshooting](/troubleshooting.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.linuxguard.io/how-to-guides/how-to/installation/redhat-centos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
