How to install Emacs on AlmaLinux 9

How to Install Emacs on AlmaLinux 9

Want to set up Emacs on AlmaLinux 9? 

In this article, I’ll show you how to install Emacs on your AlmaLinux 9 system. After that, I’ll help you with some basic setups and settings to begin.

Let’s begin.

What You’ll Need

Here’s what you’ll need:

  • AlmaLinux 9 installed and running on your device (guide)
  • Root access or sudo privileges (guide)
  • Understanding of the Command Line Interface and Linux commands (guide)
  • A reliable internet connection

Once you’ve confirmed these, let’s dive into the first step.

How to Install Emacs on AlmaLinux 9: Step-By-Step

Step 1: Prepare Your System by Cleaning and Updating

  1. First, ensure your system is current and clutter-free. Begin by clearing out the temporary files from the enabled repositories. This step helps in retrieving the latest package information more efficiently. Run the following command to clean up:
sudo dnf clean all
sudo dnf clean all command
  1. After that, you can update your software repository list to have access to the latest packages. Update that list with this command:
sudo dnf update
sudo dnf update command
  1. If this is your first time using sudo in the terminal session, you’ll be asked for the user password. So enter the password and the Enter button.
  2. When asked for confirmation, enter y and press the Enter button. Depending on the size of the update, it may take a while. So wait patiently until it finishes. 
  3. (Optional) As an additional measure, you might want to confirm the success of the update. To do so, execute the command below:
sudo dnf list updates
sudo dnf list updates command

From the screenshot provided, you’ll notice the list is empty, indicating a successful update.

With this confirmation, you’re all set to proceed with the Emacs installation on AlmaLinux.

Step 2: Installing Emacs on AlmaLinux

Now, let’s focus on the core of this guide: installing Emacs.

  1. We’ll utilize the YUM package manager for this installation. To proceed, just run the following command:
sudo yum install emacs

(Optional) Alternatively, you can use the DNF package manager. If you choose this route, the command will be as follows:

sudo dnf install emacs
install emacs on AlmaLinux
  1. When asked for confirmation, enter y and press Enter to start the installation. 
  2. To confirm whether you successfully installed Emacs or not, you can just check its version. To check the version of the currently installed Emacs on AlmaLinux, run this command:
emacs --version
check Emacs version on AlmaLinux

The displayed output, GNU Emacs 27.2, confirms it’s the latest version at the time of writing this guide, signifying a successful installation.

  1. The last thing to do is run the program. If you prefer using the terminal to run Emacs, then use the below command for that:
  1. If you’d like to use the GUI instead, then first, go to Activities.
Click on Activities
  1. Type emacs into the search bar. You should see the icon appear.
  2. Click on the icon to launch the program.
Click Emacs icon to open it
  1. If everything went well, you should see the program launch and the welcome page.
Emacs interface

Great! You’re now ready to begin using Emacs on your AlmaLinux machine and edit text files like a pro.

Getting Started With Emacs on AlmaLinux

We wouldn’t conclude this guide without introducing you to essential commands and key bindings for basic operations in Emacs.

Tip 1: Opening and Creating Files in Emacs

Mastering how to open existing files and create new ones is fundamental.

  1. To open a file in Emacs, use these keys: Ctrl+X Ctrl+F
  1. A prompt will appear, requesting the file’s path. Simply type in the location and press Enter.
Open a file in Emacs editor

Let’s now see how to create a file in Emacs.

  1. To create a new file, use the below buttons: Ctrl+X Ctrl+F
  1. In the prompt, enter a new file name that doesn’t already exist. This should create a new empty file.
Creating a new file on Emacs

As you can notice, this time, a new file was created.

Tip 2: Mastering File Navigation in Emacs

The next thing you should know is how to navigate a file after opening it.

  1. Navigating in Emacs is quite intuitive. Use the arrow keys to move the cursor up, down, left, or right.
  2. For moving forward and backward by one character, you can also use Ctrl+F and Ctrl+B, respectively.
  3. To go to the next line, press Ctrl+N.
  4. To return to the previous line, press Ctrl+P.

Tip 3: Editing and Saving Files in Emacs

Once you’re comfortable navigating, the next step is editing text files.

  1. Begin typing with your keyboard to add text.
  2. To remove an entire line to the right of the cursor, use Ctrl+K.
  3. To paste previously cut text, press Ctrl+Y.
  4. To reverse a recent change, press Ctrl+X and then U.
  5. To save your modifications, hit Ctrl+X followed by Ctrl+S.

Tip 4: Exiting Emacs Successfully

  1. To close Emacs, simply press Ctrl+X followed by Ctrl+C.
  2. If prompted to save any changes, type ‘y‘ to save or ‘n‘ to disregard the changes.

How to Make Emacs Your Default Terminal Editor: 4 Steps

By making a quick adjustment to the bashrc file, you can easily set Emacs as your default command-line editor.

  1. Open the bashrc file in Emacs using the below command:
emacs -nw ~/.bashrc
Emacs configuration file on AlmaLinux

The -nw flag allows you to open Emacs in the terminal instead of in the GUI mode.

  1. At the end of the file, add the following line:
export EDITOR="/usr/local/bin/emacs -nw"
  1. After making the changes, save the file by pressing Ctrl+X followed by Ctrl+S, and exit the editor with Ctrl+X and then Ctrl+C.
  2. Finally, restart your terminal to apply the changes.


Well done on installing and configuring Emacs on AlmaLinux 9! You should now have a solid understanding of this text editor. If you’d like to learn more about Emacs, we encourage you to check out the official documentation.

If this guide helped you, please share it.

Related Posts