How to Install Alpine Linux and Set up a Desktop Environment

Ready for a lightweight and customizable Linux experience? Dive into our guide on installing Alpine Linux and setting up a desktop environment.

You’re in the right place if you’re seeking a lightweight and customizable Linux experience. Alpine Linux, known for its minimalistic design and enhanced security, offers a refreshing alternative to traditional distributions.

Moreover, Alpine is a systemd-free operating system, which means it does not use the systemd system as its default init system. Instead, it relies on OpenRC – an init system and service manager- providing a simple and modular initialization process while efficiently managing system services.

Although the distribution’s biggest strength is on the server side, especially in containerization, more experienced Linux users will find in Alpine the flexibility, simplicity, and speed that they have been looking for in their desktop system.

So, are you ready? Let’s dive in and unleash the power of Alpine Linux!

Alpine Linux Advantages

Before we go into how to install Alpine and add a desktop environment to it, let’s take a quick look at the main benefits of using Alpine.

Lightweight and minimalistic: Alpine Linux is designed to be lightweight, making it ideal for resource-constrained systems. It consumes minimal disk space and has low memory requirements, resulting in improved performance.

Enhanced security: With a strong emphasis on security practices, Alpine employs advanced measures such as stack protection, hardened kernel, and Address Space Layout Randomization (ASLR). Its minimal package set reduces the attack surface and ensures a more secure desktop environment.

Customizable: The distro offers flexibility and customization options, allowing you to tailor your desktop environment to suit your preferences. You can choose from various lightweight window managers, desktop environments, and software packages.

Powerful package manager: Alpine utilizes an efficient and reliable package manager called APK (Alpine Package Keeper). It provides a vast repository of packages, making installing and updating software on your system easy.

Container-friendly: Alpine Linux is widely used in containerized environments due to its small size, fast boot time, and reduced attack surface. It is an excellent choice for running Docker containers, enabling efficient resource utilization.

Active community and support: Alpine Linux is widely used in containerized environments due to its small size, fast boot time, and reduced attack surface. As a result, it is an excellent choice for running Docker containers, enabling efficient resource utilization.

1. Download Alpine’s Installation ISO Image

The first step in Alpine Linux installation is, of course, to download the installation ISO image. Visit the download page at https://alpinelinux.org/downloads/ and click the “x86_64” button in the “STANDARD” section.

Download Alpine's Installation ISO Image.
Download Alpine’s Installation ISO Image.

Wait for the download to complete. This should be done quickly, as the Alpine installation image is relatively small (under 200 MB).

2. Prepare Live Bootable USB

The next step is to prepare a live Alpine installation USB by writing the ISO you downloaded to it. There are many ways to do this, but one of the easiest is using the dd command.

Of course, if you choose to perform the Alpine installation in a virtual machine using software like VirtualBox or similar, you can skip this step and directly load the Alpine ISO there.

Because Alpine is a very light and minimalist Linux distribution (considering that we will add a desktop environment), installing it on a virtual machine with 2 GB of memory and 10 GB of disk space would be sufficient.

3. Boot Alpine’s Installation Program

Once you have booted into the Alpine ISO, you will be presented with the screen as one shown below.

Boot Alpine's installation ISO image.
Boot Alpine’s installation ISO image.

This is the time to clarify that Alpine Linux installation, like Arch or Slackware, is entirely terminal-based. However, this should not bother you because the actions are simple and detailed below.

4. Start the Alpine Linux Installation

Log in as “root.” The system will not prompt you for a password; you will be taken directly to the shell. Type “setup-alpine” and press “Enter” to begin the Alpine installation.

setup-alpine
Start Alpine Linux installation.
Start Alpine Linux installation.

4.1 Setup Keyboard

The first step is to set up your keyboard layout. The various keymaps are available, so we will use the “us” that meets our needs. Of course, if you use another one, look for it in the list and enter the correct one.

Set up keyboard layout.
Set up keyboard layout.

Then select the keyboard variant. Here again, we choose just “us.”

Choose a keyboard variant.
Choose a keyboard variant.

4.2 Set Hostname

Next, you need to set the hostname. We choose to use “alpine,” but you can type in another, then confirm by pressing the “Enter” key.

Setting up the system hostname.
Setting up the system hostname.

4.3 Set up Network Connection

