Command: sqlite3
What it does: This command opens the built-in SQLite database, which stores information about your system, including running processes, network connections, and disk usage.
Example:
Let’s say you want to view a list of all running processes on your MacOS machine, along with their PID, CPU usage, and memory usage. You
can use the sqlite3
command to query the SQLite database:
-
Open Terminal on your MacOS machine.
-
Type in the following command:
sqlite3 /var/db/diagnostics.db
-
Press Enter to run the command. This will open a SQLite prompt.
-
Type in the following command at the SQLite prompt:
.headers on
(followed by Enter) -
Type in the following command at the SQLite prompt:
SELECT * FROM system.processes;
(followed by Enter)
Result: The SQLite database will display a list of all running processes, including their PID, CPU usage, and memory usage.
Note: Be aware that this command requires elevated privileges to access the SQLite database. You may need to use the sudo
command
before opening the SQLite prompt:
- Type in the following command:
sqlite3 /var/db/diagnostics.db
- Press Enter to run the command.
- When prompted for a password, enter your administrator password.
Trick: To view a specific type of process (e.g., only running processes with high CPU usage), you can modify the SQL query by adding additional conditions. For example:
SELECT * FROM system.processes WHERE cpu_usage > 5;
This will display only processes with CPU usage above 5%.
Remember, this command is for advanced users who want to explore their MacOS machine’s internal workings. Be cautious when querying or modifying data in the SQLite database, as incorrect modifications can lead to system instability.