Building a custom Debian system, part 3

This is the third and final part of a three-part tutorial on setting up a customised Debian system. In this part, you can get an overview of some of the customisation options available, and step-by-step instructions for setting up some common basic configurations. The previous part walked through installing the base system that you will be working from in this part, and the first part explained how to choose and download an installation image for installing the base system.

Before you begin

If you followed the previous part of the tutorial, you will have a “clean slate” Debian system to work from as you set up your customised Linux installation. If you have not followed the previous part on installing the system, you will need to go back and read it now before continuing. Make sure, then, that your target computer is booted into the new Debian installation and has some way of accessing the command line – the instructions in this part can all be performed using either a keyboard and a monitor or on a headless system over SSH if you chose the “SSH server” option during the installation of the base system. Log in to the system as root to start installing packages; the “sudo” command is not installed with the base system.

Some things you’ll probably want

As the installed base system is just that, a minimal base system, you’ll find that it is lacking a number of common commands and utilities that you’re probably used to having. Here’s how to install some of the most common ones.

sudo

The “sudo” command is missing from the base system, so you’ll probably want to install it first. There’s no problem with continuing to work as the root user when installing and configuring software, but you’re probably used to doing everything with sudo from other Linux distros and installing it is better done sooner rather than later when there are more users. So go ahead and install it now:

apt-get install sudo
usermod -a -G sudo <username>

where “<username>” is the name of the user that you created during installation. You will now be able perform the remainder of the commands in this tutorial as your normal user with the “sudo” prefix if you prefer.

Hereafter, any new users that you create can be given permission to use the “sudo” command by running:

usernmod -a -G sudo <username>

where “<username>” is the name of the user that you want to grant sudo permission to.

SSH

Even though not all of my systems are servers, I can’t say I’ve ever installed a new Linux system and not wanted to log in over SSH sooner or later. Plus SSH includes SFTP, which is great for file transfers. So if you didn’t install the SSH server during installation of the base system, here’s how to do it now:

apt-get install openssh-server

This will install both the SSH and the SFTP server.

curl

If you’re like me, you hate the “curl” HTTP client and prefer wget; if you’re like most people, you’ll try to “curl” a URL and get confused when curl is not installed. So if you want it, install it as follows:

apt-get install curl

unzip

As much as we all hate the outdated “PK-zip” file format, the sad truth is that it still comes along now and again. To be able to extract such files, such as “.zip” files intended for Windoze systems, install the “unzip” command:

apt-get install unzip

Automatic command suggestions

It’s generally useful to be prompted with the name of the required package if you try to run a command that isn’t installed. This is especially useful with a minimal system such as this, as you’ll be surprised how little is actually installed at first and being told straight away how to install it will make life a lot easier for you. I strongly recommend, then, that you install the “command-not-found” package as follows:

apt-get install command-not-found
update-command-not-found

Now when you try to run a command that isn’t installed, instead of just being told “command not found”, you’ll be prompted with the name of the package which supplies the command, or a range of similar commands if the command entered is not in the database.

ALSA utilities

Although the base system includes ALSA (but not PulseAudio), it doesn’t include the standard ALSA utilities, such as “alsamixer”. If you want to be able to manage your audio inputs/outputs, which you probably do want to if you care about sound, you can install these now like this:

apt-get install alsa-utils

Note that you will probably need to set the volume levels of your audio input/outputs through alsamixer before you can use them.

Additional suggestions

This is where the real customisation comes in. You’ve got your clean slate system now, and you hopefully know what you want to do with it. But maybe you’re not exactly sure exactly which packages to install, so here’s a rundown of a few popular ones for different setups.

Before you install additional software

By default, Debian is configured to install only “officially supported” software. A lot of software is good, but not officially supported, so having the system configured like this can be confusing when you try to install common applications and get told that they can’t be found. So change this as follows:

  • Run “nano /etc/apt/sources.list” as root to edit the package sources file
  • At the end of each line which ends with the word “main”, add the word “contrib”
  • You can also add “non-free” if there are no legal issues with this, although bear in mind that the software in the “non-free” category can have legal restrictions on where, how, and for what purpose it can be used – this is where you’ll find “binary blob” drivers and non-free media codecs
  • Save and close the text editor (press CTRL+O, return, CTRL+X)
  • Reload the package index cache by running “apt-get update” as root – note that this will not update the packages installed on the system but only update the package index cache to reflect your changes to the desired software categories

