Back to commands

Hosting Operations

Read-only

Check SQLite Database Integrity

You need a read-only integrity check for a SQLite database.

Command

sqlite3 app.db "PRAGMA integrity_check;"

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not treat a passing result as a full application diagnosis; it only checks database structure.

Expected output

The word ok when the database passes the integrity check.

System impact

Read-only. Nothing changes. SQLite runs an integrity check and reports the result.

Recovery / rollback: no state is changed.

When to use it

Use after crashes, disk issues, interrupted copies, or unexplained database errors.

When not to use it

Do not treat a passing result as a full application diagnosis; it only checks database structure.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ ls -lh app.db

-rw-r--r-- 1 root root 16 Jun 26 00:27 app.db

$ sqlite3 app.db "PRAGMA integrity_check;"

ok
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. ls -lh app.db
  2. sqlite3 app.db "PRAGMA integrity_check;"

next steps

Related commands

Hosting Operations Read-only

Show Indexes on a SQLite Table

Slow lookups often start with missing or misunderstood indexes.

sqlite3 app.db "PRAGMA index_list('orders');"
Hosting Operations State change

Back Up a SQLite Database File

Copying a live SQLite file blindly can produce a bad backup.

sqlite3 app.db ".backup backup/app.db"
Hosting Operations Read-only

Count SQLite Events by Type

A noisy event type stands out faster when you group it.

sqlite3 app.db "SELECT event_type, count(*) FROM events GROUP BY event_type ORDER BY count(*) DESC;"
Hosting Operations Read-only

Show Recent SQLite Events

For small apps, the quickest timeline may be inside the SQLite file.

sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"
Hosting Operations Read-only

Count Rows in Key SQLite Tables

A quick row count can reveal empty imports, runaway events, or missing data.

sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lfcs:operations-deployment
  • lfcs:services-logs
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.