# Alpine Linux

This guide covers installing the LinuxGuard agent on Alpine Linux, commonly used in containers and lightweight environments.

> **Important**: Alpine Linux uses **OpenRC** (not systemd) for service management and **musl libc** (not glibc). Commands in this guide differ from other distribution guides accordingly.

## Prerequisites

Before installing, ensure your system meets these requirements:

* **Kernel**: Linux kernel 4.18 or later
* **Permissions**: Root or sudo access
* **Network**: Outbound HTTPS access to `packages.linuxguard.io`
* **curl**: The `curl` package (not installed by default on Alpine minimal)

> **Note**: For complete system requirements including architecture and detailed prerequisites, see the [Prerequisites Guide](/how-to-guides/how-to/prerequisites.md).

To install curl if not already present:

```bash
sudo apk add curl
```

## Repository Setup

The recommended installation method uses the APK package manager to install LinuxGuard from the official repository.

### Step 1: Import GPG Key

Create the APK keys directory and import the LinuxGuard signing key:

```bash
sudo mkdir -p /etc/apk/keys
curl -fsSL https://packages.linuxguard.io/gpg/linuxguard.asc | \
  sudo tee /etc/apk/keys/linuxguard.asc > /dev/null
```

### Step 2: Add Repository

Add the LinuxGuard repository to your system:

```bash
echo "https://packages.linuxguard.io/apk/alpine/v$(cut -d. -f1,2 /etc/alpine-release)/main" | \
  sudo tee -a /etc/apk/repositories
```

### Step 3: Install Agent

Update the package index and install the agent:

```bash
sudo apk update
sudo apk add linuxguard-agent
```

The installer will also install the `sysstat` dependency, which provides `iostat` and `mpstat` for system metrics collection.

### Step 4: Enable and Start Service

Alpine uses OpenRC for service management. Enable the agent to start at boot and start the service:

```bash
sudo rc-update add linuxguard-agent boot
sudo rc-service linuxguard-agent start
```

> **Note**: Alpine uses OpenRC for service management. Use `rc-service` and `rc-update` instead of `systemctl`.

## Direct Download

If you prefer to download and install the package manually, you can download the APK package directly:

```bash
curl -fsSL -o linuxguard-agent.apk \
  https://packages.linuxguard.io/apk/pool/linuxguard-agent-latest.$(uname -m).apk
sudo apk add --allow-untrusted linuxguard-agent.apk
```

> **Note**: Manual installation does not configure automatic updates. We recommend using the repository method for production systems.

## Verification

After installation, verify the agent was installed correctly:

### Check Agent Binary

Confirm the agent binary is installed:

```bash
which linuxguard-agent
```

Expected output:

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

### Verify Agent User

Confirm the dedicated `linuxguard` user was created:

```bash
id linuxguard
```

Expected output (UID/GID may vary):

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

### Check Service Status

Verify the agent service is running (OpenRC command):

```bash
sudo rc-service linuxguard-agent status
```

Expected output:

```
 * status: started
```

The agent is now installed and ready for enrollment.

## Alpine-Specific Considerations

### musl vs glibc

Alpine uses musl libc instead of glibc. The LinuxGuard agent package for Alpine is specifically compiled against musl. **Do not install Debian/Ubuntu or RedHat/CentOS packages on Alpine** — they are compiled against glibc and will not run.

### Container Environments

Alpine is commonly used as a container base image due to its small size (3-10MB vs 100-300MB for Debian/Ubuntu). For container-specific installation instructions, see the [Container Installation Guide](/how-to-guides/how-to/installation/container-installation.md).

## Troubleshooting

### Service Commands Not Working

**Issue**: `systemctl: command not found` or systemctl commands fail.

**Solution**: Alpine uses OpenRC, not systemd. Use `rc-service linuxguard-agent <command>` instead of `systemctl <command> linuxguard-agent`. Most common mistake when switching from other distributions.

### Binary Compatibility Errors

**Issue**: Agent fails to start with library or symbol errors.

**Solution**: Verify you installed the Alpine-specific package. This error typically indicates a glibc vs musl mismatch. Reinstall using `apk add linuxguard-agent` from the Alpine repository.

### Missing curl

**Issue**: Repository setup fails because curl is not installed.

**Solution**: Alpine minimal installations don't include curl by default. Install with:

```bash
apk add curl
```

> **Note**: For additional troubleshooting guidance, see the [Troubleshooting Guide](/troubleshooting.md).

***

**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) | [Container Installation](/how-to-guides/how-to/installation/container-installation.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/alpine.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.
