Interactive Mode
How mkunit prompts for missing options.
How It Works
mkunit is designed to be both interactive and scriptable. When you run a command without all required options, mkunit will prompt you for the missing information. If you provide all required options, it runs without any prompts.
Example: Interactive Service Creation
$ mkunit service myapp
Service name: myapp
Command to run: ./server
Working directory [/home/user/myapp]:
Restart policy [on-failure]: always
User service or system? [user]:
Created myapp.service
Install now? [Y/n]: y
Installed to ~/.config/systemd/user/myapp.service
Start now? [Y/n]: y
Started myapp.service
Example: Non-Interactive Service Creation
The same service created without any prompts:
mkunit service myapp \
--exec "./server" \
--workdir /home/user/myapp \
--restart always \
--install --start
When Does mkunit Prompt?
mkunit prompts when:
- Required options are missing - Like
--execfor services - After creating a unit - Asks if you want to install/start
- Destructive operations - Like
mkunit remove
mkunit does NOT prompt when:
- All required options are provided via flags
- The
--no-interactiveflag is used - stdin is not a TTY (e.g., in scripts or CI)
Defaults and Suggestions
Interactive prompts show defaults in brackets. Press Enter to accept:
Working directory [/home/user/myapp]: # Press Enter for /home/user/myapp
Restart policy [on-failure]: # Press Enter for on-failure
mkunit infers smart defaults:
- Working directory - Current directory
- Restart policy -
on-failure(good for most services) - Service type -
user(no sudo required)
Disabling Interactive Mode
Use --no-interactive to disable prompts:
# Fails if --exec is missing
mkunit service myapp --no-interactive
# Works - all required options provided
mkunit service myapp --exec "./server" --no-interactive
This is useful for:
- Scripts and automation
- CI/CD pipelines
- When you want to fail fast on missing options
Environment Detection
mkunit automatically detects non-interactive environments:
# These disable interactive mode automatically:
# Piped input
echo "something" | mkunit service myapp
# Non-TTY stdin
mkunit service myapp < /dev/null
# CI environments (detected via CI env var)
CI=true mkunit service myapp
Combining Interactive and Flags
You can provide some options and let mkunit ask for the rest:
$ mkunit service myapp --exec "./server"
# Only prompts for optional fields not provided:
Working directory [/home/user/myapp]:
Restart policy [on-failure]:
Created myapp.service
Install now? [Y/n]:
Confirmation Prompts
Some commands ask for confirmation:
$ mkunit remove myapp
Remove myapp.service? This will:
- Stop the service if running
- Disable the service
- Delete the unit file
Are you sure? [y/N]: y
Removed myapp.service
Skip with --force:
mkunit remove myapp --force
See Also
- Scripting & CI - Using mkunit in automation
- service command - All service options