Ubuntu – Ubuntu 16.04 LTS – how is the X server started

16.04xorgxserver

I have thought that /usr/bin/startx script is used to start the X server but it looks like it is not true. Which process or script starts the X server? The X server has to be started before lightdm greeter is visible but when exactly?

Best Answer

/etc/init.d/lightdm starts the Xserver. Lightdm gets started first then it starts the Xserver. The parent process of the Xserver (Xorg) is lightdm (PID 25600 as shown in example below). You can see this by executing:

ps -ef | grep lightdm.

root     25600     1  0 00:50 ?        00:00:00 /usr/sbin/lightdm  
root     25608 25600  2 00:50 tty7     00:00:35 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch  
root     25686 25600  0 00:50 ?        00:00:00 lightdm --session-child 12 19

Running the following commands will stop and start lightdm and Xserver accordingly:

sudo /etc/init.d/lightdm stop  
sudo /etc/init.d/lightdm start
Related Question