Emacs is a powerful and extensible text editor that has been an essential tool for developers and system administrators for decades. In this blog post, we’ll guide you through the process of how to install Emacs on Rocky Linux, a popular Linux distribution that emerged as a community-driven alternative to CentOS.
Table of Contents
- Prerequisites
- Installing Emacs
- Basic Emacs Usage
- Customizing Emacs
- Useful Emacs Extensions
- Conclusion
Prerequisites
Before we begin, ensure you have the following:
- A working Rocky Linux installation. If you’re new to Rocky Linux, check out our guides on how to install Python, how to install Nginx, and how to set up an OpenVPN server.
- Familiarity with the command line and basic Linux commands. If you need a refresher, we have a tutorial on how to change the SSH port on Rocky Linux.
How to Emacs on Rocky Linux
Installing Emacs
To install Emacs on Rocky Linux, follow these simple steps:
- Open your terminal.
- Update your package lists by running:
sudo dnf update
Install Emacs using the following command:
sudo dnf install emacs
Once the installation is complete, you can start Emacs by typing emacs
in the terminal or searching for “Emacs” in your applications menu.
Basic Emacs Usage
Emacs is known for its keyboard shortcuts and extensive customization options. Here are some basic commands to help you get 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.
- C-x u or C-_: Undo the last action.
- C-s: Search for text in the current buffer.
- C-x h: Select all text in the current buffer.
Note: In Emacs, “C” stands for the “Control” key, and “M” stands for the “Meta” key (usually the “Alt” key).
For more advanced usage and tips, refer to the official Emacs manual.
Customizing Emacs
One of the main strengths of Emacs is its ability to be customized to suit your preferences. You can customize Emacs by creating an Emacs Lisp (Elisp) configuration file called .emacs
or init.el
in your home directory.
Here’s an example of a basic configuration file:
;; Set the default font size
(set-face-attribute 'default nil :height 120)
;; Enable line numbers
(global-display-line-numbers-mode t)
;; Set the default theme
(load-theme 'tango-dark t)
Restart Emacs to see the changes take effect. For more customization ideas, check out the Emacs Wiki.
Useful Emacs Extensions
Emacs has a vast ecosystem of extensions called packages that can enhance your experience. Here are some popular and useful packages to get you started:
- Magit: A powerful Git interface for Emacs that makes managing your Git repositories a breeze.
- Helm: An incremental completion and selection narrowing framework that can improve navigation and file management.
- Projectile: A project interaction library that provides easy navigation and management of project files.
- Org-mode: A versatile tool for note-taking, task management, and project planning that can also be used for literate programming and document authoring.
- Flycheck: A modern on-the-fly syntax checking extension that supports multiple programming languages and linters.
To install packages, you can use the built-in package manager called package.el. First, ensure you have the following lines in your configuration file to enable the package manager and use the MELPA repository:
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
Then, restart Emacs and use the following commands to interact with the package manager:
- M-x package-refresh-contents: Update the package list.
- M-x package-list-packages: Display the list of available packages.
- M-x package-install <package-name>: Install a package.
Conclusion
Emacs is an incredibly powerful text editor that can be customized and extended to suit your needs. By following this guide, you should now have a solid foundation for using Emacs on your Rocky Linux system.
To further expand your knowledge of Emacs and explore more advanced features, we recommend diving into the official Emacs manual and exploring the wealth of resources available on the Emacs Wiki.
For more tutorials and guides on Rocky Linux, don’t forget to check out our other articles, such as how to install Vim, how to set up RAID 1 on Rocky Linux, and how to install Ruby on Rocky Linux.