RHEL BasedRocky Linux

How To Install Emacs on Rocky Linux 10

Install Emacs on Rocky Linux 10

Emacs stands as one of the most powerful and extensible text editors available in the Linux ecosystem. For Rocky Linux 10 users seeking a robust development environment, installing Emacs opens doors to unparalleled customization and productivity. This comprehensive guide walks you through multiple installation methods, ensuring you can choose the approach that best fits your specific needs and system requirements.

Rocky Linux 10, being a downstream rebuild of Red Hat Enterprise Linux, provides enterprise-grade stability while maintaining compatibility with modern development tools. Whether you’re a system administrator managing server configurations, a developer working on complex codebases, or a power user seeking advanced text editing capabilities, Emacs on Rocky Linux 10 delivers exceptional performance and reliability.

The installation process varies depending on your preferences for package management, system integration, and maintenance requirements. This guide covers three primary installation methods: DNF package manager installation for simplicity, Snap package installation for the latest features, and source compilation for maximum customization. Each method offers distinct advantages, and understanding these differences ensures you make the optimal choice for your workflow.

Table of Contents

Prerequisites and System Preparation

Before beginning the Emacs installation process, proper system preparation ensures a smooth and successful setup. Rocky Linux 10 requires specific system resources and configurations to support Emacs effectively across different installation scenarios.

System Requirements Assessment

Rocky Linux 10 systems need adequate resources to run Emacs efficiently. The minimum hardware specifications include 2GB of RAM, 1GHz processor, and 500MB of available disk space. However, recommended specifications for optimal performance include 4GB of RAM, dual-core processor, and 2GB of disk space, especially when planning to install additional packages and extensions.

Different installation methods have varying disk space requirements. DNF package installation typically requires 200-300MB, while Snap installation may need 400-500MB due to bundled dependencies. Source compilation demands the most space, potentially requiring 1-2GB during the build process, though the final installation footprint remains comparable to other methods.

Pre-installation System Verification

Verify your Rocky Linux 10 installation by checking the system version and ensuring administrative privileges. Execute the following commands to confirm your system status:

cat /etc/rocky-release
whoami
sudo -v

These commands display the Rocky Linux version, current user, and verify sudo access respectively. Proper sudo privileges are essential for package installation and system configuration modifications.

Check for existing Emacs installations to avoid conflicts:

which emacs
rpm -qa | grep emacs

If previous Emacs installations exist, consider removing them before proceeding with the new installation to prevent configuration conflicts and ensure clean setup.

Essential Dependencies and Network Setup

Update your system package database and install essential development tools that may be required regardless of your chosen installation method:

sudo dnf update -y
sudo dnf groupinstall "Development Tools" -y
sudo dnf install curl wget git -y

Network connectivity verification ensures successful package downloads during installation. Test your connection to major repositories:

ping -c 3 dl.rockylinux.org
curl -I https://ftp.gnu.org/gnu/emacs/

These commands confirm repository accessibility and external download capability, preventing installation failures due to network issues.

Understanding Emacs Installation Options

Rocky Linux 10 offers multiple pathways for installing Emacs, each with distinct characteristics that cater to different use cases and preferences. Understanding these options helps you select the most appropriate method for your specific requirements and long-term maintenance strategy.

Available Installation Methods Overview

The DNF package manager approach provides the most straightforward installation experience, leveraging Rocky Linux’s native package management system. This method ensures proper integration with system libraries, automatic dependency resolution, and seamless updates through the standard system maintenance workflow. DNF installation typically provides stable, well-tested versions that align with Rocky Linux’s enterprise-focused stability philosophy.

Snap package installation offers access to more recent Emacs versions with automatic updates and sandboxed security. Snap packages bundle all dependencies, reducing conflicts with system libraries while potentially increasing disk usage. This method appeals to users prioritizing access to cutting-edge features and simplified maintenance procedures.

Source compilation provides maximum flexibility and customization opportunities. This approach allows fine-tuning compilation options, enabling specific features, and building optimized binaries for particular hardware configurations. Source compilation requires more technical expertise but delivers unmatched control over the final installation.

Emacs Variants and Package Options

