Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 38 ยท Getting Started

Installing Emacs

Install GNU Emacs on Windows, macOS or Linux, check the version, learn where the init file lives, and start it as a window, in a terminal or as a daemon.

Installing Emacs is easy on every major system. The only choices that matter are which version you get and how you start it. This lesson covers the common installation routes, how to confirm what you have, how Emacs finds its configuration, and the command-line options you will use often.

Which version?

Use a recent stable release. At the time of writing that means Emacs 30 or newer. Older packaged versions (for example Emacs 27 or 28 on long-term-support Linux distributions) still work, but newer ones add features this course mentions: tree-sitter modes (29), the built-in Eglot language-server client (29), use-package built in (29), and better native compilation (28 and up). If your package manager offers only an old version, install a newer one from another source.

Linux

Most distributions package Emacs.

Distribution family Command
Debian, Ubuntu sudo apt install emacs
Fedora sudo dnf install emacs
Arch sudo pacman -S emacs
openSUSE sudo zypper install emacs

The graphical build (GTK) is the default on desktops. Servers often have a -nox variant, for example emacs-nox on Debian, which runs only inside a terminal. Flatpak and Snap packages also exist and are often newer than the distribution version.

macOS

With Homebrew you can run brew install --cask emacs for the standard GUI app. Community builds such as Emacs Plus (brew install emacs-plus, from a third-party tap) and Emacs for Mac OS X offer extra integration. On macOS the Option key is not Meta by default; the next chapters show how to change this.

Windows

You have several routes:

  • Download the official zip from the GNU project's Windows archive (ftp.gnu.org/gnu/emacs/windows), extract it, and run bin\runemacs.exe.
  • Use winget install GNU.Emacs in a terminal.
  • Install it inside MSYS2 or WSL if you prefer a Unix-like environment. WSL users on recent Windows 11 can run graphical Emacs through WSLg.

Windows lacks some Unix tools Emacs likes to call (grep, find, diff, Git). Install Git for Windows, or use WSL, and make sure those tools are on your PATH.

Check what you installed

Open Emacs and run M-x emacs-version (hold Alt and press x, type emacs-version, press Enter). A message shows the version. From a shell, emacs --version prints the same information without opening a window. You can also ask about features:

ELISP
(native-comp-available-p)         ; t if native compilation works
(treesit-available-p)             ; t if tree-sitter support is built in
system-type                       ; gnu/linux, darwin, windows-nt

To evaluate these, paste a line into the *scratch* buffer, put the cursor right after the closing parenthesis (or the variable name) and press C-x C-e.

How Emacs finds its configuration

On startup Emacs looks for an init file and loads the first one it finds, in this order:

  1. ~/.emacs
  2. ~/.emacs.d/init.el
  3. ~/.config/emacs/init.el (supported since Emacs 27, following the XDG standard)

Emacs 27 and later also read an optional early-init.el in the same directory before the graphical interface is created, which is the right place to switch off the menu bar or tool bar without a flash. Most people pick ~/.emacs.d/init.el. Pick one location and stay with it so you never edit a file that Emacs ignores.

JS Stand-in: which init file would load?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The second case shows a common trap: a forgotten ~/.emacs hides your init.el.

Starting Emacs

Command What it does
emacs Open a window (graphical build)
emacs -nw Run inside the terminal, no GUI window
emacs file.txt Open a file
emacs +42 file.txt Open it with the cursor on line 42
emacs -Q Start with no init file and no site files, for a clean test
emacs --debug-init Show a backtrace if your init file has an error
emacs --daemon Start a background server
emacsclient -c file Open a new frame connected to a running server

emacs -Q is the first thing to try when something misbehaves: if the problem disappears, your configuration caused it. The daemon plus emacsclient combination starts a new editing window instantly, because the server has already loaded everything.

JS Stand-in: parse an emacs command line

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Making the shell command short

Many users add alias e='emacsclient -c -a ""' to their shell. The -a "" option starts a daemon automatically if none is running. We return to this in the workflows chapter.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command prints the Emacs version without opening a window?

    emacs --version prints version information and exits.
  2. 2. Which init file does Emacs load first if several exist?

    The search order is ~/.emacs, then ~/.emacs.d/init.el, then ~/.config/emacs/init.el. Only the first found is used.
  3. 3. What does emacs -Q do?

    -Q skips the init file and site startup files.
  4. 4. Why use the daemon with emacsclient?

    A running daemon keeps your configuration and buffers in memory.

Summary

  • Install a recent Emacs (30 or newer if possible) with your package manager, winget, Homebrew or the official Windows zip.
  • M-x emacs-version or emacs --version shows what you have.
  • Emacs loads the first init file it finds: ~/.emacs, ~/.emacs.d/init.el, ~/.config/emacs/init.el.
  • Use -nw for the terminal, -Q to test without configuration, and --daemon with emacsclient for fast new windows.

Next: A Tour of the Emacs Window