On Debian, you should place custom systemd service files in:
## **`/etc/systemd/system/`**
This is the recommended location for:
- Custom service files you create
- Local modifications to existing services
- Third-party service files
## Example:
```bash
sudo nano /etc/systemd/system/myapp.service
```
## After creating the service file:
1. **Reload systemd** to recognize the new service:
```bash
sudo systemctl daemon-reload
```
2. **Enable the service** (if you want it to start at boot):
```bash
sudo systemctl enable myapp.service
```
3. **Start the service**:
```bash
sudo systemctl start myapp.service
```
## Other systemd directories (for reference):
- **`/lib/systemd/system/`** - System-provided service files (don't modify these directly)
- **`/usr/lib/systemd/system/`** - Package-provided service files
- **`/run/systemd/system/`** - Runtime service files (temporary)
- **`~/.config/systemd/user/`** - User-specific service files (for `systemctl --user`)
## Priority order:
Files in `/etc/systemd/system/` take precedence over those in `/lib/systemd/system/`, so you can override system defaults by placing files with the same name in `/etc/systemd/system/`.