Rocky Linux 10 repositories include several Emacs variants designed for different use cases. The standard emacs package provides full GUI support with X11 integration, suitable for desktop environments and graphical development workflows. This variant includes comprehensive features for modern development practices.

The emacs-nox package offers a terminal-only version, ideal for server environments and headless systems. This variant reduces system resource requirements while maintaining full text editing capabilities, making it perfect for remote administration and minimal installations.

Additional packages extend Emacs functionality through language-specific modes, development tools, and integration libraries. These supplementary packages enhance productivity for specific programming languages and development frameworks commonly used in enterprise environments.

Choosing the Right Installation Method

Select DNF installation when prioritizing system stability, enterprise compliance, and integration with existing package management workflows. This method suits production environments where consistency and predictability outweigh access to cutting-edge features.

Choose Snap installation for development workstations where access to recent Emacs versions and automatic updates provide significant value. This approach works well for users comfortable with container-based applications and those requiring minimal maintenance overhead.

Opt for source compilation when specific customization requirements, performance optimization, or access to development versions justify the additional complexity. This method appeals to advanced users and specialized deployment scenarios requiring tailored configurations.

Method 1: Installing Emacs via DNF Package Manager

The DNF package manager represents the most streamlined approach to installing Emacs on Rocky Linux 10, leveraging the distribution’s native package management infrastructure for reliable and integrated deployment.

System Update and Repository Preparation

Begin by updating your system to ensure access to the latest package definitions and security patches:

sudo dnf clean all
sudo dnf update -y
sudo dnf makecache

These commands clear cached package data, update installed packages, and rebuild the package cache. This process ensures your system has access to the most current Emacs packages available in the Rocky Linux repositories.

Verify repository configuration and network connectivity:

sudo dnf repolist enabled
sudo dnf search emacs

The repolist command displays active repositories, while the search command confirms Emacs package availability. These verification steps prevent installation failures due to repository misconfigurations.

Standard Emacs Installation Process

Install Emacs using the DNF package manager with the following command:

sudo dnf install emacs -y

This command downloads and installs the complete Emacs package along with all required dependencies. The installation process typically takes 2-5 minutes, depending on your internet connection speed and system performance.

Monitor the installation progress and verify successful completion:

emacs --version
which emacs
rpm -qi emacs

These commands display the installed Emacs version, executable location, and detailed package information. Successful output confirms proper installation and system integration.

Alternative Package Installation Options

For server environments or systems with limited GUI requirements, install the terminal-only version:

sudo dnf install emacs-nox -y

The emacs-nox package provides full Emacs functionality without X11 dependencies, reducing system resource requirements and eliminating GUI-related potential conflicts.

Install additional Emacs packages for enhanced functionality:

sudo dnf install emacs-common emacs-filesystem -y

These supplementary packages provide common configuration files, documentation, and filesystem structures that enhance the overall Emacs experience.

DNF Installation Verification and Testing

Verify the installation by launching Emacs in different modes:

emacs --version
emacs -nw --eval "(message \"Terminal mode test\")"

These commands confirm version information and test terminal mode functionality. Successful execution indicates proper installation and basic operation capability.

Test GUI mode if installing on a desktop system:

emacs --eval "(progn (message \"GUI test successful\") (kill-emacs))"

This command launches Emacs in GUI mode, displays a test message, and exits automatically. Success confirms complete installation including graphical components.

Method 2: Installing Emacs via Snap

Snap packages provide an alternative installation method that delivers recent Emacs versions with automatic updates and enhanced security through application sandboxing.

Setting Up Snap Package Manager

Rocky Linux 10 requires manual Snap installation as it’s not included by default. Install the snapd package and enable the service:

sudo dnf install snapd -y
sudo systemctl enable --now snapd.socket

Create the necessary symbolic link for classic snap support:

sudo ln -s /var/lib/snapd/snap /snap

This link ensures proper integration with system paths and enables classic confinement for applications requiring deeper system access.

Verify Snap installation and functionality:

sudo snap version
sudo snap find emacs

These commands display Snap version information and search for available Emacs packages in the Snap store.

Installing Emacs Through Snap

Install Emacs using Snap with classic confinement:

