New Member
Jan 27, 2024
Reaction score
This is thorough, current (as of 01/26/2024), and hopefully newb-friendly. If a newb follows my guide step-by-step, they will succeed in getting their NVIDIA working (and working well) on Debian 12, but also learn many valuable things about Linux while doing it. There is a lot of information condensed here that I've acquired over the last couple years and many, many installs. But if someone spots any errors or sees a place for improvement, let me know. I realize this is longer than a normal forum post, but every word of additional context is necessary for someone installing Debian for the first time and should get their NVIDIA working right ASAP after that install. If you're not a newb, just look at the bullet points, and skip the notes.

# note - Generally, blacklisting nouveau is a critical step in compiling/installing an nvidia driver. But as of 01/26/2024 the usual ways of doing it do not work in Debian 12 and aren't needed. This was done on a fresh install of Debian 12 w/ Gnome desktop and basic utilities, after first boot up.

# note - If you're a newb who just booted into a Gnome desktop for the first time wondering where the heck your taskbar and apps are, click the Super (Windows) key on your keyboard. Clicking the square of 9 dots on the right will show your apps. I recommend you right click text editor, settings, and terminal and select "pin to dash". Don't worry, you can get a taskbar and put apps on your desktop if you want later, for now let's get that nvidia driver compiled and installed.

  • Click the app named "Software & Updates". in the "Other Software" tab deselect "cdrom:[Debian *****]"
  • Open Terminal and enter <sudo apt update && sudo apt full-upgrade>
# note - In my test, the system was up to date already. If it wants to upgrade packages you generally type "y" for yes, but read what the screen says to you. copy and paste notes into your text editor, particularly if there are any recommended/suggested packages. Save these text files somewhere. Maybe within your Documents folder make a folder called "AptNotes" and keep them there. You'll be glad you did later. For example, if an app doesn't have a function you expect it to or doesn't work correctly, you can probably go back to the note you left yourself when you installed it and there may be a suggested/recommended package which address the problem.

  • In terminal <sudo nano /etc/apt/sources.list> (nano is a simple text editor, you have to use arrow keys on the keyboard to move your cursor around. But we like it because we can open, edit, create, and save files as sudo that we can't with our GUI text editor. If we're already working in terminal, this is convenient)

# note - What you see in /etc/apt/sources.list is the repositories apt looks through to know what packages you can get for Debian bookworm, and to check if the packages you have are up to date. You may notice that the first line has something familiar "cdrom:[Debian GNU/Linux *****" which we saw earlier in Sofware & Updates. What we did with Software & Updates was place that # in front of that line, which tells apt not to read it or try to include it. Deselecting it in the GUI is the same as adding a # in front of it in /etc/apt/sources.list. Now we are going to edit /etc/apt/sources.list with nano from terminal instead. Toward the end of the lines which begin with deb we are going to change "main non-free-firmware" to "main contrib non-free non-free-firmware". When we run <sudo apt update> the next time it will search additional sections of the repository for some packages we're going to need. We are also going to place a # in front of the lines which begin with deb-src. We don't need anything from those parts of the repository. Mine looked like this when I was done.

# deb cdrom:[Debian GNU/Linux 12.2.0 Bookworm - Official amd64 DVD Binary-1 with firmware 20231007-10:29]/ bookworm main non-free-firmware

deb bookworm main contrib non-free non-free-firmware
# deb-src bookworm main non-free-firmware

deb bookworm-security main contrib non-free non-free-firmware
# deb-src bookworm-security main non-free-firmware

# bookworm-updates, to get updates before a point release is made;
# see
deb bookworm-updates main contrib non-free non-free-firmware
# deb-src bookworm-updates main non-free-firmware

# note - Yours probably says something different where mine says "", don't worry about that for now. It's that we have added "contrib non-free" at the end of the lines which begin with deb, that we added a # in front of the lines which begin with deb-src, and that we also have a # in front of the "deb cdrom:[Debian ******" line that's important.

