System "freezes" are often caused by running too many, too large programs and running out of available memory. Use free to see if you have swap space, read man mkswap swapon fstab fallocate to create some. Swap space must be contiguous. use mkswap or fallocate, not dd. Traditionally, swap space of 1.5 × RAM has been recommended, but YMMV. If you don't plan to hibernate your system, you can have less than 1.0 × RAM.
You can use sudo journalctl -b 0 and sudo journalctl --since="-10 minutes" (for various values of "10") to look at logs. Read man journalctl, look in my AskUbuntu profile (click my user name) for more journalctl help.
I'm thinking it has something to do with display. As so far it only happens when plugged into my second monitor.
– txtechnician Nov 15 '23 at 18:22