mkunit remove
Stop, disable, and remove a unit file.
mkunit remove <name> [flags]
Description
The remove command cleanly removes a unit by stopping it (if running),
disabling it (if enabled), removing the unit file, and running daemon-reload.
This is the reverse of mkunit service --install --enable --start.
Arguments
| Argument | Description |
|---|---|
<name> |
Name of the unit to remove |
Flags
| Flag | Description | Default |
|---|---|---|
--system |
Remove a system unit (requires sudo) | false |
--force, -f |
Don't prompt for confirmation | false |
--keep-logs |
Don't clear journal logs for this unit | false |
--dry-run |
Show what would be done without doing it | false |
What Remove Does
The remove command performs the following steps in order:
- Stop the unit if it's running
- Disable the unit if it's enabled
- Remove the unit file
- Run
systemctl daemon-reload - Optionally clear journal logs for the unit
Examples
Remove a user service
mkunit remove myapp
Output:
Stopping myapp.service...
Disabling myapp.service...
Removing /home/user/.config/systemd/user/myapp.service...
Reloading systemd...
Removed myapp.service
Remove without confirmation
mkunit remove myapp --force
Remove a system service
sudo mkunit remove nginx --system
Preview removal
mkunit remove myapp --dry-run
Keep the logs
mkunit remove myapp --keep-logs
Remove a timer and its service
mkunit remove backup.timer
mkunit remove backup.service
Warning
This action cannot be undone. The unit file will be permanently deleted.
Use --dry-run to preview what will be removed.
See Also
- mkunit list - List units to find what to remove
- mkunit status - Check unit status before removing
- mkunit show - View unit contents before removing