CentOSRHEL Based

How To Install Emacs on CentOS Stream 9

Install Emacs on CentOS Stream 9

Emacs, short for “Editor MACroS,” is a powerful and versatile text editor that has been a favorite among developers, system administrators, and power users for decades. Known for its extensibility and customization options, Emacs offers a wide range of features that go beyond simple text editing, including project management, integrated development environments, and even email clients.

In this comprehensive guide, we’ll walk you through the process of installing Emacs on CentOS Stream 9, the latest version of the popular Linux distribution. Whether you’re a seasoned Linux user or new to the platform, this article will provide you with clear, step-by-step instructions to get Emacs up and running on your system.

Understanding CentOS Stream 9 and Emacs

What is CentOS Stream 9?

CentOS Stream 9 is the latest iteration of the CentOS Linux distribution, designed as a rolling-release midstream between Fedora Linux and Red Hat Enterprise Linux (RHEL). It provides a stable and reliable platform for developers and system administrators, offering a balance between cutting-edge features and enterprise-grade stability.

Overview of Emacs and its Features

Emacs is more than just a text editor; it’s a complete computing environment. Some of its key features include:

  • Highly customizable and extensible
  • Support for multiple programming languages
  • Built-in package manager for easy extension installation
  • Powerful macro system for automating repetitive tasks
  • Integrated development environment capabilities
  • Version control integration
  • Org-mode for note-taking, project planning, and more

Why Install Emacs on CentOS Stream 9?

Installing Emacs on CentOS Stream 9 provides users with a powerful tool for text editing, coding, and system management. The combination of CentOS Stream’s stability and Emacs’ versatility creates an ideal environment for developers and system administrators to work efficiently and productively.

Prerequisites

Before we begin the installation process, ensure that you have the following:

  • A CentOS Stream 9 system with root or sudo access
  • At least 100 MB of free disk space
  • A stable internet connection for downloading packages
  • Basic familiarity with the command line interface

It’s also recommended to update your system before proceeding with the installation:

sudo dnf update -y

Installation Methods

There are three primary methods to install Emacs on CentOS Stream 9:

  1. Using the package manager (DNF)
  2. Building from source
  3. Using Snap

Each method has its advantages and considerations, which we’ll explore in detail.

Method 1: Installing Emacs using DNF

The simplest and most straightforward method to install Emacs on CentOS Stream 9 is by using the default package manager, DNF (Dandified Yum).

Step 1: Update the System

First, ensure your system is up to date:

sudo dnf update -y

Step 2: Install Emacs

To install Emacs, run the following command:

sudo dnf install emacs -y

This command will download and install Emacs along with its dependencies.

Step 3: Verify the Installation

After the installation is complete, verify that Emacs is installed correctly by checking its version:

emacs --version

This should display the installed version of Emacs.

Method 2: Building Emacs from Source

For users who want the latest features or need a custom build, compiling Emacs from source is an excellent option. This method requires more steps but offers greater control over the installation.

Step 1: Install Build Dependencies

First, install the necessary build tools and dependencies:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install gtk3-devel gnutls-devel libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel giflib-devel ncurses-devel texinfo -y

Step 2: Download Emacs Source Code

Download the latest Emacs source code from the GNU FTP server:

wget https://ftp.gnu.org/gnu/emacs/emacs-29.4.tar.gz
tar -xzvf emacs-29.4.tar.gz
cd emacs-29.4

Step 3: Configure and Compile Emacs

Configure the build and compile Emacs:

./configure
make

This process may take some time, depending on your system’s performance.

Step 4: Install the Compiled Emacs

Once the compilation is complete, install Emacs:

sudo make install

Verify the installation by checking the version:

emacs --version

Method 3: Installing Emacs using Snap

Snap is a universal package manager that can be used to install Emacs on CentOS Stream 9. This method provides easy updates and isolation from the system.

Step 1: Install Snap on CentOS Stream 9

First, install the EPEL repository and Snap:

sudo dnf install epel-release -y
sudo dnf install snapd -y
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

Step 2: Install Emacs via Snap

Install Emacs using Snap:

sudo snap install emacs --classic

Advantages and Disadvantages of Using Snap

Advantages of using Snap include easy updates and isolation from the system. However, Snap packages may start slower and consume more disk space compared to native packages.

Configuring Emacs

After installing Emacs, you may want to customize it to suit your needs. The primary configuration file for Emacs is ~/.emacs or ~/.emacs.d/init.el.

Basic Configuration File

Create a basic configuration file:

touch ~/.emacs

You can add configurations like:

(setq inhibit-startup-message t)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(global-linum-mode t)

Popular Emacs Configurations

For more advanced configurations, consider exploring popular Emacs distributions like:

  • Spacemacs
  • Doom Emacs
  • Prelude

Getting Started with Emacs

Basic Commands and Shortcuts

Here are some essential Emacs commands to get you started:

  • C-x C-f: Open a file
  • C-x C-s: Save the current file
  • C-x C-c: Exit Emacs
  • C-g: Cancel the current command
  • M-x: Execute a command by name

Emacs Tutorials and Resources

To learn more about Emacs, consider exploring these resources:

  • The built-in Emacs tutorial (C-h t)
  • GNU Emacs Manual
  • Emacs Wiki
  • r/emacs subreddit

Troubleshooting Common Issues

Installation Errors

If you encounter errors during installation, try the following:

  • Ensure your system is up to date
  • Check for conflicting packages
  • Verify you have sufficient disk space

Dependency Problems

For dependency issues:

  • Use sudo dnf install --skip-broken to skip problematic dependencies
  • Manually install missing dependencies
  • Consider using a different installation method

Configuration Issues

If you experience configuration problems:

  • Start Emacs with emacs -Q to bypass your configuration
  • Check your ~/.emacs file for syntax errors
  • Use M-x toggle-debug-on-error to get more detailed error messages

Updating and Maintaining Emacs

Keeping Emacs Up to Date

To update Emacs installed via DNF:

sudo dnf update emacs

For source installations, repeat the build process with the latest source code.

If you used Snap, update with:

sudo snap refresh emacs

Removing Emacs

To remove Emacs installed via DNF:

sudo dnf remove emacs

For source installations, navigate to the source directory and run:

sudo make uninstall

To remove Emacs installed via Snap:

sudo snap remove emacs

Congratulations! You have successfully installed Emacs. Thanks for using this tutorial to install the Emacs text editor on CentOS Stream 9. For additional help or useful information, we recommend you check the official Emacs website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button