Welcome to the NZRT Wiki Podcast. Today we’re looking at 🎯 Nextcloud CLI Cheatsheet.
If you manage a Nextcloud installation, you’ll quickly discover that the command line is your best friend. Nextcloud ships with a built-in tool called occ — short for ownCloud Console — and it handles just about everything you’d ever need to do from the server side. Let’s walk through the key things you can do with it.
Starting with user management. You can create a new user, delete one, or just pull up a list of everyone on the system. If someone forgets their password, there’s a command to reset it. You can also temporarily block a user from logging in by disabling their account, then re-enable them when needed. Setting storage quotas is straightforward too — you specify the user and a size value, and Nextcloud enforces that limit. You can also check when a user last logged in, which is handy for auditing inactive accounts.
Group management works in a similar way. You create a group by name, add users to it, remove users from it, and delete the group when it’s no longer needed. There are commands to list every user inside a specific group, and also to look up which groups a particular user belongs to — both directions covered.
For app management, occ lets you install, enable, disable, update, and remove apps without touching the web interface. You can list everything currently installed, check info on a specific app, or update all apps in one go. This is especially useful when you’re doing maintenance windows and want to script the whole thing.
File management is where things get really practical. If you’ve added files directly to the server — bypassing the web upload — Nextcloud won’t know they exist until you run a file scan. You can scan all users at once or target a specific user. There’s also a cleanup command that permanently removes trash items older than thirty days, a cache check for flagging file database inconsistencies, and commands to transfer all of one user’s files to another user, or to clear the file cache entirely.
On the database side, there are a few important housekeeping commands. One converts the file cache table to support larger integer values, which is something you’ll need on big installations. Another checks for and adds missing primary keys. You can also run raw database queries directly through occ if you need to inspect table sizes or check on the database state.
Configuration management is powerful. You can get or set configuration values for any app, delete config keys you no longer need, or list all configuration currently active on the system. System-wide settings work the same way — for example, you can read or update the list of trusted domains that Nextcloud will respond to.
Maintenance mode is something you’ll use before any major update or restore. One command turns it on, blocking all user access, and another turns it off again. You can also check the current system status, find out where the data directory lives, and get help on any specific command if you’re unsure of its options.
For sharing, you can list all active shares on the system, create a new share pointing to a file or folder, delete a share by its ID, or transfer share ownership from one user to another. This is useful when staff members leave and you need to reassign their shared content cleanly.
Logging and monitoring are covered too. Rather than using occ directly for logs, you’ll tail the main Nextcloud log file — you can view the last fifty lines, watch it in real time as events come in, or search it for error-level entries specifically. Background jobs have their own set of commands: you can check the queue status, list pending jobs, or manually trigger one job to run immediately.
Backup and restore rely on standard Linux tools alongside occ. For the database, you use mysqldump to export everything to a SQL file, and then restore by piping that file back into MySQL. For the Nextcloud application directory itself, you compress it into a tar archive for backup and extract it to restore. Always combine both steps — database and files — for a complete backup.
Finally, if you’re running LDAP for centralised user authentication, occ has you covered there too. You can test whether your LDAP connection is working, view the current LDAP configuration, sync users and groups from your directory, and inspect the mapping between LDAP entries and Nextcloud accounts.
At NZRT, both xc as the admin and dan as the DBA work with these commands regularly — for provisioning new users, managing groups, running maintenance, and troubleshooting issues as they come up. If you want to go deeper, the related notes in the wiki cover the full occ command reference and the administration overview.
That’s it for this episode of the NZRT Wiki Podcast. Thanks for listening.