sudo apt-get install -y linux-headers-$(uname -r)

Category: VPS Management

sudo apt-get install -y linux-headers-$(uname -r)

Install kernel headers for the running kernel

The $(uname -r) command substitution resolves to your exact kernel version, and linux-headers-<version> provides the build-time interfaces needed to compile DKMS drivers such as wireguard or GPU modules. Headers must match the running kernel exactly, which is why the substitution is used. Re-run after every kernel upgrade that needs modules rebuilt.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.