When setting up a Rasbian Linux OS lite install I might just want to set up a server, or do something from the command line only. However often I might want at least some kind of desktop environment if I am still going to have th raspberry pi hooked up to a monitor and not go fully headless. So In this post I will be going over installing the x window system, and setting up a very simple desktop for X called blackbox in Rasbian lite.
the first step is to start with a clean Raspbian lite image to run on the raspberry pi. I will not be getting into that here because I wrote a post on getting started with Raspbian lite before hand. If you have a desktop image there is no need to read this post because you have xorg installed all ready. However at that point you might be interested in installing another desktop environment, in that case it might make sense to read this post because I will be getting into setting up blackbox desktop. So then it would only make sense to continue reading if you want to just for the heck of it, or to catch something else in this post that might be of interest to a problem of some kind.
The first package I would start with is xserver-xorg, This will just install the xserver itself, and not a whole bunch of other stuff that I might not use which would be the case if I where to install the xorg package.
I will want to install the xinit package so that I can start the xserver. This package will give me commands like startx, and xinit.
Now to install a desktop environment, in this post I will be going over blackbox, but if you want to use a different desktop the setup, and additional packages to install might be different.
Once blackbox is installed I can then start it by just calling startx.
If I want to rRaspbian to boot right into a display manager, and then from there start blackbox. Or If I want to install more than one desktop environment, I will want to install a display manager. One solution for this world be lightDm. There are other options when it comes to display managers, and there is of course just using startx and xinit to start and desktop from the command line once I am logged in. So this like many things when starting with a Raspbian lite install is totally optional.
So starting with a lite distribution of Raspbian is often good starting point for certain use cases of a raspberry PI. If I want to set up a raspberry PI to just act as a sever of something on a network then it makes sense to just have a command line interface to work with, just install the application that I want it to run, and not bother installing a desktop environment at all. However in some situations I might want to install xorg, and a custom desktop environment.