Desktop environment

If you’re setting up a desktop system, you will probably want more than just the command line interface. Here’s how to install some of the more popular desktop environments (note that I have not tested any of these thoroughly):

  • GNOME
    Install the package “gnome-shell”
  • KDE
    Install the package “plasma-desktop” if you want just the desktop, or “kde-plasma-desktop” if you want a fuller desktop experience
  • XFCE
    Install the package “xfdesktop4”
  • MATE
    Install the package “mate-desktop”

All of these can be installed using the standard “apt-get install” command. GNOME and KDE include some of the related applications, such as text editors and terminal emulators, and the GNOME Display Manager and KDE Display Manager respectively, which in turn will install the entire Xorg graphical subsystem. MATE and XFCE do not include any packaged applications or display managers, so it will be necessary to install and configure a display manager separately. I recommend LightDM, which is in the package “lightdm”, and will also install Xorg. (Configuring the display manager is beyond the scope of this tutorial – they’re supposed to configure automatically these days anyway; my experience of autoconfiguration is poor.) For other desktop environments, consult the relevant documentation. Note that I do not recommend attempting to install Xorg on its own; rather let your chosen display manager install Xorg as a dependency.

You’ll probably also want some common desktop applications that you might be used to using. Remember that when you build a system up like this, there are no desktop applications installed at first so you’ll have to install each and every application that you want to use. I can’t give instructions for every application as there are so many applications out there and a lot of different applications that perform similar tasks, the choice of which you install is up to your personal preference. Hopefully if you’re building a system up from scratch you’ve got a good idea of what applications you want, and figuring out how to install them usually goes like this:

  • Try to run “apt-get install <name of application>” as root
  • If the package cannot be found, then if you installed the “command-not-found” package as recommended earlier, try to run the most likely name of the application’s binary and see what package is suggested
  • If no package is suggested, or you did not install “command-not-found”, then try “apt-cache search <name of application> –names-only” and see if any likely packages are returned, then try to install them
  • If that fails, consult the documentation for the application

where “<name of application>” is your best guess at a lowercase, single-word name for the desired application.

You can either try to install everything now, or just install applications as you need them. Remember that if an application does not appear in your desktop environment’s applications menu you can try running it from the command line – you’ll find out pretty quickly if it’s installed, and if not then if you installed the “command-not-found” package you’ll get a list of possible packages containing the requested application.

One tip that I should give you is that if you want to install the VLC media player, don’t install “vlc-nox” as suggested when you try to run “vlc”, but install the package “vlc” instead. “vlc-nox” is intended for users who want to use VLC to play audio and framebuffer video without installing Xorg.

Command line only environment

If you’re setting up a desktop system to use without a graphical environment, you’ll definitely want to install a number of useful applications, and you’ve hopefully got an idea of what command line applications you use most. I can’t list instructions for every application as there is a wide choice of applications and you’ve probably got your personal favourites that you use regularly, but figuring out how to install an application usually goes like this:

  • Try to run “apt-get install <name of application>” as root
  • If the package cannot be found, then if you installed the “command-not-found” package as recommended earlier, try to run the most likely name of the application’s binary and see what package is suggested
  • If no package is suggested, or you did not install “command-not-found”, then try “apt-cache search <name of application> –names-only” and see if any likely packages are returned, then try to install them
  • If that fails, consult the documentation for the application

where “<name of application>” is your best guess at a lowercase, single-word name for the desired application.

You can either install all of your common applications now, or just install them as you need them. If you try to run an application that isn’t installed, you’ll find out soon enough that it’s missing and if you installed the “command-not-found” package as recommended earlier then you’ll also get a list of possible packages containing the requested application.

One thing to remember is that a number of command line applications also offer graphical interfaces, including the “vim” text editor. Installing these applications with “apt-get install <name of application>” is likely to either fail, drag in Xorg as a dependency, or complete with lots of extra junk on your system (even if it doesn’t install Xorg); most such applications offer a package with the “-nox” suffix which installs the same application without the graphical interface, so be sure to try “apt-cache search <name of application> –names-only” or at least hit the tab key a few times after typing the package name to see if there is a “-nox” version available. At the very least, carefully check the list of dependencies that will be installed, and don’t always jump at the most obvious package if you’re given a few choices.

