CLI Installation and Login
GEO Wiki Pro CLI installation guide, supporting npm global installation and Token login
# CLI Installation and Login
GEO Wiki Pro provides a command-line tool `geo` for managing knowledge base documents, categories, tags, users, and more. This document covers installation and login methods.
## Installation
### Requirements
- Node.js >= 18
- npm >= 9
### Global Installation
```bash
npm install -g geowiki-cli
```
Verify installation after completion:
```bash
geo --version
geo --help
```
### Permission Issues
If you encounter permission errors, use one of these solutions:
```bash
# Method 1: Use sudo
sudo npm install -g geowiki-cli
# Method 2: Change npm global directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
npm install -g geowiki-cli
```
## Login
CLI supports two login methods: Token login (recommended) and password login.
### Token Login (Recommended)
```bash
geo login --url https://geowiki.pro --token geo_xxxxx
```
| Parameter | Short | Description | Required |
|-----------|-------|-------------|----------|
| `--url` | `-u` | Server address | Yes |
| `--token` | `-t` | API Token | Yes |
::: tip
Token login doesn't require CAPTCHA, making it suitable for CLI and automation scripts. Tokens are valid for 90 days and can be generated in the admin panel under "Settings -> API Token".
:::
### Password Login
```bash
geo login --url https://geowiki.pro --user admin --pass your-password
```
| Parameter | Short | Description | Required |
|-----------|-------|-------------|----------|
| `--url` | `-u` | Server address | Yes |
| `--user` | `-U` | Username | Yes |
| `--pass` | `-p` | Password | Yes |
::: warning
Password login requires CAPTCHA verification, suitable for browser scenarios. Token login is recommended.
:::
## Login Status
View current connection status:
```bash
geo status
```
After successful login, the Token is automatically saved to the local configuration file (`~/.geowiki/config.json`), and subsequent commands will automatically include authentication information.
Clear local credentials and logout:
```bash
geo logout
```
## Common Issues
::: faq
**Q: Can't find `geo` command after installation?**
Ensure npm global bin directory is in your system PATH. Run `npm config get prefix` to view the global directory path.
**Q: What to do if Token expires?**
Generate a new Token in the admin panel under "Settings -> API Token", then run `geo login --url ... --token <new-token>` to re-login.
**Q: How to confirm current logged-in user?**
Run `geo status` to view current server connection and user information.
:::
## Next Steps
After installation and login, please refer to:
- [CLI Quick Reference](/docs/cli-quick-reference) — Quickly master common commands
- [CLI Command Reference](/docs/cli-reference) — Complete command parameter details