It’s time to set up the network connection. Alpine Linux will try to detect your network interfaces automatically. It’s the “eth0 ” (in our case), so we confirm the selection by pressing “Enter.”

Set up a network connection.
Set up a network connection.

However, if your network interface is not identified automatically, you can type “?” for more information.

In the next step, you can manually set the IP address of your network interface. However, since we have DHCP, the default option for configuring it, we hit “Enter” once more to accept that option.

Configure the IP address.
Configure the IP address.

We answer “n” to the next question since we don’t want to make extra manual network interface configurations.

Set up a network connection.
Set up a network connection.

You should now have a properly configured network interface, so it’s time to move on to the next step.

4.4 Setting up Root Password

Set the password for the root user by entering it twice. Don’t worry that there is no regular user account set to use on your Alpine desktop system. We’ll add it a little later.

Setting up a root user password.
Setting up a root user password.

4.5 Set the Time Zone

Next, let’s configure the timezone. In our case, we will use “America/New_York.” To see your exact syntax, type “?” and you’ll be presented with a list of all available ones.

Accept the default “none” value to opt out of proxy configuration.

Setting up a Time Zone.
Setting up a Time Zone.

4.6 Select Alpine Linux Mirror

Choose the primary mirror that will serve as the software source for your Alpine system. Option 1 is our default, but if you prefer another, please provide its number.

Setting the Alpine mirror.
Setting the Alpine mirror.

4.7 Setup a Regular User Account

Enter the required information, such as username and full name, and set a password for the account that will operate your Alpine Linux desktop system.

Additionally, you can enter the SSH key for the newly created user account. Since we don’t have one, we choose the default value “none.”

Set up a regular user account.
Set up a regular user account.

4.8 Choose Secure Shell Daemon

Alpine offers two primary secure shell daemons – OpenSSH and Dropbear. The latter is simpler but has its key format, so we stick with the widely used OpenSSH. Hit “Enter” to accept the default value.

Choose the default secure shell daemon.
Choose the default secure shell daemon.

4.9 Disk Partitioning

Select the disk that will be used for your Alpine installation. In our case, this is “vda.”

Selecting the disk to partition.
Selecting the disk to partition.

You will be given to choose between several options on how the installation will be performed. Let’s take a look at them.

  • System disk mode (sys): a traditional hard-disk install that creates three partitions on the selected storage device, “/boot,” “swap,” and “/” (the filesystem root). Most suitable for generic desktop machines.
  • Data disk mode (data): This mode runs from system RAM but swaps storage, and the entire “/var” directory gets mounted from a persistent storage device. Helpful in having RAM-accelerated servers.
  • Crypt: As the names suggest, you can set up an encrypted LUKS volume. You will be asked again for “sys” or “data” mode.
  • LVM: Enable logical volume manager and ask again for “sys” or “data” mode.

Since we are installing a desktop system, we select the “sys” mode and confirm by hitting “Enter.”

Setting the installation type.
Setting the installation type.

The installer will warn you that all information on the disk will be erased. Type “y” and hit “Enter.”

Erase the disk and perform a fresh installation warning.
Erase the disk and perform a fresh installation warning.

The installation will take up to a minute. Once complete, reboot the system.

Installing Alpine Linux.
Installing Alpine Linux.

Your newly installed Alpine system will load. Log in as user “root” and use the password you set during installation.

Alpine Linux has been installed successfully.
Alpine Linux has been installed successfully.

5. Post Installation Steps

We will perform simple actions to make our newly installed Alpine system more user-friendly and software-rich.