Server

There are so many different kinds of servers that you can set up, and setting up and configuring a server is beyond the scope of this tutorial. But there are a few basic server applications that you will probably want to install, or at least look into.

SSH

I know this is the third time I’ve mentioned SSH in this tutorial, but if you’re setting up a server and you haven’t installed SSH yet then do it now. That’s an instruction, not a suggestion. Trust me, you won’t regret it.

apt-get install openssh-server

Web server

If you’re setting up a web (HTTP) server, you probably want to use Apache. There are many different ways to configure Apache, and many different “modules” that can go with it, but the stuff you’re almost certain to want is:

apt-get install apache2 libapache2-mod-php5

This will install Apache with PHP support.

Database

Configuring a database server is beyond the scope of this tutorial, but you can install the MySQL database server with:

apt-get install mysql-server

Unless you’ve got another system that you will be administering the database from, and you’re going to reconfigure the new MySQL server to allow access from another system, you’ll probably also want to install the utilities for managing the database:

apt-get install mysql-client mysql-utilities

Remember that these utilities can also be used over SSH for remote administration.

If you installed a web server with PHP, you’ll probably also want to be able to connect to the database from PHP scripts:

apt-get install php5-mysql

Email server

Email servers are in fact one of the most complicated servers to configure, but if you’re looking to set one up you’ll want to investigate Dovecot, Postfix, and Sendmail.

File sharing

If you’ve installed SSH, you’ve already got an SFTP server – they’re supplied together. But for more advanced file sharing with other UNIX-based systems, you can install the NFS server as follows:

apt-get install nfs-kernel-server

Now edit the /etc/exports file to add NFS exports (directories that can be mounted over NFS). Explaining how to edit this file here is unnecessary, as the official documentation was installed with the NFS server. Just run “man 5 exports” to view the manual page for editing this file.

If you want to share files with a Windows system, you’ll need to install the Samba file-sharing server as follows:

apt-get install samba

Then edit the /etc/samba/smb.conf file to add shared directories. As with NFS, the documentation was installed with the server and can be viewed by running “man 5 smb.conf”. You’ll also need to add users that can access Samba shares:

smbpasswd -a <username>

where “<username>” is the name of the user that you want to give access to (the users that can access a specific share is specified in the configuration for that share). When you run the above command, you will prompted to set a password for the user; this does not need to match their UNIX password (in fact they don’t need to have a UNIX password set at all; the username just needs to exist on the server).

Final steps

Now that you’ve installed all of the software that you want, or at least all of the software that you plan on installing at this stage, there are two things you should do.

Update the “locate” database

The database used by the “locate” command is updated periodically, however you’ve changed a lot of files by installing a lot of packages so updating the database manually now would be a good idea. Run “updatedb” as root now to update the database. Note that this may take some time to complete.

Rebooting the system

Finally, you should reboot the system. Almost all configuration changes take effect when the system is restarted, and some newly-installed services only start after a reboot. While it is possible to reload configuration files and start services manually, a reboot will easily make sure everything is done properly and there’s no reason not to reboot the system. So run “reboot” as root.

The next startup may take a while, as usually after installing a lot of software the readahead profile is rebuilt, meaning that the system keeps a record of what needed to be done during startup so that it can do it quicker next time. Also, the installation of extra system services, particularly if you have set up a server, will increase the average startup time. You could reboot again to compare the speeds, but this is not necessary.

What you see once you’ve rebooted depends on what you installed. If you installed a desktop environment and display manager, you’ll hopefully see a graphical login prompt. If you’ve set up a command line-only system, you’ll just have the same text-mode login prompt as before. If you have set up an SSH server, you can log in over SSH. Now would also be a good time to test any other server software that you have installed, such as file sharing.

If all goes well, then congratulations on setting up your custom-built Debian system, fully specialised to your exact needs! If not, review the steps above to see if you have missed anything, otherwise feel free to ask away in the comments section.

Advertisements

Leave a comment...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s