Hero4Hire
System ScriptsDebian 13 x86_64

Install NVIDIA driver

What it does

Installs Debian 13 (Trixie)'s proprietary NVIDIA driver and its DKMS kernel module on one x86_64 host. It verifies that it is running as root on Debian 13, adds contrib, non-free, and non-free-firmware to supported Debian APT source files, refreshes APT metadata, installs headers for the running kernel, and installs nvidia-kernel-dkms and nvidia-driver.

The script supports /etc/apt/sources.list.d/debian.sources (deb822 format) and /etc/apt/sources.list (one-line format), including the Debian netinst layout. It modifies each supported file containing active Trixie sources and saves a same-directory .nvidia-driver.bak copy first. It does not configure CUDA, containers, X11 or Wayland, GPU passthrough, or Secure Boot key enrollment. Run it during a maintenance window: package installation can replace the kernel, and a reboot is required before the NVIDIA module can be loaded. On a Secure Boot-enabled system, complete the MOK enrollment prompted by DKMS before rebooting or the unsigned module will not load.

This uses the proprietary kernel-module flavor for broad support across the GPUs supported by Debian's packaged driver. It stops if neither supported source file contains Trixie entries. Custom filenames under /etc/apt/sources.list.d/ require manual configuration.

After its first successful run, the script records version 1.1.0 in /var/lib/hero4hire/system-scripts/debian-13-x86_64-install-nvidia-driver.version. Later runs stop before changing the host, including when a newer downloaded script has a different version. Remove that marker only after reviewing the installed driver, source configuration, and script changes; it is not a routine retry mechanism.

System: Debian 13 x86_64

Download command
sudo bash -c "$(curl -fsSL 'https://hero4hire.com/scripts/debian-13-x86_64/install-nvidia-driver.sh')"
Show script
Script
Loading script…

Run the download command as your normal user with curl and sudo installed. It downloads the script using command substitution and passes it to sudo bash -c, keeping your terminal available for prompts. Check for curl errors: this compact command does not propagate download failures to Bash. If you are already root, replace sudo bash with bash.

Do not prefix bash <(curl ...) with sudo: Bash's process substitution uses a file descriptor that sudo normally closes, causing errors such as bash: /dev/fd/63: No such file or directory before the installer starts.

How it works

The driver is distributed by Debian as the nvidia-driver metapackage in the non-free component. Its DKMS kernel-module package builds a module for the installed kernel, so the script first installs the headers matching uname -r. It does not use NVIDIA's standalone installer, which is outside Debian's package management and can complicate kernel upgrades.

Debian's NVIDIA guidance requires contrib, non-free, and non-free-firmware for Trixie sources. The script makes an archive-preserving backup beside each supported source file and adds each required component only when missing. For one-line sources, it updates active deb and deb-src entries for trixie, trixie-security, and trixie-updates, preserving comments, repository URLs, and options. Commented CD-ROM entries and other suites remain unchanged. It then uses apt-get to refresh available packages and install the driver stack. The .bak extension keeps the backup from being read as an APT source.

DKMS may prompt for a Machine Owner Key (MOK) password when Secure Boot is enabled. This is expected; enroll that key in the firmware screen on the next boot. Reboot after a successful installation, then use nvidia-smi to confirm that the loaded module and userspace tools can communicate with the GPU. Debian's packaged Trixie driver does not support every NVIDIA GPU generation; review the NVIDIA Graphics Drivers guidance before using it with older hardware or an RTX 50-series (Blackwell) GPU.

The completion marker is written only after the package installation succeeds. It stores the script version for auditability, but it intentionally blocks both matching and newer versions so a revised script cannot silently repeat host-level driver changes. A failed run creates no marker and can be corrected and retried.

Commands Used

CommandArgumentDescription
id-uVerifies that the effective user is root.
uname-mConfirms the machine is x86_64.
-rSupplies the running kernel release used to select matching headers.
grep-EChecks that supported source files target a Trixie suite and that required APT components are present.
-qPerforms those checks without printing matching text.
cp--archivePreserves a metadata-aware backup of the APT source file before it is changed.
catReads a prior completion-marker version when preventing a repeat run.
install-d -m 0755Creates the root-owned Hero4Hire marker directory after a successful installation.
-m 0644 /dev/stdinWrites the completed script version marker.
awk-v source_patternAdds missing components to active one-line Trixie entries while preserving comments.
mktempCreates a temporary file for the updated one-line sources.
trapEXITRemoves the temporary file if the update fails.
rm-fRemoves the temporary file after the source update.
sed-iAdds missing repository components directly to Components: fields.
apt-getupdateRefreshes local package metadata after the source components change.
install --yesInstalls noninteractively after APT resolves the driver, DKMS, and header dependencies.
linux-headers-$(uname -r)Installs headers for the currently running kernel so DKMS can build its NVIDIA module.
nvidia-kernel-dkmsInstalls Debian's DKMS package for the proprietary NVIDIA kernel module.
nvidia-driverInstalls Debian's NVIDIA driver metapackage and associated userspace components.
nvidia-smiRecommended after reboot to verify that the driver is loaded and can communicate with the GPU. It is not run by the script.

References

Bash's process substitution documentation explains the generated file descriptor path. The sudo manual documents its default behavior of closing file descriptors other than standard input, output, and error.

Debian's NVIDIA Graphics Drivers guide documents the required Trixie APT components, the nvidia-kernel-dkms and nvidia-driver packages, GPU support limitations, and Secure Boot considerations. The Debian package index describes the Trixie nvidia-driver metapackage and its availability in non-free. Debian's Debian 13 release notes cover release-specific operational considerations.

Debian's sources.list manual describes one-line and deb822 source formats, repository options, and components.

On this page