Solution 1:

You should enter the terminal without first dollar sign.
First dollar sign ($) tells to you, this is a terminal command.
First dollar sign ( $ ) means you are a normal user.

sudo apt update && sudo apt install -y linux-headers-$(uname -r) linux-modules-$(uname -r)