emacs — Emacs editor
Linux / Basic Linux commands / emacs.html
A highly extensible text editor and execution environment.
Basic Information
| Command Name | emacs |
|---|---|
| One-line Introduction | A highly extensible text editor and execution environment. |
| Provided by | GNU Emacs |
| Official Documentation | https://www.gnu.org/software/emacs/manual/ |
| Supported Operating Systems | Linux, macOS, BSD, Windows |
| Installation Status | Requires a package |
| Category | Linux basic commands (tags: Linux basic commands (tags: emacs, editor, text, lisp)) |
What is this command?
Emacs is more than a text editor: it is an environment extensible with Lisp, covering file editing, Git, terminals and mail in one interface.
In a terminal, emacs -nw runs without a GUI. The key chord system (C-x, M-x) takes practice, and C-g cancels a pending command.
What problems does it solve?
- Editing configuration files in a terminal
- Extending the editing environment with Lisp
- Using one tool for editing, version control and a terminal
- Editing on remote servers without a GUI
Key features
File editing
Open with emacs FILE, then save and exit.
- When to use: Editing server configuration
- What you get: Syntax highlighting and search are available.
- Limitations: The key bindings take learning.
Terminal mode
The -nw flag runs without a GUI.
- When to use: Over SSH sessions
- What you get: The same environment works remotely.
- Limitations: Some GUI features are unavailable.
Extensibility
Lisp configuration and packages add features.
- When to use: Automating repetitive editing work
- What you get: Workflows can be deeply customized.
- Limitations: Complex configuration carries maintenance cost.
Installation and usage
Check whether it is installed
emacs --version
sudo apt install emacs-nox # Debian/Ubuntu sudo dnf install emacs # Fedora
Real-world examples
Open in terminal
Open a file without a GUI.
emacs -nw /etc/hosts
Run a command
Evaluate a Lisp command at startup.
emacs -nw --eval '(princ "hello")'
Batch mode
Run Lisp without an editor session.
emacs --batch --eval '(princ (+ 1 2))'