• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Projects Nextcloud

Nextcloud OCC Command Guide: Maintenance and Practical Use Cases

neo by neo
September 11, 2025
in Nextcloud
0
Nextcloud: Maintenance with OCC Command with Practical Examples

Nextcloud: Maintenance with OCC Command with Practical Examples

0
SHARES
443
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Maintenance with OCC Command
  • Prerequisites for Nextcloud Maintenance with occ Command
  • Practical Examples of occ Command for Maintenance Tasks
    • Check Nextcloud System Status
    • Scan the Files and Optimize the File Cache
    • Enable or Disable Maintenance Mode
    • Listing Installed Apps
    • Database Maintenance After Nextcloud Upgrade
  • Other Useful occ Commands Examples

Maintenance with OCC Command

In this article, we’ll walk through various maintenance tasks that can be performed with occ command. I will present you practical examples to disable or enable maintenance mode, optimize your Nextcloud instance, optimizing the database and more.

Whether you’re looking to manage file caching or configure system-wide updates, the occ command is an essential tool for every Nextcloud administrator.

Nextcloud’s occ command (origins from “ownCloud Console”) is Nextcloud’s command-line interface. You can perform many common server operations with occ, such as installing and upgrading Nextcloud, manage users, encryption, passwords, LDAP setting, and more.

Prerequisites for Nextcloud Maintenance with occ Command

occ is in the nextcloud/ directory; for example /var/www/nextcloud on Ubuntu Linux. occ is a PHP script. You must run it as your HTTP user to ensure that the correct permissions are maintained on your Nextcloud files and directories.

Practical Examples of occ Command for Maintenance Tasks

Before executing occ command, you need to navigate to the Nextcloud directory. In my case, it is in the

cd /var/www/html/nextcloud

Check Nextcloud System Status

To check system status, you can execute the following command in your Nextxloud directory:

sudo -u www-data php occ status

Output is something like:

root@nextcloud:/var/www/html/nextcloud# sudo -u www-data php occ status
  - installed: true
  - version: 30.0.3.2
  - versionstring: 30.0.3
  - edition:
  - maintenance: false
  - needsDbUpgrade: false
  - productname: Nextcloud
  - extendedSupport: false

Scan the Files and Optimize the File Cache

sudo -u www-data php occ files:scan --all
Output of occ files:scan command
Output f occ files:scan command

Enable or Disable Maintenance Mode

To disable maintenance mode, you can execute the following command:

# Enable Maintenance Mode
sudo -u www-data php occ maintenance:mode --on

# Disable Maintenance Mode
sudo -u www-data php occ maintenance:mode --off

Listing Installed Apps

To list all installed application on your Nextcloud Server, you can execute:

sudo -u www-data php occ app:list

In my case, there are a lot of installed application:

ADVERTISEMENT
ADVERTISEMENT
Enabled:
  - activity: 3.0.0
  - admin_audit: 1.20.0
  - app_api: 4.0.3
  - audioplayer: 3.4.1
  - bruteforcesettings: 3.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contactsinteraction: 1.11.0
  - cospend: 2.0.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - files: 2.2.0
  - files_accesscontrol: 1.20.1
  - files_downloadlimit: 3.0.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - geoblocker: 0.5.15
  - groupfolders: 18.0.7
  - groupquota: 0.2.1
  - login_notes: 1.6.1
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - memories: 7.4.1
  - nextcloud_announcements: 2.0.0
  - notes: 4.11.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - quota_warning: 1.20.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - spreed: 20.1.0
  - suspicious_login: 8.0.0
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - updatenotification: 1.20.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - circles: 30.0.0 (installed 25.0.0)
  - encryption: 2.18.0
  - federation: 1.20.0 (installed 1.18.0)
  - files_external: 1.22.0
  - recommendations: 3.0.0 (installed 1.3.0)
  - support: 2.0.0 (installed 1.7.0)
  - survey_client: 2.0.0 (installed 1.16.0)
  - systemtags: 1.20.0 (installed 1.18.0)
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_ldap: 1.21.0
  - weather_status: 1.10.0 (installed 1.9.0)
  - workflow_media_converter: 1.11.7 (installed 1.11.7)

Database Maintenance After Nextcloud Upgrade

After upgrading my Nextcloud environment, I am running the following occ command to optimize Database:

IMPORTANT: Create a backup of DB before running this command!

mysqldump -u root -p nextcloud > backup.sql

Add missing primary keys:

sudo -u www-data php occ db:add-missing-primary-keys

sudo -u www-data php occ db:add-missing-indices
sudo -u www-data php occ db:convert-filecache-bigint

Output:


root@nextcloud:/var/www/html$  sudo -u www-data php occ db:add-missing-primary-keys
Done.

Other Useful occ Commands Examples

Running occ with no options lists all commands and options, like this example on Ubuntu:

 sudo -u www-data php occ

Example of output:

 maintenance
  maintenance:data-fingerprint                    update the systems data-fingerprint after a backup is restored
  maintenance:mimetype:update-db                  Update database mimetypes and update filecache
  maintenance:mimetype:update-js                  Update mimetypelist.js
  maintenance:mode                                set maintenance mode
  maintenance:repair                              repair this installation
  maintenance:repair-share-owner                  repair invalid share-owner entries in the database
  maintenance:theme:update                        Apply custom theme changes
  maintenance:update:htaccess                     Updates the .htaccess file

Please check other Nextcloud topics on my blog.

Nextcloud: Maintenance with OCC Command with Practical Examples

defencedev.com

About The Author

neo

See author's posts

Tags: nextcloud
ADVERTISEMENT
Previous Post

Linux Networking: netplan Network Configuration on Ubuntu

Next Post

Check Disk Usage on Ubuntu Terminal Using ncdu – Easy & Fast Guide

neo

neo

Related Posts

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)
Nextcloud

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)

Self-Hosted Nextcloud Hub 10 on Ubuntu – My Top 5 Apps
Nextcloud

Nextcloud: My Top 5 Must-Have Apps

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality
Nextcloud

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Nextcloud: Manual Upgrade from 25.0 to 26.0 on Ubuntu 22.04
Nextcloud

Nextcloud Manual Upgrade on Ubuntu 22.04: Step-by-Step Guide

Nextcloud: Security Concept with FortiGate Firewall
Nextcloud

Nextcloud: Security Concept with FortiGate Firewall

NextCloud dashboard screenshot
Nextcloud

Nextcloud: How to Upgrade Nextcloud via the Web Interface

Next Post
Solutions: Check Disk Usage on Ubuntu Terminal with ncdu Application

Check Disk Usage on Ubuntu Terminal Using ncdu – Easy & Fast Guide

Recommended

Lesson 9: Bash Maths Operations (Bash Arithmetic) Examples

Lesson 9: Bash Maths Operations (Bash Arithmetic) Examples

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Install Portainer on Ubuntu 24.04 Using Docker Compose

Install Portainer on Ubuntu 24.04 Using Docker Compose

FortiGate Country Address Object Generator – Block or Allow Access by Country

FortiGate Country Address Object Generator – Block or Allow Access by Country

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • Web Tools
ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

Install Portainer on Ubuntu 24.04 Using Docker Compose

Install Portainer on Ubuntu 24.04 Using Docker Compose

FortiGate Country Address Object Generator – Block or Allow Access by Country

FortiGate Country Address Object Generator – Block or Allow Access by Country

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.