sudo -u www-data php occ #以www-data用户身份执行OCC文件
会输出以下内容(以Nextcloud为例):
Nextcloud version 11.0.1 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --no-warnings Skip global warnings, show command output only -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: _completion BASH completion hook. check check dependencies of the server environment help Displays help for a command list Lists commands status show some status information upgrade run upgrade routines after installation of a new release. The release has to be installed before. app app:check-code check code to be compliant app:disable disable an app app:enable enable an app app:getpath Get an absolute path to the app directory app:list List all available apps background background:ajax Use ajax to run background jobs background:cron Use cron to run background jobs background:webcron Use webcron to run background jobs config config:app:delete Delete an app config value config:app:get Get an app config value config:app:set Set an app config value config:import Import a list of configs config:list List all configs config:system:delete Delete a system config value config:system:get Get a system config value config:system:set Set a system config value dav dav:create-addressbook Create a dav addressbook dav:create-calendar Create a dav calendar dav:sync-birthday-calendar Synchronizes the birthday calendar dav:sync-system-addressbook Synchronizes users to the system addressbook db db:convert-type Convert the Nextcloud database to the newly configured one db:generate-change-script generates the change script from the current connected db to db_structure.xml encryption encryption:change-key-storage-root Change key storage root encryption:decrypt-all Disable server-side encryption and decrypt all files encryption:disable Disable encryption encryption:enable Enable encryption encryption:encrypt-all Encrypt all files for all users encryption:list-modules List all available encryption modules encryption:set-default-module Set the encryption default module encryption:show-key-storage-root Show current key storage root encryption:status Lists the current status of encryption federation federation:sync-addressbooks Synchronizes addressbooks of all federated clouds files files:cleanup cleanup filecache files:scan rescan filesystem files:transfer-ownership All files and folders are moved to another user - shares are moved as well. files_external files_external:applicable Manage applicable users and groups for a mount files_external:backends Show available authentication and storage backends files_external:config Manage backend configuration for a mount files_external:create Create a new mount configuration files_external:delete Delete an external mount files_external:export Export mount configurations files_external:import Import mount configurations files_external:list List configured admin or personal mounts files_external:notify Listen for active update notifications for a configured external mount files_external:option Manage mount options for a mount files_external:verify Verify mount configuration group group:adduser add a user to a group group:list list configured groups group:removeuser remove a user from a group integrity integrity:check-app Check integrity of an app using a signature. integrity:check-core Check integrity of core code using a signature. integrity:sign-app Signs an app using a private key. integrity:sign-core Sign core using a private key. l10n l10n:createjs Create javascript translation files for a given app log log:file manipulate logging backend log:manage manage logging configuration 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:singleuser set single user mode maintenance:update:htaccess Updates the .htaccess file security security:certificates list trusted certificates security:certificates:import import trusted certificate security:certificates:remove remove trusted certificate trashbin trashbin:cleanup Remove deleted files trashbin:expire Expires the users trashbin twofactorauth twofactorauth:disable Disable two-factor authentication for a user twofactorauth:enable Enable two-factor authentication for a user user user:add adds a user user:delete deletes the specified user user:disable disables the specified user user:enable enables the specified user user:info show user info user:lastseen shows when the user was logged in last time user:list list configured users user:report shows how many users have access user:resetpassword Resets the password of the named user user:setting Read and modify user settings versions versions:cleanup Delete versions versions:expire Expires the users file versions
在CentOS中,命令是这样的:
sudo -u apache php occ
区别就是Ubuntu和CentOS的http服务器用户不同
使用它!
1,遇到一个新命令行工具,我们首先要help一下。
sudo -u www-data php occ -h
输出如下
Usage: help [options] [--] [<command_name>] #格式:help [选项] [--] [命令名] Arguments: command The command to execute command_name The command name [default: "help"] #命令名(对应使用格式中的“命令名”) Options: #选项 --format=FORMAT The output format (txt, xml, json, or md) [default: "txt"] #输出格式,默认为txt,下文中有讲 --raw To output raw command help #输出原始命令帮助 -h, --help Display this help message #显示帮助信息 -q, --quiet Do not output any message #不输出任何信息 -V, --version Display this application version #显示程序版本 --ansi Force ANSI output #强制使用ANSI格式输出 --no-ansi Disable ANSI output #禁用ANSI输出 -n, --no-interaction Do not ask any interactive question #不要询问任何问题(所有选项默认,大概这个意思) --no-warnings Skip global warnings, show command output only #跳过错误信息 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug # 增加消息的详细程度:1用于正常输出,2用于更详细的输出,3用于调试 Help: The help command displays help for a given command: #详细地,查看一个命令的使用方法,例如: php occ help list You can also output the help in other formats by using the --format option: php occ help --format=xml list To display the list of available commands, please use the list command.
使用-h选项获取一个命令的详细信息,比如我要查询maintenance:mode(维护模式)命令的使用方式
输入
sudo -u www-data php occ help maintenance:mode
Usage: maintenance:mode [options] #格式: maintenance:mode+选项(即maintenance:mode后面跟选项) Options: #选项(对应上面格式中的“选项”) --on enable maintenance mode #激活维护模式 --off disable maintenance mode #关闭维护模式 -h, --help Display this help message #显示帮助信息,即本段信息 -q, --quiet Do not output any message #不输出任何信息 -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --no-warnings Skip global warnings, show command output only -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
2.显示ownCloud/Nextcloud版本
以Ubuntu、Nextcloud为例
sudo -u www-data php occ -V #选项为-V,注意大写 Nextcloud version 9.0.0 #Nextcloud版本为 9.0.0
3.查询您的Nextcloud服务器状态
sudo -u www-data php occ status - installed: true #安装状态:已安装 - version: 9.0.0.19 #版本:9.0.0.19 - versionstring: 9.0.0 #版本串:9.0.0 - edition: #发行版本,社区版不显示,企业版可能会显示
4.命令输出格式,可以输出txt, xml, json或 md格式的信息
比如以json格式输出服务器状态信息:
sudo -u www-data php occ status --output=json {"installed":true,"version":"9.0.0.19","versionstring":"9.0.0","edition":""}
或者以json_pretty格式输出:
sudo -u www-data php occ status --output=json_pretty { "installed": true, "version": "9.0.0.19", "versionstring": "9.0.0", "edition": "" }
(这样,OCC命令可以作为一个API来使用)
5.命令自动补全
Nextcloud11后,OCC命令可以使用自动补全命令,你需要以下命令来设置自动补全
# BASH ~4.x, ZSH source <(/var/www/html/nextcloud/occ _completion --generate-hook) # BASH ~3.x, ZSH /var/www/html/nextcloud/occ _completion --generate-hook | source /dev/stdin # BASH (any version) eval $(/var/www/html/nextcloud/occ _completion --generate-hook)
设置后,只有提供OCC文件完整目录(比如/var/www/html/nextcloud/occ <tab>)才能使用自动补全。在–generate-hook之后指定–programm occ,便可无需在写完整目录。
这样,当你使用OCC命令行工具时,按下Tab键便可自动补全剩余的命令内容。
例如
输入 sudo -u www-data php occ sta 按Tab键,命令自动补全为: sudo -u www-data php occ status
插件(APP)管理命令
使用以下命令列出、激活禁用插件
app app:check-code check code to be compliant #检查代码是否合法 app:disable disable an app #禁用一个插件(app) app:enable enable an app #激活一个插件 app:getpath Get an absolute path to the app directory #获取应用程序目录的绝对路径 app:list List all available apps #列出所有可用的插件
命令示例:
sudo -u www-data php occ app:list Enabled: - activity: 2.4.1 - comments: 1.1.0 - dav: 1.1.1 - direct_menu: 0.10.0 - federatedfilesharing: 1.1.1 - federation: 1.1.1 - files: 1.6.1 - files_external: 1.1.2 - files_markdown: 1.0.0 - files_pdfviewer: 1.0.1 - files_sharing: 1.1.1 - files_texteditor: 2.2 - files_trashbin: 1.1.0 - files_versions: 1.4.0 - files_videoplayer: 1.0.0 - firstrunwizard: 2.0 - gallery: 16.0.0 - logreader: 2.0.0 - lookup_server_connector: 1.0.0 - nextcloud_announcements: 1.0 - notifications: 1.0.1 - password_policy: 1.1.0 - provisioning_api: 1.1.0 - serverinfo: 1.1.1 - sharebymail: 1.0.1 - survey_client: 0.1.5 - systemtags: 1.1.3 - theming: 1.1.1 - twofactor_backupcodes: 1.0.0 - updatenotification: 1.1.1 - user_saml: 1.2.2 - workflowengine: 1.1.1 Disabled: - admin_audit - encryption - external - files_accesscontrol - files_automatedtagging - files_retention - spreed - spreedme - templateeditor - user_external - user_ldap
近期评论