March 17, 2011

Enabling Slackware 13.1 to Boot to the X Login Screen by Default

I did some playing around with slackware to get a better understanding of how linux functions behind the curtains. To be honest, there's a little frustrations of not choosing slackware as the first linux distro to use. Better late than never.

Understanding linux, can be tricky when every function, component, device is in the form of a script, file or something of that nature. Meaning, most of the time, you are trying to understand code. Like a friend has told me, "think it is easy until you've proven it to be difficult".

On that note, I wanted slackware, instead of booting to the terminal (which it does by default), to boot to the gui UI.  To accomplish this, you need to change a few things in a script file. What script file?

In linux, scripts called "runlevels" determine how a linux system should act when it boots, either, in multi-user mode, single user mode, terminal(default) or the X11 mode. They are numbered in a format like rcO.d, rc1.d all the way to rc6.d.  If you used other distros like ubuntu, fedora and opensuse, you will notice they all boot to a X11 login screen, which basically mean, it is using a runlevel that tells the system to boot in X11. All we need to do is find that runlevel. The run level to boot any linux distro to X11 is called rc4.d.

In slackware, all runlevels, and initialization scripts are stored in a directory called rc.d located in etc/rc.d. In that directory, you will see the runlevel script that boots slackware into the X11 mode. Now, you don't change the runlevel rc4.d located in rc.d directly. In stead you will have to find a script file named inittab that slackware reads to find the scripts used to initialize itself. Sounds confusing, it did to me.

What you need to do, is open inittab in your favorite text editor as root and change one line in the file. When  you open the file you will see a bullet list of default runlevels with a heading named "These are the default runlevels in slackware". At the very bottom of the list are the runlevels and initiation script slackware will use to boot.

The first line of code under the list is the "default run level, do not set to 0 or 6". The code line is separated with semicolons: "id:3:initdefault". The number 3 represents the runlevel slackware will use. You are going to change that number to 4 and save the file. It is always good to make a backup copy of the file before you do any changes. Or, like I like to do it, do all your testings on a beta machine or in a virtual machine. When you are done, reboot the system. In a few seconds your system will boot to an X11 login screen. Remenber, exploring and breaking means learning.