# ownCloud 8.0 Server Administration Manual

# Using the occ Command

ownCloud’s `occ` command (ownCloud console) is ownCloud’s command-line interface. You can perform many common server operations with `occ`:

    * Manage apps
    * Manage users
    * Convert the ownCloud database
    * Reset passwords, including administrator passwords
    * Convert the ownCloud database from SQLite to a more performant DB
    * Query and change LDAP settings

`occ` is in the `owncloud/` directory; for example `/var/www/owncloud` 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 ownCloud files and directories.

The HTTP user is different on the various Linux distributions. See the Setting Strong Directory Permissions section of Installation Wizard to learn how to find your HTTP user.

- The HTTP user and group in Debian/Ubuntu is `www-data`.
- The HTTP user and group in Fedora/CentOS is `apache`.
- The HTTP user and group in Arch Linux is `http`.
- The HTTP user in openSUSE is `wwwrun`, and the HTTP group is `www`.

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

    $ sudo -u www-data php occ
    ownCloud version 8.0.3
    Usage:
     [options] command [arguments]

    Options:
     --help (-h)           Display this help message
     --quiet (-q)          Do not output any message
     --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal
                           output, 2 for more verbose output and 3 for debug
     --version (-V)        Display this application version
     --ansi                Force ANSI output
     --no-ansi             Disable ANSI output
     --no-interaction (-n) Do not ask any interactive question

    Available commands:
     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.

This is the same as `sudo -u www-data php occ list`.

Run it with the `-h` option for syntax help:

    $ sudo -u www-data php occ -h

Display your ownCloud version:

    $ sudo -u www-data php occ -V
      ownCloud version 8.0.3

Query your ownCloud server status:

    $ sudo -u www-data php occ status
      - installed: true
      - version: 8.0.3.4
      - versionstring: 8.0.3
      - edition: Enterprise

`occ` has options, commands, and arguments. Options and arguments are optional, while commands are required. The syntax is:

    occ [options] command [arguments]

Get detailed information on individual commands with the `help` command, like this example for the `maintenance:mode` command:

    $ sudo -u www-data php occ help maintenance:mode
      Usage:
      maintenance:mode [--on] [--off]

      Options:
      --on                  enable maintenance mode
      --off                 disable maintenance mode
      --help (-h)           Display this help message.
      --quiet (-q)          Do not output any message.
      --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal
      output, 2 for more verbose output and 3 for debug
      --version (-V)        Display this application version.
      --ansi                Force ANSI output.
      --no-ansi             Disable ANSI output.
      --no-interaction (-n) Do not ask any interactive question.

## Apps Commands

The `app` commands list, enable, and disable apps. This lists all of your installed apps, and shows whether they are enabled or disabled:

    $ sudo -u www-data php occ app:list

Enable an app:

    $ sudo -u www-data php occ app:enable external
      external enabled

Disable an app:

    $ sudo -u www-data php occ app:disable external
      external disabled

## Database Conversion

The SQLite database is good for testing, and for ownCloud servers with small workloads, but production servers with multiple users should use MariaDB, MySQL, or PostgreSQL. You can use `occ` to convert from SQLite to one of these other databases. You need:

- Your desired database and its PHP connector installed
- The login and password of a database admin user
- The database port number, if it is a non-standard port

This is example converts to SQLite MySQL/MariaDB:

    $ sudo -u www-data php occ db:convert-type mysql oc_dbuser 127.0.0.1
    oc_database

For a more detailed explanation see Converting Database Type

## Encryption

When you are using encryption, you must manually migrate your encryption keys after upgrading your ownCloud server:

    $ sudo -u www-data php occ encryption:migrate

## File Operations

The `files:scan` command scans for new files and updates the file cache. You may rescan all files, per-user, a space-delimited list of users, and limit the search path:

    $ sudo -u www-data php occ  files:scan --help
      Usage:
      files:scan [-p|--path="..."] [-q|--quiet] [--all] [user_id1] ... [user_idN]

    Arguments:
      user_id               will rescan all files of the given user(s)

    Options:
      --path (-p)           limit rescan to this path, eg.
      --path="/alice/files/Music", the user_id is determined by the path and the
      user_id parameter and --all are ignored
      --all                 will rescan all files of all known users

`files:cleanup` tidies up the server’s file cache by deleting all file entries that have no matching entries in the storage table.

## l10n, Create javascript Translation Files for Apps

Use the `l10n:createjs` to translate apps into various languages, using this syntax:

    l10n:createjs appname language_name

This example converts the Activity app to Bosnian:

    $ sudo -u www-data php occ l10n:createjs activity bs

These are the supported language codes, and Codes for the Representation of Names of Languages may be helpful:

    ach                     gu     ml     sr
    ady          eo         he     ml_IN  sr@latin
    af_ZA        es         hi     mn     su
    ak           es_AR      hi_IN  ms_MY  sv
    am_ET        es_BO      hr     mt_MT  sw_KE
    ar           es_CL      hu_HU  my_MM  ta_IN
    ast          es_CO      hy     nb_NO  ta_LK
    az           es_CR      ia     nds    te
    be           es_EC      id     ne     tg_TJ
    bg_BG        es_MX      io     nl     th_TH
    bn_BD        es_PE      is     nn_NO  tl_PH
    bn_IN        es_PY      it     nqo    tr
    bs           es_US      ja     oc     tzm
    ca           es_UY      jv     or_IN  ug
    ca@valencia  et_EE      ka_GE  pa     uk
    cs_CZ        eu         km     pl     ur
    cy_GB        eu_ES      kn     pt_BR  ur_PK
    da           fa         ko     pt_PT  uz
    de           fi         ku_IQ  ro     vi
    de_AT        fi_FI      lb     ru     yo
    de_CH        fil        lo     si_LK  zh_CN
    de_DE        fr         lt_LT  sk     zh_HK
    el           fr_CA      lv     sk_SK  zh_TW
    en_GB        fy_NL      mg     sl
    en_NZ        gl         mk     sq