sudo snap install emacs --classic

The --classic flag provides Emacs with necessary system access for full functionality, including file system access and integration with system tools.

Monitor installation progress and verify completion:

snap list emacs
/snap/bin/emacs --version

These commands display installed Snap packages and verify Emacs version information. Successful output confirms proper Snap installation.

Snap Package Management and Integration

Configure PATH integration for seamless command-line access:

echo 'export PATH="/snap/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

This configuration ensures Snap-installed applications are accessible from the command line without specifying full paths.

Check automatic update configuration:

snap refresh --list
sudo snap set system refresh.timer=tue,10:00-12:00

These commands display pending updates and configure automatic refresh schedules. Snap’s automatic update feature ensures you receive the latest Emacs versions without manual intervention.

Snap Installation Advantages and Considerations

Snap installation provides several benefits including access to recent Emacs versions, automatic security updates, and application sandboxing. The containerized approach reduces conflicts with system libraries while potentially increasing disk usage and startup times.

Consider performance implications when choosing Snap installation. While generally minimal, some users report slightly longer startup times compared to native package installations. However, the trade-off often justifies the benefits for development workstations requiring cutting-edge features.

Method 3: Compiling Emacs from Source

Source compilation offers maximum customization and control over the Emacs installation, enabling specific feature selection and optimization for particular hardware configurations.

Preparing the Build Environment

Install comprehensive development tools and libraries required for Emacs compilation:

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

These packages provide compilers, development headers, and libraries necessary for building Emacs with full feature support.

Create a dedicated build directory and set up the workspace:

mkdir -p ~/emacs-build
cd ~/emacs-build

Organizing the build process in a dedicated directory simplifies cleanup and troubleshooting if issues arise during compilation.

Downloading and Preparing Source Code

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

wget https://ftp.gnu.org/gnu/emacs/emacs-30.1.tar.gz
wget https://ftp.gnu.org/gnu/emacs/emacs-30.1.tar.gz.sig

Verify the download integrity using the provided signature file:

gpg --verify emacs-30.1.tar.gz.sig emacs-30.1.tar.gz

Extract the source archive and navigate to the source directory:

tar -xzf emacs-30.1.tar.gz
cd emacs-30.1

Configuration and Compilation Process

Configure the build with appropriate options for Rocky Linux 10:

./configure --with-modules --with-x-toolkit=gtk3 --with-xwidgets

These options enable module support, GTK3 toolkit integration, and web widget functionality. Customize options based on your specific requirements and intended use cases.

Review the configuration summary and address any missing dependencies:

make -j$(nproc)

The compilation process utilizes all available CPU cores for optimal build speed. Compilation typically takes 10-30 minutes depending on system specifications.

Installation and System Integration

Install the compiled Emacs binary and associated files:

sudo make install

This command installs Emacs to the default system locations, typically /usr/local/bin for executables and /usr/local/share for data files.

Verify successful installation and create necessary desktop integration:

/usr/local/bin/emacs --version
sudo cp /usr/local/share/applications/emacs.desktop /usr/share/applications/

These steps confirm proper installation and enable desktop environment integration for GUI access.

Post-Compilation Configuration

Update system PATH to prioritize the compiled version:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Configure dynamic linker to recognize locally compiled libraries:

sudo ldconfig

This ensures proper linking of shared libraries and prevents runtime loading issues.

Post-Installation Configuration and Setup

Proper post-installation configuration optimizes Emacs for your specific workflow and integrates it seamlessly with your Rocky Linux 10 system.

Initial Emacs Configuration

Launch Emacs for the first time to create initial configuration files:

emacs

Emacs creates a .emacs.d directory in your home folder containing configuration files and package installations. This directory serves as the central location for all customizations and extensions.

Install Emacs on Rocky Linux 10

Create a basic configuration file to establish fundamental settings:

cat > ~/.emacs.d/init.el << 'EOF'
;; Basic configuration for Rocky Linux 10
(setq inhibit-startup-message t)
(setq make-backup-files nil)
(global-linum-mode 1)
(setq column-number-mode t)
(setq-default tab-width 4)
EOF

