Linux User’s Guide: Installing and Using ‘Emacs’
Are you looking to install emacs
on your Linux system? If you’re new to Linux or just haven’t had the need to install emacs
before, it might seem a bit daunting. However, emacs
, like a Swiss Army knife, is a versatile text editor that can significantly boost your productivity. It’s a tool that’s worth learning to install and use. Emacs is even available on most package management systems, making the installation process straightforward once you know the steps.
In this guide, we will walk you through the process of installing Emacs on Linux. We will show you methods for both APT and YUM-based distributions, delve into advanced topics like compiling Emacs from source, installing a specific version, and finally, how to use the Emacs command and ensure it’s installed correctly.
So, let’s dive in and begin installing Emacs on your Linux system!
TL;DR: How Do I Install Emacs on Linux?
You can install Emacs on Debian-based distributions like Ubuntu by running the command
sudo apt-get install emacs
. For RPM-based distributions like CentOS, use the commandsudo yum install emacs
.
# For Debian-based distributions like Ubuntu
sudo apt-get install emacs
# For RPM-based distributions like CentOS
sudo yum install emacs
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'emacs is already the newest version (x.xx.x).'
# '0 upgraded, 0 newly installed, 0 to remove and x not upgraded.'
This is the most straightforward way to install Emacs on Linux, but there’s much more to learn about Emacs and its installation process. Continue reading for a more detailed guide, advanced installation options, and troubleshooting tips.
Table of Contents
- Getting Started with Emacs on Linux
- Installing Emacs from Source
- Installing Specific Versions of Emacs
- Basic Command Usage and Verification
- Exploring Alternative Text Editors: Vim and Nano
- Troubleshooting Common Emacs Installation Issues
- Understanding Text Editors in Linux
- The Relevance of Emacs in Programming and System Administration
- Diving into Emacs Lisp and Emacs Plugins
- Wrapping Up: Installing Emacs Installation on Linux
Getting Started with Emacs on Linux
Emacs is a powerful and versatile text editor that’s especially popular among programmers and system administrators. It’s not just a simple text editor; it’s a complete working environment where you can edit text, browse files, send emails, and even play games. The real power of Emacs lies in its ability to be customized and extended, making it a tool that can adapt to your needs.
Emacs is available in the repositories of most Linux distributions, so you can install it using your distribution’s package manager. In this guide, we’ll cover how to install Emacs using the apt
package manager (used in Debian-based distributions like Ubuntu) and the yum
package manager (used in RPM-based distributions like CentOS).
Installing Emacs with APT
On Debian-based distributions like Ubuntu, you can use the apt-get
command to install Emacs. Here’s how you do it:
# Update the package lists for upgrades and new packages
sudo apt-get update
# Install Emacs
sudo apt-get install emacs
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'emacs is already the newest version (x.xx.x).'
# '0 upgraded, 0 newly installed, 0 to remove and x not upgraded.'
In the above code, the first command updates the list of available packages and their versions, but it does not install or upgrade any packages. The second command installs Emacs.
Installing Emacs with YUM
On RPM-based distributions like CentOS, you can use the yum
command to install Emacs. Here’s how:
# Update the package lists for upgrades and new packages
sudo yum check-update
# Install Emacs
sudo yum install emacs
# Output:
# 'Loaded plugins: fastestmirror, langpacks'
# 'Loading mirror speeds from cached hostfile'
# 'Package emacs-x.xx.x.el7.x86_64 is already installed and latest version'
# 'Nothing to do'
Similar to the apt-get
commands, the first yum
command checks for available updates, and the second command installs Emacs.
By following these steps, you should now have Emacs installed on your Linux system. In the next section, we’ll dive into more advanced installation methods.
Installing Emacs from Source
Installing Emacs from source gives you more control over the installation process, allowing you to install specific versions and customize the build to suit your needs. Here’s how you can do it:
# Download the source code
wget http://ftp.gnu.org/gnu/emacs/emacs-26.1.tar.gz
# Extract the tarball
tar -xvf emacs-26.1.tar.gz
# Change to the extracted directory
cd emacs-26.1
# Configure the build
./configure
# Compile the source code
make
# Install Emacs
sudo make install
This will install Emacs 26.1 on your system. You can replace ‘26.1’ with the version number of your choice.
Installing Specific Versions of Emacs
From Source
As shown in the previous section, you can install a specific version of Emacs by downloading the corresponding source code and compiling it.
Using Package Managers
APT
On Debian-based systems, you can install a specific version of a package using the apt-get
command followed by the package name and the version number. However, the version you want to install must be available in the repositories you have added to your system.
# Install a specific version of Emacs
sudo apt-get install emacs=26.1+1-3.2ubuntu2
YUM
On RPM-based systems, you can use the yum
command to install a specific version of a package. Like with APT, the version must be available in your repositories.
# Install a specific version of Emacs
sudo yum install emacs-26.1-5.el7
These commands will install Emacs version 26.1. Replace ‘26.1’ with the version number of your choice.
Emacs Version Comparison
Version | Key Changes | Compatibility |
---|---|---|
26.1 | Improved support for modules, additional Unicode support | Compatible with all modern systems |
25.2 | New JSON parsing library, enhanced network security | Compatible with all modern systems |
24.5 | Last release with Windows XP support, bug fixes | Compatible with older systems |
Basic Command Usage and Verification
Using Emacs
After installing Emacs, you can start it by simply typing emacs
in your terminal. This will open Emacs in your terminal window.
# Start Emacs
emacs
Verifying the Installation
You can check if Emacs is installed and find the installed version by using the emacs --version
command.
# Check Emacs version
emacs --version
# Output:
# 'GNU Emacs 26.1'
This will display the version of Emacs that is currently installed on your system. In this case, it’s version 26.1.
Exploring Alternative Text Editors: Vim and Nano
While Emacs is a powerful and versatile text editor, it’s not the only option available for Linux users. There are other text editors like Vim and Nano that you might find more suitable depending on your needs and preferences.
Vim: The Programmer’s Editor
Vim, also known as Vi IMproved, is a highly configurable text editor built to enable efficient text editing. It’s an improved version of the vi editor distributed with most UNIX systems.
# Install Vim on Debian-based distributions
sudo apt-get install vim
# Install Vim on RPM-based distributions
sudo yum install vim
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'vim is already the newest version (x.xx.x).'
# '0 upgraded, 0 newly installed, 0 to remove and x not upgraded.'
Vim is known for its keyboard shortcuts which can make text editing very efficient once you get the hang of it. However, Vim has a steep learning curve and might not be the best choice for beginners.
Nano: The Beginner’s Editor
Nano is a simple and easy-to-use text editor for Unix-like operating systems. It’s designed to be a free replacement for the Pico text editor, part of the Pine email suite from The University of Washington.
# Install Nano on Debian-based distributions
sudo apt-get install nano
# Install Nano on RPM-based distributions
sudo yum install nano
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'nano is already the newest version (x.xx.x).'
# '0 upgraded, 0 newly installed, 0 to remove and x not upgraded.'
Nano is much simpler and easier to use than either Emacs or Vim, making it a great choice for beginners. However, it doesn’t offer as many features or as much flexibility as Emacs or Vim.
Emacs, Vim, or Nano: Which Should You Choose?
The choice between Emacs, Vim, and Nano largely comes down to personal preference. If you want a simple, easy-to-use editor, Nano might be the best choice. If you want a highly configurable editor and don’t mind a steep learning curve, Vim could be the right choice. Finally, if you want a powerful, versatile editor that’s also highly customizable, you might prefer Emacs.
Regardless of which editor you choose, remember that the key to mastering any text editor is practice. Spend some time getting to know your chosen editor, learn its shortcuts, and customize it to suit your workflow.
Troubleshooting Common Emacs Installation Issues
Installing Emacs on Linux is usually a straightforward process, but like with any software installation, you might encounter some issues. Here are a few common problems and their solutions.
Issue: Package Not Found
If you get a ‘package not found’ error when trying to install Emacs, it’s likely that your package lists are out of date or Emacs is not available in the repositories you have added to your system.
# Update the package lists for upgrades and new packages
sudo apt-get update
# Or for RPM-based distributions
sudo yum check-update
# Output:
# 'Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease'
# 'Reading package lists... Done'
Running these commands updates the list of available packages and their versions. After running these commands, try installing Emacs again.
Issue: Insufficient Permissions
If you get a ‘permission denied’ error when trying to install Emacs, it’s likely that you’re not running the command as root. Most package managers require root privileges to install packages. You can get root privileges by using the sudo
command.
# Install Emacs with root privileges
sudo apt-get install emacs
# Or for RPM-based distributions
sudo yum install emacs
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'emacs is already the newest version (x.xx.x).'
# '0 upgraded, 0 newly installed, 0 to remove and x not upgraded.'
Issue: Out of Disk Space
If you get an ‘out of disk space’ error when trying to install Emacs, you’ll need to free up some space on your system. You can do this by removing unnecessary files and uninstalling programs you no longer need.
# Check disk space
df -h
# Output:
# 'Filesystem Size Used Avail Use% Mounted on'
# '/dev/sda1 30G 27G 1.2G 96% /'
This command displays the amount of disk space used and available on your system. If your disk is nearly full, consider freeing up some space.
Remember, the key to successful troubleshooting is to read the error messages carefully, understand what they’re saying, and take appropriate action.
Understanding Text Editors in Linux
Text editors are an essential part of every Linux user’s toolkit. They allow you to create and modify text files, write and edit code, and perform a variety of other tasks. In the Linux world, there’s a wide range of text editors to choose from, each with its own unique features and advantages.
Emacs: More Than Just a Text Editor
Emacs stands out from other text editors due to its extensive features and capabilities. It’s not just a text editor – it’s a complete working environment. With Emacs, you can write and edit code, read emails, browse the web, and even play games, all without leaving the editor.
Emacs is built on a core of Emacs Lisp (Elisp), a powerful programming language that allows you to customize and extend the editor to suit your needs. This extensibility is one of the key reasons why Emacs is so popular among programmers and system administrators.
# Start Emacs
emacs
# Output:
# Emacs will open in a new window
When you run the emacs
command, Emacs starts in a new window. You can then use the menu and toolbar to perform tasks, or you can use keyboard shortcuts for faster operation.
Why Choose Emacs?
Emacs offers a number of features that set it apart from other text editors:
- Extensibility: Emacs is built on Elisp, which allows you to customize and extend the editor.
- Versatility: Emacs can handle all kinds of text editing tasks, from writing code to reading emails.
- Efficiency: Emacs has a wide range of keyboard shortcuts that allow you to work quickly and efficiently.
Emacs is more than just a text editor – it’s a powerful tool that can help you work more efficiently and effectively. Whether you’re a programmer, a system administrator, or just someone who needs to edit text files on a regular basis, Emacs has something to offer you.
The Relevance of Emacs in Programming and System Administration
Emacs is not just a text editor; it’s a complete development environment that can significantly improve your productivity, whether you’re a programmer or a system administrator. Emacs provides a wide range of features like syntax highlighting, auto-completion, and version control integration that can make coding more efficient.
# Start Emacs with a specific file
emacs /path/to/your/file
# Output:
# Emacs will open the specified file in a new window
The above command opens a specific file in Emacs. Emacs will highlight the syntax of the file based on its type, making it easier to read and understand the code.
Diving into Emacs Lisp and Emacs Plugins
Emacs is built on a core of Emacs Lisp (Elisp), a powerful programming language that you can use to customize and extend Emacs. With Elisp, you can write your own functions, create custom key bindings, and even modify the behavior of Emacs itself.
;; Define a custom function
(defun hello-world ()
"Print Hello, World!"
(interactive)
(message "Hello, World!"))
;; Call the custom function
M-x hello-world
;; Output:
;; 'Hello, World!'
In the above code, we define a custom function hello-world
that prints ‘Hello, World!’ when called. We then call the function using M-x
, which is the key binding for executing extended commands in Emacs.
Emacs also supports plugins, which are packages of code that extend the functionality of Emacs. There are plugins for almost everything, from web development to scientific computing.
# List installed packages
M-x list-packages
# Output:
# A list of installed packages will be displayed in a new window
The above command lists all the packages that are currently installed in your Emacs environment. You can install new packages, update existing ones, and remove packages you no longer need.
Further Resources for Mastering Emacs
- GNU Emacs Manual: The official manual for GNU Emacs, covering everything from basic usage to advanced customization.
EmacsWiki: A community-driven site with a wealth of information about Emacs, including tips, tutorials, and examples of Elisp code.
Mastering Emacs: A comprehensive guide to Emacs, covering everything from basic commands to advanced topics like Elisp programming and Emacs plugins.
Wrapping Up: Installing Emacs Installation on Linux
In this comprehensive guide, we’ve journeyed through the process of installing Emacs, a versatile text editor, on Linux systems. We’ve covered the process for both APT and YUM-based distributions, including Debian, Ubuntu, CentOS, and AlmaLinux. We’ve also delved into more advanced topics such as compiling Emacs from source, installing a specific version, and using the Emacs command correctly.
We began with the basics, explaining how to install Emacs using the apt-get
or yum
commands in different Linux distributions. Then, we ventured into more advanced territory, exploring how to install Emacs from source and how to install specific versions of Emacs. We also discussed alternative text editors like Vim and Nano, comparing their features and installation processes with those of Emacs.
Along the way, we tackled common challenges you might face when installing Emacs, such as ‘package not found’ errors, insufficient permissions, and lack of disk space, providing you with solutions and workarounds for each issue.
Here’s a quick comparison of the text editors we’ve discussed:
Text Editor | Pros | Cons |
---|---|---|
Emacs | Highly customizable, versatile | Steeper learning curve |
Vim | Efficient with keyboard shortcuts | Steep learning curve |
Nano | Easy to use for beginners | Less features compared to Emacs or Vim |
Whether you’re just starting out with Emacs or you’re looking to level up your text editing skills, we hope this guide has given you a deeper understanding of Emacs and its installation process. With its balance of versatility, customizability, and powerful features, Emacs is a valuable tool for any Linux user. Happy coding!