How to stop and restart an X server on Ubuntu

Make sure you are logged out first

  1. Hit Ctrl+Alt+F1 and login using your credentials.
  2. kill your current X server session by typing sudo service lightdm stop or sudo lightdm stop
  3. Enter runlevel 3 by typing sudo init 3
  4. Do whatever you need to do in the terminal
  5. You might be required to reboot when the installation finishes. If not, run sudo service lightdm start or sudo start lightdm to start your X server again.