Ubuntu 16.04 LTS安装nvidia-396驱动后出现登录循环问题求助
Hey there, sorry to hear you're stuck in that frustrating login loop after installing the nvidia-396 driver—been there, done that, and it’s a real headache. Let’s walk through the most likely fixes, step by step.
第一步:先切换到TTY终端
When you hit the login loop, don’t panic. Press Ctrl+Alt+F3 (or any F key from F2 to F6) to switch to a text-only terminal. Log in with your username and password—this is where we’ll do all the troubleshooting.
方案1:修复用户权限问题
Sometimes the loop happens because your user doesn’t have proper permissions for Xorg-related files. Let’s check and fix that:
- First, list the ownership of critical files:
ls -l ~/.Xauthority ~/.ICEauthority - If either file shows
rootas the owner instead of your username, run this to fix permissions:sudo chown $USER:$USER ~/.Xauthority ~/.ICEauthority - Now restart the display manager to test:
sudo systemctl restart lightdm
If this works, you should be able to switch back to the graphical login (Ctrl+Alt+F1) and log in normally.
方案2:彻底清理并重新安装驱动
If permissions aren’t the issue, the problem is likely a corrupted driver installation or conflicting Xorg configs. Let’s start fresh:
- Purge all existing NVIDIA components (you did this already, but we’ll make sure nothing’s left):
sudo apt purge nvidia-* nvidia* libnvidia*sudo apt autoremove && sudo apt autoclean - Remove old Xorg config files that might be causing conflicts:
sudo rm /etc/X11/xorg.conf(ignore the error if the file doesn’t exist) - Reinstall the nvidia-396 driver using the official repositories:
sudo apt updatesudo apt install nvidia-396 nvidia-settings - Generate a fresh Xorg config tailored to your GPU:
sudo nvidia-xconfig - Reboot your system to apply changes:
sudo systemctl reboot
方案3:检查Secure Boot设置
Modern systems with Secure Boot enabled can block unsigned NVIDIA drivers from loading, which breaks the graphical session. Here’s how to fix it:
- Reboot your computer and enter BIOS/UEFI settings (usually by pressing Del, F2, or F10 during boot).
- Look for the "Secure Boot" option and disable it.
- Save changes and boot back into your system, then repeat the driver reinstall steps above.
方案4:匹配内核版本
NVIDIA 396 is an older driver, so it might not support newer Linux kernels. Let’s check if your kernel is too new:
- First, check your current kernel version:
uname -r - If your kernel is 5.4 or newer, nvidia-396 might not be compatible. You’ll need to install an older kernel that’s supported:
- Install a compatible kernel (e.g., 4.15.x, which works well with 396):
sudo apt install linux-image-4.15.0-197-generic linux-headers-4.15.0-197-generic - Reboot your system, and when the GRUB menu appears, select "Advanced options for Ubuntu" > choose the 4.15 kernel.
- Once logged in, reinstall the nvidia-396 driver as outlined in方案2.
- Install a compatible kernel (e.g., 4.15.x, which works well with 396):
If none of these work, feel free to share more details like your GPU model, Ubuntu version, and any error messages you see in /var/log/Xorg.0.log—that’ll help narrow things down further.
内容的提问来源于stack exchange,提问作者devansdev

