LinuxCommandLibrary

hf

official command-line interface for Hugging Face Hub

TLDR

Log in to Hugging Face Hub

$ hf auth login
copy
Download a model from the Hub
$ hf download [gpt2]
copy
Download specific files from a model
$ hf download [meta-llama/Llama-2-7b] [config.json] [model.safetensors]
copy
Upload a folder to the Hub
$ hf upload [username/my-model] [./models] [.]
copy
List trending models
$ hf models ls
copy
Run a job on GPU infrastructure
$ hf jobs run --flavor [a10g-small] [pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel] [python train.py]
copy
View cache usage
$ hf cache ls
copy

SYNOPSIS

hf command [subcommand] [options]

DESCRIPTION

hf (formerly huggingface-cli) is the official command-line interface for Hugging Face Hub. It provides direct terminal access to download models and datasets, upload files, manage repositories, run compute jobs, and interact with the ML community platform.
The CLI follows a consistent hf resource action pattern. Files are cached locally in ~/.cache/huggingface/hub/ with smart deduplication. The download command supports partial downloads with --include/--exclude patterns and resumable transfers.
hf jobs enables running code on Hugging Face infrastructure including GPUs (T4, A10G, A100) and TPUs, with Docker-like commands. Jobs support environment variables, secrets, scheduled execution, and UV scripts for self-contained Python tasks.
Authentication is managed via hf auth login which stores tokens locally. Tokens can also be set via the HF_TOKEN environment variable for scripting.

PARAMETERS

--repo-type type

Repository type: model, dataset, or space.
--revision ref
Specific revision (branch, tag, or commit hash).
--local-dir path
Download to specific local directory instead of cache.
--include pattern
Include files matching glob pattern.
--exclude pattern
Exclude files matching glob pattern.
--token token
Authentication token for private repos.
--quiet
Suppress verbose output, print only final result.
--flavor hardware
Hardware for jobs: cpu-basic, t4-small, a10g-small, a100-large, etc.
--timeout duration
Job timeout with units: 30m, 2h, 1d.
--help
Display help for any command.

COMMANDS

auth login

Log in to Hugging Face Hub with access token.
auth logout
Log out and remove stored tokens.
auth whoami
Display current user and organizations.
download repoid [files_]
Download files from the Hub to local cache.
upload repoid localpath pathinrepo
Upload files or folders to a repository.
repo create repoid_
Create a new repository on the Hub.
repo delete repoid_
Delete a repository.
cache ls
List cached repositories and their sizes.
cache rm repoid_
Remove cached files.
jobs run image command
Run compute jobs on Hugging Face infrastructure.
models ls
List and search models on the Hub.
datasets ls
List and search datasets.
spaces ls
List and search Spaces.
env
Print environment information for debugging.

CAVEATS

Some features require a Hugging Face Pro subscription or organization membership, including hf jobs for compute access. Large model downloads may require significant disk space and bandwidth. Private repositories require authentication.

HISTORY

The Hugging Face Hub CLI was introduced as part of the huggingface_hub Python package to provide programmatic access to the model repository. In July 2025, the CLI was renamed from huggingface-cli to hf for brevity, with commands reorganized into a clearer resource action structure. The legacy command remains functional with deprecation warnings.

SEE ALSO

ollama(1), git-lfs(1), docker(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community