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:

  1. Stop the unit if it's running
  2. Disable the unit if it's enabled
  3. Remove the unit file
  4. Run systemctl daemon-reload
  5. 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