--- title: "CLI reference" description: "Discover all the commands available in the gogs binary" icon: "terminal" --- Most people know `gogs web` for starting the server, but the `gogs` binary ships with several other commands that help you manage your instance from the command line. Run `gogs --help` at any time to see the full list of available commands, and `gogs --help` for details on a specific command. Every command accepts a `--config` (`-c`) flag to specify a custom configuration file path. The default is `custom/conf/app.ini`. ## Starting the server ```bash gogs web ``` The `web` command starts the HTTP server that powers the web UI, the REST API, and Git HTTP operations. Use the `--port` (`-p`) flag to override the default listening port. ## Administration ```bash gogs admin ``` The `admin` command lets you perform maintenance tasks without going through the web interface. Available subcommands include: | Subcommand | Purpose | |---|---| | `create-user` | Create a new user account (with optional `--admin` flag). | | `delete-inactive-users` | Remove user accounts that were never activated. | | `delete-repository-archives` | Clean up generated repository archive files. | | `delete-missing-repositories` | Remove database records for repositories whose Git data is missing on disk. | | `collect-garbage` | Run `git gc` across all repositories. | | `rewrite-authorized-keys` | Regenerate the SSH `authorized_keys` file from the database. | | `resync-hooks` | Re-write Git server-side hooks for all repositories. | | `reinit-missing-repositories` | Re-initialize bare Git repositories that are missing on disk. | `rewrite-authorized-keys` replaces the entire `authorized_keys` file. Any non-Gogs keys in that file will be lost. ## Importing data ```bash gogs import locale --source --target ``` The `import` command helps you bring portable data from other Gogs installations into your local instance. Currently the only subcommand is `locale`, which merges locale files from a source directory into a target directory. ## Backup and restore ```bash gogs backup gogs restore --from ``` `backup` dumps the database, repositories, and related files into a single zip archive. `restore` imports everything back from an archive, which is useful for migrating Gogs to another server or switching database engines. Both commands support `--database-only` and `--exclude-repos` flags to narrow the scope. `backup` additionally supports `--exclude-mirror-repos` and `--target` to control where the archive is saved. ## Internal commands The `serv` and `hook` commands are used internally by the SSH and Git subsystems. You generally do not need to invoke them directly, but they are the reason Gogs can handle SSH authentication and server-side Git hooks without any external tooling.