This configuration disables the startup message, prevents backup file creation, enables line numbers, shows column numbers, and sets tab width to 4 spaces.

Package Manager Setup and Essential Packages

Configure package repositories for additional functionality:

emacs --eval "(progn (require 'package) (add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\")) (package-initialize) (package-refresh-contents))"

This command adds the MELPA repository and refreshes the package list, providing access to thousands of community-developed packages.

Install essential packages for development workflows:

emacs --eval "(progn (package-install 'company) (package-install 'magit) (package-install 'which-key) (package-install 'projectile))"

These packages provide auto-completion, Git integration, key binding help, and project management capabilities respectively.

Desktop Environment Integration

Create desktop shortcuts and file associations for improved system integration:

cat > ~/.local/share/applications/emacs-custom.desktop << 'EOF'
[Desktop Entry]
Name=Emacs Text Editor
Comment=Edit text files
Exec=emacs %F
Icon=emacs
Type=Application
MimeType=text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Categories=Development;TextEditor;
StartupNotify=true
EOF

This desktop file enables proper integration with file managers and application menus, supporting various file types commonly edited with Emacs.

Performance Optimization and Customization

Optimize Emacs startup performance by configuring lazy loading and efficient initialization:

cat >> ~/.emacs.d/init.el << 'EOF'
;; Performance optimizations
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024))
(setq package-enable-at-startup nil)
EOF

These settings increase garbage collection threshold, improve process output handling, and defer package loading for faster startup times.

Verification and Testing

Comprehensive testing ensures your Emacs installation functions correctly across different scenarios and integrates properly with your Rocky Linux 10 system.

Installation Verification Procedures

Verify Emacs installation by checking version information and basic functionality:

emacs --version
emacs --batch --eval "(message \"Batch mode test successful\")"

These commands confirm version details and test batch mode operation, ensuring both interactive and non-interactive functionality works correctly.

Test GUI and terminal modes:

emacs -nw --eval "(progn (message \"Terminal mode working\") (sit-for 2) (kill-emacs))"

This command launches Emacs in terminal mode, displays a message, waits 2 seconds, and exits automatically, confirming terminal interface functionality.

Functionality Testing and Feature Verification

Create a test file to verify editing capabilities and syntax highlighting:

cat > test-emacs.py << 'EOF'
#!/usr/bin/env python3
def hello_world():
    print("Hello from Emacs on Rocky Linux 10!")
    
if __name__ == "__main__":
    hello_world()
EOF

Open this file in Emacs and verify syntax highlighting and editing features work correctly.

Test package functionality by verifying installed packages:

emacs --eval "(progn (require 'package) (package-initialize) (message \"Packages: %s\" (mapcar 'car package-alist)) (kill-emacs))"

This command lists installed packages and confirms package management functionality.

Performance Benchmarking

Measure Emacs startup performance:

time emacs --eval "(kill-emacs)"

This command measures the time required for Emacs to start and exit, providing baseline performance metrics for your installation.

Monitor resource usage during operation:

emacs --eval "(progn (message \"Memory: %s\" (memory-usage)) (kill-emacs))"

This provides memory usage information, helping identify potential performance issues or optimization opportunities.

Troubleshooting Common Issues

Effective troubleshooting techniques help resolve installation and configuration problems quickly, ensuring minimal disruption to your workflow.

Installation-Related Problem Resolution

Address package manager errors by checking repository configuration:

sudo dnf repolist --all
sudo dnf clean all && sudo dnf makecache

These commands display repository status and refresh package caches, resolving common DNF-related installation issues.

Resolve dependency conflicts by identifying conflicting packages:

sudo dnf history list emacs
sudo dnf remove --duplicates

These commands show installation history and remove duplicate packages that may cause conflicts.

Runtime and Configuration Issue Diagnosis

Debug Emacs startup problems using verbose output:

emacs --debug-init

This command provides detailed error messages during initialization, helping identify configuration file syntax errors or missing dependencies.

Test minimal configuration to isolate problems:

emacs -Q

The -Q flag starts Emacs without loading any initialization files, helping determine if issues stem from custom configurations or system-level problems.

System Integration Problem Solutions

Fix desktop integration issues by updating desktop database:

