LM Studio is best known for its desktop app, but it also ships a command-line tool called lms, and the terminal is often the faster way to manage models: list what is on disk, see what is in memory, load one with a timeout, and unload it when you are done — all without opening the window. This is the routine to use when you finish for the day and want the memory back, or when a script needs the model ready before it starts.
See what you have, and what is loaded
lms ships with LM Studio: install the app, open it at least once, then run lms --help in a new terminal. If the command is not found, run npx lmstudio install-cli and open a fresh terminal. Then check the two lists that answer different questions:
lms ls
lms ps
lms ls lists downloaded models, with size, architecture, and parameter count; lms ps lists the models currently loaded in memory. Both accept --json for machine-readable output, which is handy in scripts. Pick the model key from lms ls — it is the first item on the model’s line.
Load with a timeout, then unload
Load a model with an idle time-to-live, after which LM Studio unloads it for you and frees the memory:
lms load qwen3-8b --gpu max --context-length 8192 --ttl 3600
The --ttl 3600 flag unloads the model automatically after 3600 seconds — one hour — of inactivity. LM Studio’s own docs confirm the same flag: lms load --ttl <seconds>. Before loading a large model, estimate first: --estimate-only shows how much memory the load would use, without loading. To take a model out of memory yourself, unload it:
lms unload qwen3-8b
lms unload --all
| Check | What you should see | If you do not see it |
|---|---|---|
| Downloaded | lms ls shows qwen3-8b with its size and architecture |
The model is not downloaded — get it with lms get first |
| Loaded | lms ps lists qwen3-8b after the load command |
Read the load output — the model may not fit in memory |
| Unloaded | lms ps no longer lists it after lms unload |
Use lms unload --all to unload every loaded model |
Expected result. We checked LM Studio’s own docs for the TTL flag and a third-party CLI guide for the list, load, and unload commands. We did not run lms.
Limits
Only the --ttl flag above comes from LM Studio’s own docs; the lms ls, lms ps, --estimate-only, and lms unload --all details come from a third-party CLI guide, so confirm them with lms --help on your installed version. A model loaded through lms load uses the per-model defaults set in the app, so a default you set in My Models can change what the command loads. The model key in the examples, qwen3-8b, is the guide’s example — replace it with a key from your own lms ls output. We did not run lms, so no listing here is a recorded result.