Edit the “/etc/apk/repositories” file and remove the comment (#) before the community repository line to enable it. Then, save the file and exit.

vi /etc/apk/repositories
Enable Alpine's community repository.
Enable Alpine’s community repository.

It contains software made by users in teams with Alpine’s developers and is well-near integrated with the Alpine packages.

Next, we’ll install a Bash shell (which isn’t installed by default) and the “sudo” command. Finally, we’ll add our user to the “wheel” group so that we can execute commands with root privileges and set his default shell to Bash.

apk add bash bash-completion sudo shadow
echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
adduser linuxiac wheel
usermod -s /bin/bash linuxiac
Alpine Linux post-installation steps.
Alpine Linux post-installation steps.

Finally, reboot the system.

6. Install Desktop Environment on Alpine Linux

Here’s where APK, Alpine Linux’s trusty package manager, steps into the spotlight. If it’s new to you, we highly recommend getting acquainted with it before diving into the commands below.

Don’t worry; we’ve made this easy for you with our comprehensive and user-friendly guide, “Alpine User’s Guide to APK: How to Manage Packages.” It’s a great starting point for your journey with the apk command. Now, back to the topic.

Once the base Alpine system is installed, we can move on to the next step – installing the desktop environment. We’ll show you how to install three of the most popular ones, KDE Plasma, GNOME, and Xfce, so you can choose the one you prefer.

But first, however, we need to prepare the system for the desktop environment.

6.1 Setting up X-Window

Alpine Linux provides users with the “setup-xorg-base” command. This standalone script automatically configures a graphical environment, installing basic Xorg packages and udev, and is also required for Wayland sessions. Type the following command:

setup-xorg-base

All the packages needed to run the desktop environment will be automatically installed.

6.2 Install KDE Plasma on Alpine Linux

KDE Plasma is a desktop environment that provides a user-friendly and customizable interface for Linux-based operating systems. It is known for its modern and visually appealing design, flexibility, and extensive customizability.

Enter the following command to install the Plasma desktop on your Alpine Linux system.

apk add plasma elogind polkit-elogind

This will install the Plasma desktop, as specified by the “plasma” meta package, the SDDM display manager, and other goodies.

Please remember that this will only install the base Plasma desktop environment.

Suppose you want to add any of its many applications to enjoy its full power. In that case, you must install some of the Plasma metagroups packages shown below using Alpine’s APK package manager.

  • kde-applications-accessibility
  • kde-applications-admin
  • kde-applications-base
  • kde-applications-edu
  • kde-applications-games
  • kde-applications-graphics
  • kde-applications-multimedia
  • kde-applications-network
  • kde-applications-pim
  • kde-applications-sdk
  • kde-applications-utils
  • kde-applications-webdev

Or you can use the command below to install them all at once, which is the approach we will use.

apk add kde-applications

Let’s install the Firefox browser now because the Plasma desktop doesn’t have one by default.

apk add firefox

Install additional fonts to make working with the Alpine system more visually pleasing.

apk add font-terminus font-inconsolata font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra font-liberation

Finally, set the SDDM display manager automatically to start on boot and reboot the system.

rc-update add sddm
reboot
Set SDDM automatically to start on boot.
Set SDDM automatically to start on boot.

After the restart, you will be greeted by the SDDM login manager. Enter the username and password for the user you created earlier and enjoy the KDE Plasma desktop.

SDDM login manager.
SDDM login manager.
Alpine Linux with KDE Plasma desktop.
Alpine Linux with KDE Plasma desktop.

6.3 Install GNOME on Alpine Linux

The GNOME desktop environment is easy to install on Alpine Linux. First, run the command below to get a basic GNOME installation.

setup-desktop gnome

Once all packages have been downloaded and installed, perform the following command to allow GNOME Software to manage APK packages:

rc-update add apk-polkit-server default

Add some additional fonts for a more visually pleasing GNOME experience.

apk add font-terminus font-inconsolata font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra font-liberation

Finally, install the Firefox web browser and reboot the system.

apk add firefox
reboot

The GDM login manager will greet you. So log in and enjoy GNOME.

GDM login manager.
GDM login manager.
Alpine Linux with GNOME desktop.
Alpine Linux with GNOME desktop.

6.4 Install Xfce on Alpine Linux

Xfce is lightweight, efficient, and visually appealing while using minimal system resources desktop environment, so it’s a perfect match for your Alpine system. Here’s how to install it.

First, execute the following command to install the basic Xfce desktop, LightDM login manager, and Firefox:

apk add xfce4 xfce4-terminal xfce4-screensaver lightdm-gtk-greeter dbus firefox

Next, install some additional fonts:

apk add font-terminus font-inconsolata font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra font-liberation

Enabled LightDM and D-Bus services to start up on boot automatically:

rc-update add dbus
rc-update add lightdm

And finally, reboot the system:

reboot

The LightDM login manager will greet you, and after logging in, you will experience one of the fastest-running systems you have ever encountered.

LightDM login manager.
LightDM login manager.
Xfce desktop environment running on Alpine Linux.
Xfce desktop environment running on Alpine Linux.

Install, Remove, and Update Packages with APK on Alpine Linux

APK (Alpine Package Keeper) is Alpine’s package manager, allowing users to search, install, remove, and update software on Alpine-based systems.

Below is a quick guide on how to use it, which, as you’ll see, is very easy. Moreover, if you have previous experience with other package managers such as APTDNF, or Pacman, you’ll immediately feel at home with APK.

Search for Packages

apk search <package_name>

Install Packages

apk install <package_name1 package_name2 ...>

Remove Packages

apk del <package_name1 package_name2 ...>

Update/Upgrade System

apk update
apk upgrade

Cleaning Cache

apk cache clean

Conclusion

Installing Alpine Linux and setting up a desktop environment is a straightforward process that provides a lightweight and secure operating system for various purposes.

Following the steps outlined in this guide, users can enjoy the benefits of Alpine Linux’s minimalistic design and efficient resource utilization. In addition, the distro offers a reliable and secure foundation, whether for a lightweight server, a desktop, or a development environment.

To learn more about Alpine, check out the official documentation or visit the project’s website.

So, what do you think of Alpine? Feel free to express your opinion or ask questions in the comments below.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%

12 Comments

  1. Hei Bob, I tried install Alpine xfce4 on My old Acer laptop 32 bit. No gui interfaces appears only cli login, if I run startx nothing only error message no X server Available. Can I fix it? Thanks for reply. Sincerly, Henry.

    • That is exactly the issue since 4 years minimum. I was hoping, that somebody eventually finds out and posts an solution to that obvious fault. In 64bit machines the graphical login manager works, as it should. But not on 32bit machines.
      I tried everything I found – and I had some success a few years ago with plasma. but unfortunately I forgot about it – and I thought: surely today people fixe this flaw and it is written about it. I suppose I am still naive…

  2. Hi and thanks for your help .
    My question to you for help is . Post Installation Steps
    We will perform simple actions to make our newly installed Alpine system more user-friendly and software-rich.

    Edit the “/etc/apk/repositories” file and remove the comment (#) before the community repository line to enable it. Then, save the file and exit.

    How do you remove the # . I am very new to Linux and probably picked a too hard for a new user but i just can’t work out how . I probably made a mistake in setup . I am using a Macbook Pro running a virtualbox trying to add a desktop to Alpine . I have installed xfce from your instructions, but really would like to install kde plasma .

    • Hi Alan,

      The thing to do is to open the file in question (“/etc/apk/repositories“) with a terminal text editor such as nano.
      nano /etc/apk/repositories

      If you don’t have it (the nano text editor), you can install it by running as root the following command:
      apk add nano

      Once you open the file, you will see that the line looks like this:
      #http://dl-cdn.alpinelinux.org/alpine/v3.18/community

      The goal is to make it look like this:
      http://dl-cdn.alpinelinux.org/alpine/v3.18/community

      by removing the “#” symbol at the beginning of the line, which is a comment symbol, so anything else after it is ignored. By removing it, the repository is now taken into account by the OS.

      Best,
      Bobby

  3. I was experimenting with different desktops (plasma, xfce4) using setup-desktop.
    Now that I have a preference (xfce), I’m looking to remove the plasma desktop and all it’s packages that are not required by other system components.
    So far, my search resulted in little information on cleanly removing a desktop environment.
    Any suggestions?

  4. i have an alpine vm (4.19.84-0-virt #1-Alpine SMP Wed Nov 13 09:52:17 UTC 2019 x86_64 Linux
    ) i want to upgrade it offline is there any ways to do it.

  5. Hi Bob!!!
    I’m tried to install wayland as graphic server, and flwm as desktop, and I tried;
    “apk add wayland”
    “apk add wayland-utils”
    “apk add flwm”
    But,… I still can’t start wayland as a server,… and I can´t run flwm (Message “Can´t open display”),… I missed something,… right?,… but,… what?
    (Alpine Linux v3.19 Standard x86_64)
    Thanks!!!

  6. Is it possible to install from Wifi? I tried APK in the ASH install shell but no luck. I did something similar with Arch. Thanks

  7. Hi. After intalation xfe4 or another Shell 3 monitor do not display screen (input not supported). How to change display properties or enter to safe mode?
    Best regards
    Simon

  8. XFCE instructions do not work. Blank screen.
    dropping to cli shows xserver connection refused.
    Seems this setup instructions are no longer correct or maintained (note same fault in previous posters)

Leave a Reply

Your email address will not be published. Required fields are marked *