The Sudden Black Screen
Under the hood, Ubuntu Linux runs multiple virtual consoles (TTYs). TTY1 usually runs your graphical desktop environment (GNOME), while TTY2 through TTY6 are pure, text-based command-line interfaces. Normally, you switch between them intentionally using keyboard shortcuts like Ctrl+Alt+F3. However, due to graphics driver crashes (especially with proprietary NVIDIA drivers) or conflicts with ACPI power events when waking from suspend, Ubuntu might occasionally panic and automatically switch you from your graphical desktop to a black, text-only virtual console, making it appear as though the entire system has crashed and requires a hard reboot.
Preventing the TTY Switch
To maintain your graphical session and stop Ubuntu from automatically switching to a virtual console during a minor display server hiccup, you must disable the kernel keyboard shortcuts that allow the switch.
Open your terminal (Ctrl+Alt+T). You need to edit the X11 keyboard configuration file. Type sudo nano /etc/default/keyboard and press Enter. Look for the line that says XKBOPTIONS="". You need to add a specific flag to disable the virtual console switching keybindings (which the system itself relies on during a crash). Change the line to read: XKBOPTIONS="srvrkeys:none". Press Ctrl+O to save, Enter to confirm, and Ctrl+X to exit. Finally, apply the new keyboard map by typing sudo dpkg-reconfigure keyboard-configuration. If the graphics driver briefly hangs in the future, it will be forced to recover within the graphical environment rather than dumping you to a black text screen.