The following tutorial will teach you how to install Emacs on Linux Mint 21 LTS release series using a LaunchPAD APT PPA or Flatpak with the command line terminal.
Table of Contents
Update Linux Mint
First, update your system to ensure all existing packages are up to date to avoid conflicts.
sudo apt update && sudo apt upgrade -y
Install GNU Emacs – APT PPA Method
The best APT package manager method is importing and installing the PPA by Kevin Kelley.
First, make sure the following dependencies are installed.
sudo apt install dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https -y
Next, import the GPG key needed for all the repositories.
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/emacs.gpg --keyserver keyserver.ubuntu.com --recv-keys 873503A090750CDAEB0754D93FF0E01EEAAFC9CD
If you have issues importing the GPG key from LaunchPAD, please see the end section on GPG troubleshooting at the end of the article.
gpg: keybox '/usr/share/keyrings/emacs.gpg' created gpg: key 3FF0E01EEAAFC9CD: public key "Launchpad PPA for Kevin Kelley" imported gpg: Total number processed: 1 gpg: imported: 1
Next, import the Emacs PPA.
echo 'deb [signed-by=/usr/share/keyrings/emacs.gpg] https://ppa.launchpadcontent.net/kelleyk/emacs/ubuntu jammy main' | sudo tee -a /etc/apt/sources.list.d/emacs.list
Before you continue, run an APT update to reflect the newly imported PPA.
sudo apt update
Now install the text editor.
sudo apt install emacs28
For users that prefer using the terminal, you can install the CLI version.
sudo apt install emacs28-nox
Currently, version 28 is the latest.
Install GNU Emacs – Flatpak Method
The second option is to use the Flatpak package manager. Flatpak is installed on Linux Mint desktops as the default optional third-party package manager replacing Snapcraft.
First, re-install the Flatpak manager if it was removed previously.
sudo apt install flatpak -y
For users re-installing Flatpak, I would suggest a reboot. This is optional, but if anything odd occurs, reboot.
SKIP THE REBOOT IF FLATPAK IS INSTALLED.
Next, you need to enable Flatpack using the following command in your terminal.
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Now install Emacs using the following flatpak command.
flatpak install flathub org.gnu.emacs -y
How to Launch GNU Emacs (GUI or Terminal)
Launching can be done in a few ways now that you have the software installed.
First, the software can be launched using the following command for desktop users.
Alternatively, Flatpak users will need to launch using the command below from a terminal instance.
flatpak run org.gnu.emacs
Most desktop users may elect to use the application icon, which can be achieved using the following path.
Taskbar > Programming > Emacs (GUI or Terminal).
Depending on the option you choose using the graphical UI or terminal, you will arrive at the text editor. For new users, check out the Emacs documentation.
How to Update/Upgrade GNU Emacs
The best method to ensure your installation of Emacs is up-to-date is to open the command line terminal and run the following command.
Depending on the method of installation used, the following commands can be used to update.
APT Update Method
sudo apt upgrade && sudo apt upgrade
Flatpak Update Method
The command will also ensure all other packages that use the APT package manager, including your system packages, are up-to-date. I suggest that users new to Linux run this command frequently to ensure your system works as intended, even if you have automatic GUI updates or notifications.
How to Remove (Uninstall) GNU Emacs
Use one of the following commands to suit the original installation method for users who no longer require the application.
APT Remove Method
sudo apt autoremove emacs* -y
Next, you should remove the PPA for users who will not use the software again.
sudo rm /etc/apt/sources.list.d/emacs.list
Flatpak Remove Method
flatpak uninstall --delete-data org.gnu.emacs
Next, run the following command for any leftover clean-up.
flatpak remove --unused
How to Fix Broken LaunchPAD GPG Import
Users that have installed Linux Mint for the first time or have not imported a GPG key before using the command line terminal will often have issues importing GPG keys from LaunchPAD PPAs due to the directories not being created. This is an easy fix. Use the following command that will, in turn, generate the directories.
sudo gpg --list-keys
As above, the necessary directories have been created. This can be skipped, and use the following GPG import command below. If you have any issues with directories missing for this and any other PPA GPG key in the future, just run the above command.
Comments and Conclusion
GNU Emacs is a powerful and versatile text editor trusted by programmers and other power users for many years. The latest release, GNU Emacs 28, brings significant new features and improvements, making it even more user-friendly and customizable. If you’re looking for a text editor that can do everything you need, look no further than GNU Emacs – it’s the complete text editor available today.