There are useful commands you can use in Terminal to verify and repair the startup volume. fsck is a common UNIX command that's used for system checks and repairs. It is the equivalent of First Aid in the Disk Utility tool. For APFS volumes, you could also use the fsck_apfs command.
To use this command, you need to restart your computer in single-user mode so that the system disk is unmounted. You can review how to enter single-user mode by rereading Chapter 3, The Startup Process.
Through the use of flags, you can perform extra actions. For example, the -f flag forces journaled filesystems to be verified, such as HFS, while the -y flag answers with "Yes" to any prompts fsck might encounter, so use it with caution. In the case of APFS volumes, you can use the -n flag to verify without performing any repairs.
For example, once you are in single-user mode or you are sure your system disk is unmounted, you could run the following command...