How to Install GNU Emacs in Debian 11 / Ubuntu 20.04 via 5 Different Ways

In this tutorial, I will show how to install the GNU Emacs text editor (v27.2 so far) in different ways in Debian 11 and Ubuntu 20.04. So, you may choose the favorite method depends on your situation.

Emacs does not provide official binary packages for Linux. But, each Linux distribution has its own package of the editor in repository. As well, it’s available as universal Flatpak and Snap packages. And, user may compile it from the source tarball.

Option 1: Install GNU Emacs from System Repository:

User may install the text editor from Debian or Ubuntu’s own repository. The package is usually old, but well-trusted and supports all CPU architectures (e.g., 64-bit, 32-bit, arm64, powerpc).

Simply open terminal from start menu (or press Ctrl+Alt+T on Ubuntu), then paste the command below into terminal and hit enter:

sudo apt install emacs

Uninstall Emacs apt package:

For choice, here’s the command to remove the emacs package installed via the previous command:

sudo apt remove --autoremove emacs emacs-common emacs-gtk

Option 2: Install Emacs via Flatpak:

Flatpak is an universal package format that works on most Linux systems. It runs in sandbox with a separate daemon. Flatpak makes easy to install the latest apps and keep up-to-date automatically, but it takes hundreds of MB more disk spaces for run-time libraries.

Firstly, open terminal from start menu (search in ‘Activities’ overview), then run command to install the daemon:

sudo apt install flatpak

Next, install the Emacs editor as Flatpak using command:

flatpak install

Type ‘y’ to confirm, and it will start installing the app as well as run-time libraries.

Like normal apps, user may open Emacs Flatpak from start menu (or search in ‘Activities’ overview). But, you may have duplicated icons, if snap and/or deb packages (via apt command) installed.

Uninstall Emacs as Flatpak:

For any reason, user may easily remove the Flatpak package by running command in terminal:

flatpak uninstall --delete-data org.gnu.emacs

And, remove unused libraries via command flatpak uninstall --unused.

Option 3: Install Emacs via Snap:

Canonical, the company behind Ubuntu, developed the Snap package format runs in most Linux. Snap and Flatpak are competing with each other, though I prefer the latter a little bit more. It runs in sandbox too with a separate daemon, and updates automatically while taking more disk spaces! And, Emacs as Snap is available to install in 64-bit, armhf/arm64, ppc64el, and s390x architectures.

Firstly, install the snap daemon (Ubuntu has it out-of-the-box) by open terminal and running command:

sudo apt install snapd

Next, install Emacs as snap via command (Ubuntu user may also install it from Ubuntu Software):

sudo snap install emacs --classic

Uninstall Emacs as Snap:

And to remove Emacs as snap, using command:

sudo snap remove --purge emacs

Option 4: Install Emacs Snapshot in Ubuntu:

For those want to install the latest bleeding-edge version of the editor, there’s an official Ubuntu PPA contains the packages for Ubuntu 18.04, Ubuntu 20.04, and Ubuntu 21.10.

There are also and repositories for Debian. Somehow, Debian 11 Bullseye is not supported!

Firstly, press Ctrl+Alt+T on keyboard to open termina. When it opens, run command to add the PPA:

sudo add-apt-repository ppa:ubuntu-elisp/ppa

Next, update the system package cache by running command:

sudo apt update

Finally, install the snapshot package via command:

sudo apt install emacs-snapshot

How to Remove Emacs snapshot package:

To remove the snapshot package, use command:

sudo apt remove --autoremove emacs-snapshot-common

And remove the PPA via command:

sudo add-apt-repository --remove ppa:ubuntu-elisp/ppa

Option 5: Build Emacs from the source tarball:

I don’t find any apt repository for the latest stable Emacs (v27.2) via native DEB package. If you found one, please tell me via the command below. For choice, user may build it from the source tarball.

Install build dependencies:

1.) Firstly, open a terminal window from start menu (or search in ‘activities’ overview). When it opens, run commands to install the dependency libraries:

sudo apt install build-essential
sudo apt build-dep emacs
The second command installs the build dependencies, but you need to enable 'Source Code' first in Software & Updates utility then reload the cache (sudo apt update) on app close.

Download & Extract the Source:

2.) Next, download the GNU Emacs source tarball from the link below:

3.) Extract the source and open source folder in terminal window via its context menu option “Open in Terminal”.

Build Emacs:

4.) In pop-up terminal window, it automatically navigate to the Emacs source folder. You can now run following commands one by one to build it:

  • Run command to generate the configure script:
  • Configure the source:
  • Start building it via command:
    make bootstrap
    Depends on your CPU, start multiple threads via "-jN" flag, such as make bootstrap -j4 to start 4 threads to speed up the process.
  • Finally install it via command:
    sudo make install

Install App shortcut icon:

5.) Compiling the source tarball does not create app shortcut file. So, you have to run command to create one yourself:

sudo nano /usr/share/applications/emacs.desktop

The command creates the file and opens in nano command line text editor. When it opens, paste the lines below.

[Desktop Entry]
Name=Emacs (GUI)
GenericName=Text Editor
Comment=GNU Emacs is an extensible, customizable text editor – and more
Exec=/usr/local/bin/emacs %F

Finally, save the file by pressing Ctrl+X, then type “y” and hit Enter.

Uninstall Emacs:

Before removing the source folder, user may run the command in terminal to uninstall Emacs:

sudo make uninstall

Make sure the source folder is current working directory in terminal. And, if you’ve removed the source folder. Re-download and extract the source, and re-make the source.

And, remove the app shortcut icon by removing the .desktop file via command:

sudo rm /usr/share/applications/emacs.desktop


In this guide, I’ve taught how to install Emacs via system’s own package, Snap, Flatpak, as well as source tarball. Since the system package is always old, Flatpak and Snap are easy way to install and keep the app up-to-date. However, some users does not like Flatpak or Snap, so here’s also how to compile from the source.

Exit mobile version