## LDAP Commands

You can run the following LDAP commands with `occ`.

Search for an LDAP user, using this syntax:

    $ sudo -u www-data php occ ldap:search [--group] [--offset="..."]
    [--limit="..."] search

This example searches for usernames that start with “rob”:

    $ sudo -u www-data php occ ldap:search rob

Check if an LDAP user exists. This works only if the ownCloud server is connected to an LDAP server:

    $ sudo -u www-data php occ ldap:check-user robert

`ldap:check-user` will not run a check when it finds a disabled LDAP connection. This prevents users that exist on disabled LDAP connections from being marked as deleted. If you know for certain that the user you are searching for is not in one of the disabled connections, and exists on an active connection, use the `--force` option to force it to check all active LDAP connections:

> $ sudo -u www-data php occ ldap:check-user –force robert

`ldap:create-empty-config` creates an empty LDAP configuration. The first one you create has no `configID`, like this example:

    $ sudo -u www-data php occ ldap:create-empty-config
      Created new configuration with configID ''

This is a holdover from the early days, when there was no option to create additional configurations. The second, and all subsequent, configurations that you create are automatically assigned IDs:

    $ sudo -u www-data php occ ldap:create-empty-config
       Created new configuration with configID 's01'

Then you can list and view your configurations:

    $ sudo -u www-data php occ ldap:show-config

And view the configuration for a single configID:

    $ sudo -u www-data php occ ldap:show-config s01

`ldap:delete-config [configID]` deletes an existing LDAP configuration:

    $ sudo -u www-data php occ ldap:delete  s01
     Deleted configuration with configID 's01'

The `ldap:set-config` command is for manipulating configurations, like this example that sets search attributes:

    $ sudo -u www-data php occ ldap:set-config s01 ldapAttributesForUserSearch
    "cn;givenname;sn;displayname;mail"

`ldap:show-remnants` is for cleaning up the LDAP mappings table, and is documented in LDAP User Cleanup.

## Maintenance Commands

These maintenance commands put your ownCloud server into maintenance and single-user mode, and run repair steps during updates.

You must put your ownCloud server into maintenance mode whenever you perform an update or upgrade. This locks the sessions of all logged-in users, including administrators, and displays a status screen warning that the server is in maintenance mode. Users who are not already logged in cannot log in until maintenance mode is turned off. When you take the server out of maintenance mode logged-in users must refresh their Web browsers to continue working:

    $ sudo -u www-data php occ maintenance:mode --on
    $ sudo -u www-data php occ maintenance:mode --off

Putting your ownCloud server into single-user mode allows admins to log in and work, but not ordinary users. This is useful for performing maintenance and troubleshooting on a running server:

    $ sudo -u www-data php occ maintenance:singleuser --on
      Single user mode enabled

And turn it off when you’re finished:

    $ sudo -u www-data php occ maintenance:singleuser --off
      Single user mode disabled

The `maintenance:repair` command runs automatically during upgrades to clean up the database, so while you can run it manually there usually isn’t a need to:

     $ sudo -u www-data php occ maintenance:repair
        - Repair mime types
    - Repair legacy storages
    - Repair config
    - Clear asset cache after upgrade
        - Asset pipeline disabled -> nothing to do
    - Generate ETags for file where no ETag is present.
        - ETags have been fixed for 0 files/folders.
    - Clean tags and favorites
        - 0 tags for delete files have been removed.
        - 0 tag entries for deleted tags have been removed.
        - 0 tags with no entries have been removed.
    - Re-enable file app

## User Commands

The `user` commands remove users, reset passwords, display a simple report showing how many users you have, and when a user was last logged in.

You can reset any user’s password, including administrators (see Resetting a Lost Admin Password):

    $ sudo -u www-data php occ user:resetpassword layla
      Enter a new password:
      Confirm the new password:
      Successfully reset password for layla

You can delete users:

    $ sudo -u www-data php occ user:delete fred

View a user’s most recent login:

    $ sudo -u www-data php occ user:lastseen layla
      layla's last login: 09.01.2015 18:46

Generate a simple report that counts all users, including users on external user authentication servers such as LDAP:

    $ sudo -u www-data php occ user:report
    +------------------+----+
    | User Report      |    |
    +------------------+----+
    | Database         | 12 |
    | LDAP             | 86 |
    |                  |    |
    | total users      | 98 |
    |                  |    |
    | user directories | 2  |
    +------------------+----+

## Upgrade Command

When you are performing an update or upgrade on your ownCloud server (see the Maintenance section of this manual), it is better to use `occ` to perform the database upgrade step, rather than the Web GUI, in order to avoid timeouts. PHP scripts invoked from the Web interface are limited to 3600 seconds. In larger environments this may not be enough, leaving the system in an inconsistent state. After performing all the preliminary steps (see Upgrading Your ownCloud Server) use this command to upgrade your databases:

    $ sudo -u www-data php occ upgrade

Before completing the upgrade, ownCloud first runs a simulation by copying all database tables to a temporary directory and then performing the upgrade on them, to ensure that the upgrade will complete correctly. This takes twice as much time, which on large installations can be many hours, so you can omit this step with the `--skip-migration-test` option:

    $ sudo -u www-data php occ upgrade --skip-migration-test

You can perform this simulation manually with the `--dry-run` option:

    $ sudo -u www-data php occ upgrade --dry-run