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.
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
- 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
- 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
- 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.
- 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.
- (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
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.
- 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
- When asked for confirmation, enter y and press Enter to start the installation.
- 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:
The displayed output, GNU Emacs 27.2, confirms it’s the latest version at the time of writing this guide, signifying a successful installation.
- 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:
- If you’d like to use the GUI instead, then first, go to Activities.
- Type emacs into the search bar. You should see the icon appear.
- Click on the icon to launch the program.
- If everything went well, you should see the program launch and the welcome page.
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.
- To open a file in Emacs, use these keys: Ctrl+X Ctrl+F
- A prompt will appear, requesting the file’s path. Simply type in the location and press Enter.
Let’s now see how to create a file in Emacs.
- To create a new file, use the below buttons: Ctrl+X Ctrl+F
- In the prompt, enter a new file name that doesn’t already exist. This should create a new empty file.
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.
- Navigating in Emacs is quite intuitive. Use the arrow keys to move the cursor up, down, left, or right.
- For moving forward and backward by one character, you can also use Ctrl+F and Ctrl+B, respectively.
- To go to the next line, press Ctrl+N.
- 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.
- Begin typing with your keyboard to add text.
- To remove an entire line to the right of the cursor, use Ctrl+K.
- To paste previously cut text, press Ctrl+Y.
- To reverse a recent change, press Ctrl+X and then U.
- To save your modifications, hit Ctrl+X followed by Ctrl+S.
Tip 4: Exiting Emacs Successfully
- To close Emacs, simply press Ctrl+X followed by Ctrl+C.
- 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.
- Open the bashrc file in Emacs using the below command:
emacs -nw ~/.bashrc
The -nw flag allows you to open Emacs in the terminal instead of in the GUI mode.
- At the end of the file, add the following line:
export EDITOR="/usr/local/bin/emacs -nw"
- 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.
- 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.