Black screen after sudo systemctl stop gdm

Whenever you stop your display manager, you need to do so through a TTY console so that you don't lose your session. You will need to go to a TTY screen and log in with your username and password so you can run commands.

Press CTRL+ALT+F4 to open a TTY screen (TTY4).

Then, sign in with your username and password.

Now, you can run the commands listed in the help article.

sudo systemctl stop display-manager
sudo /etc/NX/nxserver --restart

I'm not sure which screen this will start the GUI. The GUI usually runs on TTY1 or TTY2 but sometimes runs on TTY7.

Use CTRL+ALT+F1 to get to TTY1, CTRL+ALT+F2 to get to TTY2, or CTRL+ALT+F7 to get to TTY7. Try all three of these to see if you can find a working session.

Alternatively, to get back to a normal GUI desktop, you can always startup your display manager using the following command:

sudo systemctl restart display-manager

and your default Ubuntu desktop or login screen should be on TTY1 or TTY2 or possibly TTY7.