Disclaimer: I am not an investment advisor. When I describe my own trading activities, it is not intended as advice or solicitation of any kind.

15 September 2011

X Windows and KDE

See Time For a Change for the first in this series, or view the index to see all the entries dealing with Arch Linux. In this post, I will go from the command-line to a KDE desktop. We're getting somewhere this time!

An awesome Linux machine isn't very awesome if all you get is a root login and a command-line prompt. There are a number of desktop managers out there for Linux, but the two most popular are Gnome and KDE. For this machine, I chose KDE. There are several command-line examples throughout this post, and by a common convention I will prefix the ones that should be done as root with "#", and the ones that should be done as an unprivileged user with "$".

In Arch, most things are installed with the package management utility: pacman. Other distributions have different but similar utilities: Fedora uses yum, and Debian uses apt. They all do pretty much the same things, and they all have documentation that does its best to convince the reader that each utility is different and somehow better than the others. Whatever. They are just tools to do a job, as far as I'm concerned. Before I get started installing KDE, I need to generally update my system:

# pacman -Syu

Immediately after a new installation, this will probably update pacman itself and then dump back to a command prompt, so it's a good idea to run the command twice.

Next, I need to install X Windows before I install KDE. Linux is laid out in a hierarchical way: there is the underlying kernel, which runs the operating system and does hardware, resource, and process management, but it doesn't have any graphical capabilities. On top of that -- if installed -- is X Windows, which is capable of interfacing with the graphical hardware subsystem and providing a high(er) level framework to applications looking to provide a GUI interface to their users but not wanting to reinvent the wheel, the way DOS games had to back in the day. Finally on top of that is the desktop manager, which puts a pretty face onto X Windows, coordinates a user session, and manages access to the various utilities and menus an average user needs to do his job. Technically, X Windows can be run without a desktop manager like KDE, but no sane person would want to.

As an example of insanity, here's how to launch the X Windows calculator, and what it looks like:

$ X &
$ export DISPLAY=0:0
$ xcalc &

And here is the equivalent in KDE:

Launching KCalc KCalc itself

Bear in mind that if you want to see more than one application at a time in X Windows, you have to specify the size and coordinates of the windows at launch time. Yeah, I'll stick with a desktop manager.

So... onward to X and KDE installation!

# pacman -S xorg

This takes a while. When it's done:

# pacman -S kde

This takes even longer. When that finishes, though, X Windows and KDE are installed. But they need some configuration before they can be used. First of all, I had to add "hal" and "dbus" to the DAEMONS section of /etc/rc.conf - no idea why, just following instructions. In order to get a dvorak layout at the login prompt (very important when you can't see what password you're typing), I also had to add the following highlighted line to the appropriate section of /etc/X11/xorg.conf.d/10-evdev.conf:

Section "InputClass"
     Identifier "evdev keyboard catchall"
     MatchIsKeyboard "on"
     MatchDevicePath "/dev/input/event*"
     Driver "evdev"
Option "XkbLayout" "dvorak"

Next, if I want to use KDE I have to create a non-privileged user, because by default root isn't allowed to log into KDE directly. I also need to set a password, create a home directory to store the new user's configuration and personal files, and make sure this user can elevate his privileges to root in case I need to use it to manage the system from within KDE. So I executed the following commands in sequence:

# useradd mark -d /home/mark
# passwd mark
 (enter a password)
# mkdir /home/mark
# chown mark:mark /home/mark
# groupadd sudo
# usermod -aG sudo mark

Since I had never set up sudo, which lets an authorized user elevate his privileges to super-user, I also had to execute visudo and comment out the line that says that anyone in the "sudo" user group is allowed to use the sudo command. In this way, I have given unlimited power to the mark user, but no one else.

All that is left now is to make the machine boot directly into KDE instead of to a console login. To accomplish this, I edited the /etc/inittab file. First, there is a section near the bottom that has several example lines for starting various desktop managers. Luckily, there is a KDE one: "x:5:respawn:/usr/bin/kdm -nodaemon". All I needed to do was comment out the "xdm" one that leads to the bare X Windows environment, and uncomment the line above dealing with KDE. Next, there is a line near the top that reads "id:3:initdefault:". Changing this to "id:5:initdefault:" causes the default runlevel to be 5.

OK, what the heck is a runlevel?

In a nutshell, runlevels categorize the various services that should be started or stopped based on what task the operating system is carrying out. This is an old concept harkening back to the Unix System V days, but it is still a simple and powerful way to manage a system. The various runlevels in Arch are:

  • Level 0: Halt, aka Shutdown. If you switch to level 0, your machine will power off.
  • Level 1: Single user mode. If you are familiar with Windows Safe Mode, this is like that but more so.
  • Level 2: Not used these days.
  • Level 3: Multi user mode, console login. This was the default level after a bare Arch installation.
  • Level 4: Not used these days.
  • Level 5: Multi user mode, X Windows. This is our target level.
  • Level 6: Reboot. If you switch to level 6, your machine will reboot.

So by switching my default runlevel from 3 to 5, I make the machine boot straight into KDE. Simple!

And here it is!

Next: Application Install
Or check out the Index

No comments:

Post a Comment