# Grav — CLI for the Grav Flat-File CMS

> Practical guide to the Grav CLI tools: bin/grav for cache, backup and scheduler, and bin/gpm for installing and updating plugins and themes.

Source: https://www.jpkc.com/db/en/cheatsheets/build-languages/grav/

<!-- PROSE:intro -->
Grav is a modern PHP-based flat-file CMS: it needs no database and stores your content as plain Markdown and YAML files right in the filesystem. You manage it through two command-line tools – `bin/grav` for core tasks such as clearing the cache, backups and the scheduler, and `bin/gpm`, the Grav Package Manager, which installs and keeps plugins and themes up to date. This guide walks you through the everyday commands of both tools, from cache maintenance to a core upgrade.
<!-- PROSE:intro:end -->

## bin/grav — General

`bin/grav list` — List all available Grav CLI commands.

```bash
bin/grav list
```

`bin/grav help <command>` — Show help for a specific command.

```bash
bin/grav help clear-cache
```

`bin/grav new-project <path>` — Create a new Grav project in a directory.

```bash
bin/grav new-project ~/sites/my-grav-site
```

`bin/grav sandbox` — Create a symlinked sandbox copy of Grav (for development).

```bash
bin/grav sandbox -s ~/grav-core ~/sites/my-sandbox
```

## bin/grav — Cache & Clean

`bin/grav clear-cache` — Clear the Grav cache.

```bash
bin/grav clear-cache
```

`bin/grav clear-cache --all` — Clear all cache types (standard + images + assets).

```bash
bin/grav clear-cache --all
```

`bin/grav clear-cache --assets-only` — Clear only compiled asset cache (CSS/JS pipeline).

```bash
bin/grav clear-cache --assets-only
```

`bin/grav clear-cache --images-only` — Clear only image cache (generated thumbnails).

```bash
bin/grav clear-cache --images-only
```

`bin/grav clear-cache --tmp-only` — Clear only temporary files.

```bash
bin/grav clear-cache --tmp-only
```

`bin/grav clean` — Remove unnecessary files (vendor cruft, tests, docs).

```bash
bin/grav clean
```

## bin/grav — Backup & Security

`bin/grav backup` — Create a full backup of the Grav site.

```bash
bin/grav backup
```

`bin/grav backup --destination <path>` — Create a backup to a specific directory.

```bash
bin/grav backup --destination ~/backups
```

`bin/grav security` — Run a security scan on the Grav installation.

```bash
bin/grav security
```

`bin/grav logviewer` — View Grav log entries from the command line.

```bash
bin/grav logviewer
```

## bin/grav — Scheduler & Composer

`bin/grav scheduler -i` — Install the Grav scheduler cron job.

```bash
bin/grav scheduler -i
```

`bin/grav scheduler -r` — Remove the Grav scheduler cron job.

```bash
bin/grav scheduler -r
```

`bin/grav scheduler` — Run pending scheduled tasks manually.

```bash
bin/grav scheduler
```

`bin/grav composer` — Run Composer within the Grav context.

```bash
bin/grav composer update
```

`bin/grav yamllinter` — Check all YAML files for syntax errors.

```bash
bin/grav yamllinter
```

## bin/gpm — Package Info

`bin/gpm index` — List all available plugins and themes from the repository.

```bash
bin/gpm index
```

`bin/gpm index --plugins` — List only available plugins.

```bash
bin/gpm index --plugins
```

`bin/gpm index --themes` — List only available themes.

```bash
bin/gpm index --themes
```

`bin/gpm info <package>` — Show detailed info about a plugin or theme.

```bash
bin/gpm info admin
```

`bin/gpm version` — Show Grav and plugin versions.

```bash
bin/gpm version
```

## bin/gpm — Install & Uninstall

`bin/gpm install <package>` — Install a plugin or theme.

```bash
bin/gpm install admin
```

`bin/gpm install <pkg1> <pkg2>` — Install multiple packages at once.

```bash
bin/gpm install admin login sitemap
```

`bin/gpm install --all-yes <package>` — Install without confirmation prompts.

```bash
bin/gpm install --all-yes feed
```

`bin/gpm uninstall <package>` — Uninstall a plugin or theme.

```bash
bin/gpm uninstall simplesearch
```

## bin/gpm — Update

`bin/gpm update` — Check for and install plugin/theme updates.

```bash
bin/gpm update
```

`bin/gpm update <package>` — Update a specific plugin or theme.

```bash
bin/gpm update admin
```

`bin/gpm update --plugins` — Update only plugins.

```bash
bin/gpm update --plugins
```

`bin/gpm update --themes` — Update only themes.

```bash
bin/gpm update --themes
```

`bin/gpm self-upgrade` — Upgrade the Grav core to the latest version.

```bash
bin/gpm self-upgrade
```

`bin/gpm self-upgrade -f` — Force a Grav core upgrade (re-download even if up to date).

```bash
bin/gpm self-upgrade -f
```

<!-- PROSE:outro -->
## Conclusion

With `bin/grav` and `bin/gpm` you manage an entire Grav installation straight from the command line – with no database backend, because Grav keeps all content as files. Before every plugin, theme or core update, grab a full snapshot with `bin/grav backup`, so a failed `bin/gpm update` or `self-upgrade` can always be rolled back. Mind your file permissions, too: the web-server user needs write access to `cache/`, `logs/`, `backup/` and `user/`, but shouldn't own the whole directory. That keeps your site both current and secure.

## Further Reading

- [Grav documentation](https://learn.getgrav.org/) – official manual covering the CLI, plugins and themes
- [getgrav.org](https://getgrav.org/) – project site with downloads and the plugin/theme directory
- [GPM – Grav Package Manager](https://learn.getgrav.org/17/cli-console/grav-cli-gpm) – reference for all `bin/gpm` commands
<!-- PROSE:outro:end -->

## Related Commands

- [artisan](https://www.jpkc.com/db/en/cheatsheets/build-languages/artisan/) – command-line tool of the Laravel PHP framework
- [cargo](https://www.jpkc.com/db/en/cheatsheets/build-languages/cargo/) – package manager and build tool for Rust
- [composer](https://www.jpkc.com/db/en/cheatsheets/build-languages/composer/) – dependency manager for PHP