# note - To recap, in the repositories there are three folders apt will search for us. "bookworm" "bookworm-security" and "bookworm-updates". Those three folders have four folders inside them all with the same names, "main" "contrib" "non-free" "non-free-firmware". A total of 12 folders, where it was only searching 6 before. Look it over carefully, and when you're confident it's right with no spelling errors, then...

  • ctl+s to save, and ctl+x to return to command line.
  • In terminal <sudo apt update && sudo apt upgrade> (if you happen to get error messages here, it is likely you mispelled something in /etc/apt/sources.list backtrack and try again.)
  • In terminal <sudo apt install nvidia-detect> (a program from the non-free directory we added which is going to help us)
  • In terminal <nvidia-detect> (you will get a result showing your nvidia card and telling you what options you have, probably recommended "nvidia-driver". If so, good.

# Now we are going to install 452mb of packages which will help the nvidia installer compile your driver and be useful to you for using your nvidia.

  • In terminal <sudo apt install menu g++-multilib g++-12-multilib autoconf automake libtool flex bison gdb gcc-12-multilib gcc-12-locales nvidia-cuda-mps bzr vulkan-tools build-essential firmware-nvidia-gsp>

# note - (Your normal approach when installing packages with apt should be to carefully look through the suggested/recommended packages, look them up on and determine which ones you may need or want. Resist the urge to download them willy-nilly. In this case I have some experience installing NVIDIA drivers and have culled them down for you. You should consider all the -doc packages, these give you manuals of information about using the software. The documentation should be your first place to go to with questions, searching on the internet should be last. (although you can also look up the man's online with your browser)

# note - The next step will compile your new nvidia driver. It would not be a bad idea to reboot your computer before doing it. (Although, I must confess that in my test I didn't).

  • In terminal <sudo apt install nvidia-kernel-dkms> press yes when it tells you about conflicting nouveau and rebooting. This is actually going to install nvidia-driver too btw. There's reasons why I like using the nvidia-kernel-dkms package to trigger it. But to confirm the driver is installed, you can do <sudo apt install nvidia-driver> and you'll probably get a message that you already have an nvidia driver installed, which is what you want.
  • reboot your computer again, now you should have NVIDIA X-Server settings in your apps when you press Super (Windows) button on your keyboard and click the 9-dot square. Your driver is compiled and installed.
**EDIT - If you do not see X-Server Settings, or it doesn't show a driver installed, or you saw errors after you ran install nvidia-kernel-dkms, see the post below this one.

There is one last step. You must use NVIDIA X-Server settings to write a new /etc/X11/xorg.conf file. This is a very important file, you will not get best use performance of your x-server and nvidia without it, and it's a bit of a struggle to get the first one written. You can chill and come back and do it later if you want. Your NVIDIA is installed and working, it just can't store it's configuration or any changes we make. I want to repeat that it's very important for optimal performance of your desktop to get that xorg.conf written.

  • In terminal <cd /etc>
  • In terminal <ls -l> you'll see the folders and files in /etc and something in front of X11 like drwxr-xr-x root root. This tells us root owns it and we gotta be sudo to write to it.
  • In terminal <sudo chown deb:deb X11> My username is deb, you put whatever your username is, the letters in front of @<nameofyourmachine> in the terminal. Mine says deb@BRUTUS;~$ so I put deb:deb.
  • In terminal <sudo chmod g+w X11>
  • In terminal <ls -l> Now we should see drwxrwxr-x deb:deb in front of X11. That's what we wanted to do, trust me. If you're confused, don't worry. You can study up on chown and chmod later.
  • In terminal <cd X11>
  • In terminal <ls -l> Have you noticed that ls -l is how we look around in whatever directory we're in? We see what's there, what the permissions are, size of files, how many files in a folder, and so forth.
  • If there is no xorg.conf you should be good and ready to write one. Don't worry about xorg.conf.d, that's of no concern to us. If there is an xorg.conf, we need to change ownership to "deb" in my case and whatever your username is in your case, also we'll make sure the deb group can write to it. But it won't start with d because it's not a directory, and there won't be any x's because it's not executable. So, if there is one it may say something like -rw-r--r-- root root.
  • In terminal <sudo chown deb:deb xorg.conf>
  • In terminal <sudo chmod g+w xorg.conf> now let's have a look again.
  • In terminal <ls -l> Now we should see -rw-rw-r-- deb deb in front of xorg.conf it is ready for the NVIDIA X-server settings to write to, and NVIDIA X-server settings can also write a backup file in the folder because we changed the permissions on the folder too.

So you can tweak around in the NVIDIA X-server settings as much or as little as you like and then click Save to X Configuration File (merge with existing file) and it will work for you. You also just got a crash course in sources.list, cd, ls -l, nano text editor, chown + chmod, apt package manager........... some very important things to know in Linux. good job!
Last edited:

As of 02-11-2024 there is a bug with the 6.1.0-18 kernel. If you try to install the nvidia driver on that kernel and get errors, I suggest the following. Reboot your computer, and use the Advanced Options in the grub menu (below the usual Debian option you use), selecting 6.1.0-15 (or whatever backup kernel you have) instead.

!!You must be booted in on 6.1.0-15 (or whatever backup kernel you have) and not 6.1.0-18!!

In terminal <sudo nano /etc/apt/sources.list> (this time add the following line below your other entries)
deb bookworm-backports main contrib non-free-firmware non-free

then ctl-s to save and ctl-x to return to terminal
#note You can replace "" with your own mirror, but that one will work too.

In terminal <sudo apt update>
In terminal <sudo apt install -t bookworm-backports linux-image-amd64>
In terminal <sudo apt install -t bookworm-backports linux-headers-amd64>
In terminal <sudo apt purge linux-image-6.1.0-18-amd64>

Now reboot, and this time choose 6.5.0-0, if things went well, the nvidia driver will already be installed and you will find nvidia x-server with the rest of your apps, open it to confirm. If not, then try <sudo apt install nvidia-kernel-dkms> again.

You can read more about the bug here -->

fyi- bookworm-backports is another section of the repository that contains newer packages somewhat tested, but not as extensively as those in the stable bookworm section. Adding it to /etc/apt/sources.list won't add packages unless you flag it like we did above with "-t bookworm-backports" in front of the package we wanted from it.
Nvidia driver installs fine (on MSI Alpha 17 C7V) with kernel 6.1.0-21. Thank you very much for this tutorial!