# LibTmux.Server.start/1

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/00d34b3d387da72a5a416f1dd3962a98c76cedd2/lib/libtmux/server.ex#L327
- **Page:** https://libtmux.org/en/elixir/latest/reference/libtmux-server-start-1/

```
start(options)
@spec start([start_option()]) ::
        {:ok, t()} | {:error, LibTmux.Error.t()}
```

Starts a private tmux server and returns a Server for it.

The server runs in the foreground under libtmux's native helper, in a
directory of its own below `:root`: the directory has mode 700, holds the
socket and is `TMUX_TMPDIR` for the daemon and its panes. The daemon never
inherits `TMUX` or `TMUX_PANE`, reads `:config_file` (an empty file by
default), and stays up with no session. `start/1` returns when the socket
answers, or when `:timeout` (5000 ms by default) ends.

The process that calls `start/1` owns the server. When it exits, the daemon
stops and its directory is removed. If the VM is killed, the native helper
still retires the daemon, but the directory stays. Other processes may use
the returned Server. Stop it with `stop/2` as soon as the work is done, or
use `with_owned/2`.

Returns `{:error, error}` for an invalid option, a socket path that would
exceed the 107 usable bytes of `sun_path`, a daemon that cannot start or
exits before it answers, and a timeout. A failed start leaves no directory
behind. It starts only on Linux, like the rest of libtmux.

    alias LibTmux.Server

    {:ok, server} = Server.start(executable: System.find_executable("tmux"))
    {:ok, _} = Server.new_session(server, "demo", command: {:argv, ["/bin/cat"]})
    :ok = Server.stop(server)

## Parameters

- `options` (`[start_option()]`)

## Guides

Pages that discuss `start/1`.

### Guides

- [Getting started](/en/elixir/latest/guides/overview/)

### Topics

- [Execution ownership](/en/elixir/latest/topics/ownership/)