sudo update-desktop-database
sudo gtk-update-icon-cache /usr/share/icons/hicolor

These commands refresh desktop environment metadata and icon caches, resolving application menu and icon display problems.

Address font rendering issues by configuring fontconfig:

fc-cache -fv
fc-list : family | grep -i emacs

These commands rebuild font caches and list available fonts, helping resolve display and rendering problems.

Advanced Troubleshooting Techniques

Enable detailed logging for comprehensive problem diagnosis:

emacs --eval "(setq debug-on-error t)" --eval "(setq debug-on-quit t)"

This configuration enables error and quit debugging, providing stack traces and detailed error information for complex issues.

Use system monitoring tools to identify resource-related problems:

top -p $(pgrep emacs)
strace -p $(pgrep emacs)

These commands monitor process resource usage and system calls, helping identify performance bottlenecks or system-level issues.

Best Practices and Maintenance

Implementing proper maintenance procedures ensures your Emacs installation remains secure, performant, and up-to-date throughout its lifecycle.

Configuration Management Strategies

Implement version control for your Emacs configuration:

cd ~/.emacs.d
git init
git add init.el
git commit -m "Initial Emacs configuration"

Version control enables tracking configuration changes, reverting problematic modifications, and sharing configurations across multiple systems.

Create modular configuration files for better organization:

mkdir ~/.emacs.d/config
echo '(load "~/.emacs.d/config/packages.el")' >> ~/.emacs.d/init.el

Modular configurations improve maintainability and make it easier to share specific functionality with other users.

Update and Maintenance Procedures

Establish regular update schedules based on your installation method:

For DNF installations:

sudo dnf update emacs

For Snap installations:

sudo snap refresh emacs

For source installations, monitor the GNU Emacs website for new releases and rebuild as needed.

Security Considerations and Best Practices

Regularly audit installed packages and remove unnecessary extensions:

emacs --eval "(progn (require 'package) (package-initialize) (message \"Installed packages: %s\" (length package-alist)) (kill-emacs))"

Monitor package sources and verify package integrity before installation to prevent security vulnerabilities.

Configure automatic backups for important configuration files:

cp ~/.emacs.d/init.el ~/.emacs.d/init.el.backup.$(date +%Y%m%d)

Performance Monitoring and Optimization

Implement performance monitoring to identify degradation over time:

emacs --eval "(progn (benchmark-init/activate) (message \"Benchmarking enabled\"))"

Regular performance monitoring helps identify packages or configurations that negatively impact startup time or runtime performance.

Advanced Integration and Workflows

Maximizing Emacs productivity involves integrating it with development tools, system administration workflows, and automation processes commonly used in Rocky Linux environments.

Development Environment Integration

Configure Emacs for software development with version control integration:

cat >> ~/.emacs.d/init.el << 'EOF'
;; Development configuration
(require 'magit)
(global-set-key (kbd "C-x g") 'magit-status)
(setq vc-follow-symlinks t)
EOF

This configuration enables Git integration through Magit and configures automatic symlink following for version-controlled files.

Set up language-specific development environments:

emacs --eval "(progn (package-install 'python-mode) (package-install 'go-mode) (package-install 'rust-mode))"

These packages provide syntax highlighting, indentation, and development tools for Python, Go, and Rust programming languages commonly used in modern software development.

System Administration Applications

Configure Emacs for system administration tasks:

cat >> ~/.emacs.d/init.el << 'EOF'
;; System administration configuration
(require 'tramp)
(setq tramp-default-method "ssh")
(global-set-key (kbd "C-c C-s") 'shell)
EOF

This configuration enables remote file editing through TRAMP and provides convenient shell access for system administration tasks.

Automation and Scripting Integration

Integrate Emacs with system automation tools:

cat >> ~/.emacs.d/init.el << 'EOF'
;; Automation integration
(setq auto-save-default t)
(setq auto-save-timeout 30)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
EOF

This configuration enables automatic saving and makes script files executable automatically, streamlining automation workflow development.

Congratulations! You have successfully installed Emacs. Thanks for using this tutorial for installing GNU Emacs on your Rocky Linux 10 system. 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