Skip to main content

NextCloud OCC

occ (ownCloud/Nextcloud Console) is Nextcloud's command-line interface for configuration, maintenance, user administration, and system upgrades.

In this environment, Nextcloud runs inside rootless Podman (docker-data, UID 1100) as the nextcloud container (nextcloud.container systemd user Quadlet). All occ commands must be executed as the web server user (www-data) inside the container.


Running occ in Rootless Podman

Standard Command Pattern

(cd /tmp && sudo -u docker-data podman exec -u www-data nextcloud php occ <command>)

Shell Alias

To simplify running commands across your terminal sessions, define an alias:

alias occ='(cd /tmp && sudo -u docker-data podman exec -u www-data nextcloud php occ)'

(All commands below assume this alias is active.)


Getting Started: Status and Help

# Check Nextcloud version, installation status, and maintenance state
occ status

# List all available commands
occ list

# Get detailed help for any specific command
occ help config:system:set

Practical Example: Redirecting Root / to Files

By default, Nextcloud directs authenticated users to the Dashboard app (/apps/dashboard/). You can customize the landing page using config:system:set and config:app:set:

# Set the default application to Files
occ config:system:set defaultapp --value="files"

# Configure core default page to redirect root / directly to user files
occ config:app:set core defaultpage --value="/apps/files/files"

To verify the current values:

occ config:system:get defaultapp
occ config:app:get core defaultpage

System Configuration (config:system:*)

System configurations directly inspect or modify config/config.php.

Reading & Writing Settings

# Get a configuration value
occ config:system:get trusted_domains

# Set a scalar string or boolean value
occ config:system:set defaultapp --value="files"
occ config:system:set htaccess.IgnoreFrontController --value="true" --type=bool

# Set array elements by index
occ config:system:set trusted_domains 2 --value="cloud.drheck.dev"

# Remove a setting
occ config:system:delete defaultapp

App Configuration & Management (config:app:* & app:*)

Managing App Settings

# List all config keys for an app
occ config:app:get core

# Get a single key
occ config:app:get core defaultpage

# Set a key value
occ config:app:set core defaultpage --value="/apps/files/files"

# Delete a setting
occ config:app:delete core defaultpage

Enabling, Disabling, and Updating Apps

# List installed, enabled, and disabled apps
occ app:list

# Enable or disable an app
occ app:enable files_rightclick
occ app:disable dashboard

# Update all installed apps
occ app:update --all

Filesystem Operations (files:*)

Useful when files are added, modified, or deleted externally on disk (e.g. through local mounts or background syncing).

# Rescan files for all users
occ files:scan --all

# Rescan files for a single user
occ files:scan luke

# Rescan a specific subdirectory for a user
occ files:scan --path="/luke/files/Documents"

# Clean up stale file cache entries
occ files:cleanup

Maintenance & Database Tasks

Maintenance Mode

# Enable maintenance mode (blocks user web access)
occ maintenance:mode --on

# Disable maintenance mode
occ maintenance:mode --off

Database Optimization & Missing Indices

Nextcloud updates occasionally recommend adding missing indices or columns:

# Add missing database indices
occ db:add-missing-indices

# Add missing columns
occ db:add-missing-columns

# Add missing primary keys
occ db:add-missing-primary-keys

Post-Upgrade Migration

After pulling a newer container image:

occ upgrade

User Management (user:*)

# List all registered users
occ user:list

# View details for a user
occ user:info luke

# Reset user password interactively
occ user:resetpassword luke

# Enable or disable a user account
occ user:disable username
occ user:enable username