Nextcloud offers a range of occ commands for management and maintenance, making it easier to keep your cloud storage up and running smoothly.
You can use the occ command to update Nextcloud, which is essential for ensuring you have the latest security patches and features. This can be done with a simple command like `sudo -H php occ update`.
For example, updating to the latest version can be done with `sudo -H php occ update:all`. This command updates all components of Nextcloud, including the core, apps, and libraries.
To check the Nextcloud version, you can use the `sudo -H php occ info:version` command. This will display the current version of Nextcloud, including the major, minor, and patch versions.
Occ commands can also be used to troubleshoot issues with Nextcloud. For instance, you can use `sudo -H php occ status` to check the status of the Nextcloud server, including any errors or warnings.
Installation and Management
You can install Nextcloud entirely from the command line using the occ commands. After downloading the tarball and copying Nextcloud into the appropriate directories, you can use occ commands in place of running the graphical Installation Wizard.
Displaying your maintenance:install options will show you the available options. This is where you can choose your occ options and complete the installation.
Supported databases are listed after displaying your maintenance:install options.
Line Installation
You can install Nextcloud entirely from the command line after downloading the tarball and copying Nextcloud into the appropriate directories. This method is a great alternative to running the graphical Installation Wizard.
To start, you'll need to use the occ commands, which are available only after you've downloaded and unpacked the Nextcloud archive and taken no further installation steps. These commands allow you to complete the installation process without having to navigate the graphical interface.
Displaying your maintenance:install options is a crucial step in the process, as it lists your available options for completing the installation. This is where you'll choose the settings that work best for your specific needs.
Supported databases are:
Versions
The "Versions" app is a crucial part of the system, and it's only available when enabled.
To delete file versions, you'll need to use the "Versions" command, which is only accessible when the "Versions" app is enabled.
You can delete all versions for all users with a single command, or specify individual users in a space-delimited list.
The "Versions" command is supported by various databases, but the article doesn't specify which ones exactly.
File and Directory Management
File and Directory Management is a crucial aspect of Nextcloud administration. To scan files, use the `occ files:scan` command, specifying the user, path, or all files.
You can scan all files for a user with `sudo -u www-data php /var/www/nextcloud/occ files:scan -v --all`. Alternatively, you can scan a specific user's files with `sudo -u www-data php /var/www/nextcloud/occ files:scan -v myusername`. If you need to scan a specific folder, use `sudo -u www-data php /var/www/nextcloud/occ files:scan -v --path="/myusername/files/myfolder/mysubfolder" myusername`.
To tidy up the server's file cache, use the `files:cleanup` command. This command deletes all file entries that have no matching entries in the storage table.
Directory
To manage your directories effectively, it's essential to understand the commands available in the occ command directory.
You can run occ as your HTTP user to execute various commands. This includes running commands in maintenance mode, which is crucial for troubleshooting and resolving issues.
The occ command directory is extensive, offering a range of options for managing your directories. Some of the key commands include apps commands, background jobs selector, and config commands.
Here are some of the main commands available in the occ command directory:
- Apps commands
- Background Jobs Selector
- Config commands
- Dav commands
- Database conversion
- Encryption
- Federation sync
- File operations
- Files external
- Integrity check
- l10n, create JavaScript translation files for apps
- LDAP commands
- Logging commands
- Maintenance commands
- Security
- Trashbin
- User commands
- Group commands
- Versions
- Command line installation
- Command line upgrade
- Two-factor authentication
- Disable users
- System Tags
- Antivirus
- Setupchecks
- Debugging
You can also customize the output format of some commands, such as the status command, to display the information in a JSON format.
Setting an Array
Some configurations, like the trusted domain setting, are an array of data. This means you need to specify the array index when setting a value.
To set one of multiple values, you need to specify the array index as the second name in the command, separated by a space. For example, to replace sample.tld with example.com, you need to set trusted_domains => 2.
You can also specify multiple config names separated by spaces to set the value of one key. This is how you replace sample.tld with example.com in the trusted domain setting.
You need to delete the configuration of an app or system configuration by using the config:system:set command with the correct syntax.
Security and Authentication
Two-factor authentication is enabled for all users by default if a two-factor provider app is enabled.
This means that if a user loses access to their second factor, such as their phone with two-factor SMS verification, the admin can temporarily disable the two-factor check for that user via the occ command.
To re-enable two-factor authentication, the admin can use the same command that was used to disable it.
User: Reset Password
Resetting a user's password can be a straightforward process. You can reset any user's password, including administrators.
If you're having trouble remembering your admin password, don't worry, you can use the "password-from-env" method to reset it. This is a convenient option.
To reset a user's password, you can simply use the "user:resetpassword" command. This will allow you to reset any user's password.
Encryption and Security
Encryption and security are crucial for protecting sensitive data. You can enable server-side encryption with the command `occ encryption:enable`. This ensures that data is safely encrypted, making it unreadable to unauthorized users.
Disabling server-side encryption is also possible with the command `occ encryption:disable`. This is useful when you need to access or transfer data.
If you've already encrypted files, you can use the command `occ encryption:scan` to scan and repair them. This helps maintain data integrity and prevents potential issues.
Rescanning the app data folder is also a good practice to ensure everything is up to date. You can do this with the command `occ files:scan-app-data`. This command specifically rescans the app data folder.
For a more comprehensive scan, you can use the command `occ files:scan:all`. This rescans all files for all users, providing a thorough check of your system's security.
Two-Factor Authentication
Two-Factor Authentication is enabled by default for all users when a two-factor provider app is enabled, though the provider decides whether the user must pass a challenge.
If a user loses access to their second factor, the admin can temporarily disable the two-factor check for that user using the occ command.
This allows users to regain access to their account without requiring a working second factor.
To re-enable two-factor authentication again, the admin can use a specific command.
Sources
- https://www.ullright.org/ullWiki/show/nextcloud-cheatsheet
- https://docs.nextcloud.com/server/latest/admin_manual/occ_command.html
- https://lightningcr.com/projects/nextcloud/wiki/Essential_Commands_for_Managing_Apps_with_%27occ%27
- https://www.edv2.com/nxt/core/doc/admin/configuration_server/occ_command.html
- https://blog.netways.de/blog/2017/07/19/how-to-use-nextcloud-cli/
Featured Images: pexels.com