Home / Guide / Copyparty as a systemd service

Running Copyparty as a Linux Service With systemd

Make copyparty start at boot on Linux. Create a dedicated user, install the systemd unit, store the configuration safely, read logs and update without downtime.

Small single-board computer and portable drive in front of a monitor showing a terminal

Copyparty becomes far more useful once it runs as a proper background service rather than in a terminal window you must remember to leave open. On Linux, systemd is the standard way to achieve this. It starts copyparty at boot, restarts it if it stops, collects its logs and lets you reload the configuration with a single command. This guide explains how to prepare a dedicated user, install and adapt the unit file shipped with copyparty, and manage the service day to day.

Why run copyparty as a service?

A file server is only helpful when it is available. Running copyparty in an open terminal works for testing, but the server stops when you log out, close the window or reboot. A systemd service solves all of these issues and brings further benefits.

  • copyparty starts automatically when the machine boots.
  • systemd restarts the server if it crashes.
  • Logs are collected in the system journal for later reading.
  • The server runs under a restricted account rather than your own.
  • Configuration changes can be applied with a reload instead of a full restart.

Preparing a dedicated user

Running services under their own unprivileged account limits the damage any bug or misconfiguration can cause. Create a system user for copyparty with no login shell.

Terminal
sudo useradd -r -s /usr/sbin/nologin -m -d /var/lib/copyparty copyparty

Then grant that user access to the folders you intend to share. For a folder that should accept uploads, the copyparty user needs write permission; for a read-only archive, read permission is enough. Group membership is often the neatest approach, because it lets both you and the service work with the same files.

Placing the program

There are two common ways to install copyparty for a service.

  • Install it system-wide with your distribution’s package or with pip, so the copyparty command is available on the PATH.
  • Keep the self-extracting copyparty-sfx.py file in a fixed location, such as /usr/local/bin, and run it with Python.

The unit file shipped with copyparty assumes the second approach, but adapting it to the first is simply a matter of changing the command it runs. Whichever you choose, make sure the dedicated user can read and execute the program.

Writing the configuration file

A service should read its settings from a file rather than from a long command line. Create /etc/copyparty.conf and make it readable only by root and the copyparty user, because it contains passwords.

Terminal
[global]
  e2dsa
  e2ts

[accounts]
  admin: ChooseAStrongPassword

[/]
  /srv/files
  accs:
    r: *
    rwmda: admin

Set the permissions on the file so that other users on the machine cannot read it.

Terminal
sudo chown root:copyparty /etc/copyparty.conf
sudo chmod 640 /etc/copyparty.conf

Installing the systemd unit

The copyparty repository includes a ready-made unit in its contrib/systemd folder, together with instructions written as comments inside the file. Copy it into place, then open it in an editor to adjust the paths and the user.

Terminal
sudo cp contrib/systemd/copyparty.service /etc/systemd/system/
sudo nano /etc/systemd/system/copyparty.service

The essential parts of a working unit are short. The service section names the user, the command and the restart behaviour.

Terminal
[Unit]
Description=copyparty file server
After=network.target

[Service]
Type=simple
User=copyparty
Group=copyparty
ExecStart=/usr/bin/python3 /usr/local/bin/copyparty-sfx.py -c /etc/copyparty.conf
ExecReload=/bin/kill -s USR1 $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

The ExecReload line lets systemctl reload ask copyparty to reread its configuration without dropping connections. The repository’s own unit includes further hardening options that are worth keeping.

Enabling and starting the service

Tell systemd about the new unit, then enable and start it in one step.

Terminal
sudo systemctl daemon-reload
sudo systemctl enable --now copyparty

Check that it is running.

Terminal
systemctl status copyparty

A healthy service shows as active, with the most recent log lines confirming the version and the volumes being served.

Reading the logs

copyparty prints useful information to its output, and systemd stores it in the journal. To follow the log live, use journalctl.

Terminal
journalctl -u copyparty -f

The log shows uploads, logins, errors and configuration problems. When something does not behave as expected, it is the first place to look.

Reloading after configuration changes

When you add an account or change a volume, there is no need to stop the server.

Terminal
sudo systemctl reload copyparty

copyparty rereads the accounts and volumes, keeping existing connections alive. Remember that changes to the global section, such as the port, still require a restart.

Terminal
sudo systemctl restart copyparty

Opening the firewall

Allow the copyparty port through the host firewall so other devices can connect. On Ubuntu and Debian with ufw, the command is short.

Terminal
sudo ufw allow 3923/tcp

On distributions using firewalld, add the port permanently and reload the firewall rules.

