Linux – the difference between startx and init 5

linux

When I run the command startx it launches me immediately into Gnome without having to login and if I attempt to go back to the command line interface by typing in the comamnd init 3 in the x-terminal it does nothing.

If I attempt to hit CTRL-ALT-Backspace it does nothing however if I were to run init 5 it launches me into the Gnome Display Manager and expects me to login and if I run init 3 in the x-terminal it shutdowns the x-server and returns me to the command line interface.

Best Answer

Theoretically you're doing the right-ish thing. In theory being in runlevel N means that all of the services associated with number N are running, and those that are not are not running.

In practice you can't make that transition without telling the system explicitly to make the transition for you.

You did confuse running startx with what typically happens in runlevel 5 though. When you enter runlevel 5, the system starts a display manager login (gdm, kdm, etc.). This is a simple display manager that will then start X as you once you log in (similar to what you did with startx... the differences are pretty small).

If you started gdm as root from runlevel 3, it is conceivable that some implementation of runlevel transitioning / management would stop gdm if you then indicated that you wanted to be in runlevel 3. I wouldn't count on it working that way in real life. First, the system might ignore you because no-one told it that it was in runlevel 5 even though gdm is running. Second, the system might not deal with the process you started in the same way it would deal with a process that was started automatically.

Related Question