In case of pure disaster you can lose your X, and mess up your X-Config file. This tells you how to fix that.
In the case of a failing X you get thrown back to the prompt in a text console in runlevel 3, just to check that do:
$ root ( not "su" because you´re not logged in as user yet )
< password >
# init 3

This because the following actions should absolutely not be done in another run level. ( In Ubuntu and Debian please boot up in "safe mode" )
We stay logged in as root and first do:
# Xorg -configure

The screen will go black for a few seconds because it will generate an new xorg.conf file, it will put a “xorg.conf.new” in root's home directory ( /root ). . . . so check this with:
# ls /root

If the file is indeed there we can first check if it works with this command:
# Xorg -config /root/xorg.conf.new

Xorg -version <===> zjisti verzi xorg

You should get a gray ( or blue ) screen with an X-shaped mouse cursor, this means it´s working. If so we get back to the prompt with:
< Ctrl+Alt+Backspace >
Now we back up the old xorg.conf file, just to be sure we can compare later if needed:
# cp /etc/X11/xorg.conf /etc/X11/xorg.conf-BACKUP

Next we move the new xorg.conf file to its place:
# mv /root/xorg.conf.new /etc/X11/xorg.conf

I hope all went smooth up until now, because then we can:
# reboot

I know “startx” is possible too, but I do like a “fresh” start
In Debian and Ubuntu ( as root ) "dpkg-reconfigure xserver-xorg"

#<------------------------------------ WAYLAND | X11 ------------------------------------>#

echo $XDG_SESSION_TYPE <===> zjisti zda mate X11 ci Wayland // how to know which display server is being used

## If you are using Wayland, you should get ‘wayland’ in the output: Wayland
## If you use xorg (X display server), you should get x11 in the output: x11

env | grep -E -i 'x11|xorg|wayland' <===> zjisti zda mate X11 ci Wayland
loginctl show-session $(loginctl | grep "$USER" | awk '{print $1}') -p Type <===> zjisti zda mate X11 ci Wayland

 #<------------------------------------ TYPES OF DISPLAY SERVER ------------------------------------>#

The display server communicates with its clients over the display server protocol. There are three display server protocols available in Linux. X11 and Wayland are two of them. The third is Mir.

  #<------------------------------------ X Window System, Xorg, X11, Explained ------------------------------------>#

X Window System
X Window System, often referred to merely as X, is old. First originating in 1984, it was the default windowing system for most UNIX-like operating systems, including Linux.

X.Org
X.Org server is the free and open-source implementation of the X Window System display server stewarded by the X.Org Foundation. It is an application that interacts with client applications via the X11 protocol to draw things on display and to send input events like mouse movements, clicks, and keystrokes.

Typically, one would start an X server which will wait for client’s applications to connect to it. However, Xorg is based on a client/server model and thus allows clients to run either locally or remotely on a different machine.

If it’s not obvious, it’s implicit in the design of X11 that the application and the display don’t have to be on the same computer. When X was developed, it was widespread that the X server would run on a workstation, and the users would run applications on a remote computer with more processing power.

X11
X11 is a network protocol. It describes how messages are exchanged between a client (application) and the display (server). These messages typically carry primitive drawing commands like “draw a box,” “write these characters at this position,” “the left mouse button has been clicked,” etc.

But X11 is old, and it was still a pile of hacks sitting on top of a protocol not overhauled for over 30 years. Most of the X Server protocol’s features were not used anymore.

All of the work that X11 did was redelegated to the individual applications and the window manager. And yet all of those old features are still there, weighing down on all of these applications, hurting performance and security.

Mir
je počítačový display server pro Linux, vyvíjený společností Canonical Ltd. Jeho účelem je, aby nahradil stávající X Window System pro systém Ubuntu.[2][3][4]

Mir byl ohlášen společností Canonical Ltd. 4. března 2013.[5] Byl vyvíjen jako základ vývoje rozhraní Unity 8, další generace rozhraní Unity.[2] 


Wayland, the Next-generation Display Server
Wayland was begun by Kristian Hogsberg, an X.Org developer, as a personal project in 2008. It is a communication protocol that specifies the communication between a display server and its clients.

Wayland is developed as a free and open-source community-driven project to replace the X Window System (also known as X11 or Xorg ) with a modern, secure, and more straightforward windowing system.

In Wayland, the compositor is the display server. The compositor is a window manager that provides applications with an off-screen buffer for each window. The window manager composites the window buffers into an image representing the screen and writes the result into the display memory.

The Wayland protocol lets the compositor send the input events directly to the clients and enables the client to send the damage event directly to the compositor.

As in the X case, when the client receives the event, it updates the user interface (UI). But in the Wayland rendering happens in the client, so the client sends a request to the compositor to indicate the region that was updated.

Wayland’s main advantage over X is that it starts from scratch. One of the main reasons for X’s complexity is that, over the years, its role has changed. As a result, today, X11 acts largely as “a really terrible” communications protocol between the client and the window manager.

Wayland is also superior when it comes to security. With X11, it’s possible to do something known as “keylogging” by allowing any program to exist in the background and read what’s happening with other windows open in the X11 area.

This simply won’t happen with Wayland, as each program works independently.

Conclusion
However, the X Window System still has many advantages over Wayland. Even though Wayland eliminates most of the design flaws of the Xorg, it has its issues. Even though the Wayland project has been up for more than ten years, things are not 100% stable.

As of 2022, most video games and graphics-intensive applications for Linux are still written for X11. Also, many closed-source graphics drivers, such as those for NVIDIA GPUs, do not yet offer complete support for Wayland.

X cannot last and Wayland, in many ways, is an improvement. But for now, the vast majority of native applications were written for Xorg. Until those apps are all ported, Xorg needs to be maintained. Wayland is not very stable yet, compared to Xorg.