> Markdown version of https://tuna.am/en/docs/cli/service/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# tuna service

Manage tuna background services.

Run as root (sudo, Administrator on Windows) to install a system service, otherwise the service runs in your user session (systemd `--user` on Linux, LaunchAgent on macOS). Without a subcommand in a terminal opens the list of installed services.

Alias: `svc`.

Guide with examples: [Running in the background](https://tuna.am/en/docs/tunnels/guides/service.md).

Usage

```bash
tuna service

```

Examples

```bash
tuna service install -- tuna http 8080
tuna service list
tuna service logs -f
tuna service restart
tuna service uninstall

```

## Subcommands

| Command                                | Description                                            |
| -------------------------------------- | ------------------------------------------------------ |
| [`tuna service edit`](#edit)           | Change the command of a service and restart it.        |
| [`tuna service install`](#install)     | Install and start a service.                           |
| [`tuna service list`](#list)           | List installed services.                               |
| [`tuna service logs`](#logs)           | Show service logs.                                     |
| [`tuna service restart`](#restart)     | Restart a service.                                     |
| [`tuna service start`](#start)         | Start a service.                                       |
| [`tuna service status`](#status)       | Show service status, exit code 1 if it is not running. |
| [`tuna service stop`](#stop)           | Stop a service.                                        |
| [`tuna service uninstall`](#uninstall) | Stop and remove a service, revoke its token.           |

## tuna service edit

Change the command of a service and restart it.

The service keeps its name, user, environment and autostart. The tunnel type cannot change: reinstall the service for that. When the address changes (`--subdomain`, `--domain`, `--port`), a new key is issued from the login session and the old one is revoked.

Usage

```bash
tuna service edit -- tuna [type] [flags]

```

Examples

```bash
tuna service edit -- tuna http 8081 --subdomain=web
tuna service edit --name db -- tuna tcp 5433

```

| Flag            | Description                    |
| --------------- | ------------------------------ |
| `--name string` | Service name. Default: `tuna`. |

## tuna service install

Install and start a service.

Usage

```bash
tuna service install -- tuna [type] [flags]

```

Examples

```bash
tuna service install -- tuna http 8080
tuna service install --name db -- tuna tcp 5432
tuna service install -- tuna ssh
tuna service install -- tuna trigger webhook /tmp/trigger.sh
sudo tuna service install --user www-data -- tuna http 8080

```

| Flag            | Description                        |
| --------------- | ---------------------------------- |
| `--name string` | Service name. Default: `tuna`.     |
| `--user string` | Run a system service as this user. |

## tuna service list

List installed services.

Alias: `ls`.

Usage

```bash
tuna service list [flags]

```

| Flag     | Description            |
| -------- | ---------------------- |
| `--json` | Output in JSON format. |

## tuna service logs

Show service logs.

Usage

```bash
tuna service logs [flags]

```

Examples

```bash
tuna service logs
tuna service logs --name db -f
tuna service logs -n 500

```

| Flag              | Description                                   |
| ----------------- | --------------------------------------------- |
| `-f, --follow`    | Follow new lines.                             |
| `-n, --lines int` | Number of last lines to show. Default: `100`. |
| `--name string`   | Service name. Default: `tuna`.                |

## tuna service restart

Restart a service.

Usage

```bash
tuna service restart [flags]

```

| Flag            | Description                    |
| --------------- | ------------------------------ |
| `--name string` | Service name. Default: `tuna`. |

## tuna service start

Start a service.

Usage

```bash
tuna service start [flags]

```

| Flag            | Description                    |
| --------------- | ------------------------------ |
| `--name string` | Service name. Default: `tuna`. |

## tuna service status

Show service status, exit code 1 if it is not running.

Usage

```bash
tuna service status [flags]

```

| Flag            | Description                    |
| --------------- | ------------------------------ |
| `--name string` | Service name. Default: `tuna`. |

## tuna service stop

Stop a service.

Usage

```bash
tuna service stop [flags]

```

| Flag            | Description                    |
| --------------- | ------------------------------ |
| `--name string` | Service name. Default: `tuna`. |

## tuna service uninstall

Stop and remove a service, revoke its token.

Usage

```bash
tuna service uninstall [flags]

```

| Flag            | Description                    |
| --------------- | ------------------------------ |
| `--name string` | Service name. Default: `tuna`. |

[Global flags](https://tuna.am/en/docs/cli.md#global-flags) work too.