Running on ports 80 and 443

A service running as an unprivileged user cannot open ports below 1024 on Linux. Rather than running copyparty as root, place a reverse proxy such as nginx or Caddy in front of it. The repository includes an example nginx configuration in its contrib folder. The proxy handles HTTPS and the standard ports, then forwards traffic to copyparty on its local port.

Extra isolation with prisonparty

For people who want stronger isolation, the repository also provides prisonparty, a variant that runs copyparty inside a chroot. It restricts the server to a minimal view of the filesystem containing only the folders it needs. This is optional, but it is a useful extra layer on machines that hold sensitive data.

Updating a service installation

Updating follows the same pattern regardless of how you installed copyparty.

  • Download or install the new version.
  • Restart the service with systemctl restart copyparty.
  • Check the journal to confirm the new version started cleanly.

Because the configuration lives in /etc and your files in their own folders, updates do not affect your setup. Read the release notes first, particularly when they mention security fixes or breaking changes.

Other init systems

Not every distribution uses systemd. The repository includes service scripts for OpenRC, used by Alpine and Gentoo, and an rc script for FreeBSD. NixOS users can enable copyparty through a dedicated module in their system configuration. The principles are the same everywhere: a dedicated user, a configuration file and automatic restarts.

Hardening the unit further

systemd offers sandboxing options that restrict what a service can see and do, and the unit shipped with copyparty already uses several of them. Options such as ProtectSystem and ProtectHome make most of the filesystem read-only or invisible to the service, while PrivateTmp gives it its own temporary directory. If you add these yourself, remember to allow access to the folders copyparty actually shares, using ReadWritePaths for upload locations and ReadOnlyPaths for archives.

Test after each change. A sandboxing option that is too strict usually shows up as a permission error in the journal when copyparty tries to read a volume or write an upload.

Storing indexes and caches sensibly

When indexing and thumbnails are enabled, copyparty keeps a database and cache for each volume. By default, these sit in a hidden folder inside the volume. On a server where the shared folders live on slow or removable drives, you may prefer to keep the caches on the system disk instead. The hist option sets a different location, such as a folder under /var/lib/copyparty owned by the service user. This keeps shared folders clean and speeds up thumbnail loading.

Running more than one instance

Occasionally it is useful to run two separate copyparty servers on one machine, for example a public archive and a private family server with different settings. systemd handles this neatly with two unit files, each pointing to its own configuration and listening on a different port. Give each instance its own user if they share different folders, so a problem in one cannot affect the other.

Checking the service after a reboot

The real test of a service is a reboot. After setting everything up, restart the machine and, without logging in, try to reach copyparty from another device. If the page loads and your volumes are present, the service starts correctly on its own. If not, log in and inspect the journal for the copyparty unit. Common causes include shared folders on drives that mount after the service starts and network-dependent paths that are not yet available.

For drives that mount late, add a dependency on the mount to the unit file, or use systemd’s RequiresMountsFor setting with the path of your shared folder. systemd then waits for the drive before starting copyparty, which avoids empty volumes after a reboot. Taking a few minutes to confirm this behaviour now prevents an unpleasant surprise during the next power cut.

Keeping logs under control

On a busy server, logs grow steadily. The systemd journal rotates automatically according to its own size limits, so in most cases no action is needed. If disk space is tight, adjust the journal’s maximum size in its configuration file, or reduce how much copyparty logs with its quieter logging options. Keep enough history to investigate problems from the last few weeks, because security incidents and odd behaviour are often noticed some time after they begin. A balance between detail and disk usage serves most home and small-office servers well.

Frequently Asked Questions

Where is the copyparty systemd unit file?

It is included in the copyparty repository under contrib/systemd, with setup instructions written as comments inside the file.

Should copyparty run as root?

No. Run it as a dedicated, unprivileged user and use a reverse proxy if you need ports 80 and 443.

How do I apply configuration changes without downtime?

Run systemctl reload copyparty. Accounts and volumes are reread while existing connections stay open.

How can I see what copyparty is doing?

Use journalctl -u copyparty -f to follow its log, which shows uploads, logins and errors.

Does the service start automatically after a reboot?

Yes, once it is enabled with systemctl enable. systemd also restarts it if it fails.

Conclusion

Copyparty runs best on Linux as a systemd service under its own unprivileged user. Create the account, place the program and a protected configuration file, adapt the unit shipped in the repository, and enable it. From then on, the server starts at boot, recovers from failures, logs to the journal and reloads its configuration on request. It is a small investment of time that turns copyparty into a dependable piece of home or office infrastructure.