Spell Check Linux Terminal: Does It Work?
In this article
Yes, the Linux terminal has spell-checking capabilities, but not as a single built-in command. Instead, you get a set of tools—aspell, hunspell, and ispell—that check text files, command output, or even your shell commands as you type. The most common approach is piping text into a spell checker or using a shell plugin for real-time suggestions.
What Spell Checkers Exist for the Terminal?
Linux distributions typically offer three main spell-checking programs, each with a different history and focus:
- aspell – Designed as a replacement for ispell, it offers better UTF-8 support and is often the default on many systems. It’s fast and good for interactive use.
- hunspell – The engine behind LibreOffice and Firefox spell check. It handles complex word morphology (like Hungarian or German) better than aspell, and is the best choice for non-English languages.
- ispell – The classic Unix spell checker, still available but less maintained. It’s simple and works, but lacks modern features.
All three are command-line tools, so they integrate well with scripts, editors like Vim or Emacs, and even your shell prompt.
How to Check a File or Text
The most direct way to use spell check in the terminal is to pipe text into one of these tools. For example, to check a file named report.txt with aspell:
- Run
aspell check report.txt– this opens an interactive session where you can accept, replace, or add words to your personal dictionary. - For a non-interactive list of misspelled words, use
aspell list < report.txt– this prints only the words it doesn’t recognize, one per line. - To check command output, pipe it:
cat report.txt | aspell listorecho "Helo world" | aspell list.
With hunspell, the syntax is slightly different: hunspell -l < report.txt lists misspelled words, and hunspell -a enters a pipe mode for use with editors. For ispell, ispell report.txt works like aspell’s interactive mode.
Real-Time Spell Check in the Shell Prompt
If you want spell check as you type commands, you need a shell plugin. The most popular is zsh-syntax-highlighting with its spell-check feature, or the older bash-completion with a spell-check option. However, these only underline or suggest corrections for command names and filenames, not for every word you type. For actual prose, you’d use an editor like Vim (with set spell) or Emacs (with M-x flyspell-mode), which call aspell or hunspell in the background.
To enable spell check in Vim, add set spell spelllang=en_us to your .vimrc. In Emacs, install flyspell and run M-x flyspell-mode. Both highlight misspelled words as you type and offer suggestions via a keybinding.
Choosing the Right Tool for Your Language
Language support is a major factor. Aspell has decent English and many European languages, but its morphology is weak for compound words. Hunspell is the clear winner for languages with complex word formation, like German, Finnish, or Turkish, because it uses the same dictionary format as LibreOffice. If you need a specific language, check if your distribution’s package manager has a dictionary package like hunspell-de-de or aspell-es.
To see which dictionaries are installed, run aspell dump dicts or hunspell -D. You can switch languages with -l (e.g., aspell -l es for Spanish).
Common Problems and How to Fix Them
If the spell checker isn’t working, the usual culprits are:
- Not installed – On Debian/Ubuntu, install with
sudo apt install aspellorsudo apt install hunspell. On Fedora, usesudo dnf install aspell. - No dictionary for your language – Install the matching package, e.g.,
hunspell-frfor French. - Locale issues – The tool may not detect your language. Set the
LANGenvironment variable or pass the language explicitly. - Personal dictionary not saving – Check that your home directory is writable and that the tool’s config file (
~/.aspell.confor~/.hunspell_default) is correct.
For a quick test, run echo "Helo" | aspell list – if it prints Helo, the tool is working. If it prints nothing, either the word is in the dictionary or the tool isn’t set up.
Spell Check in Scripts and Automation
You can use these tools in shell scripts to validate user input or check generated reports. For example, to check for misspelled words in a log file and output them to a separate file:
cat log.txt | aspell list > misspellings.txt
Or to count errors: cat log.txt | aspell list | wc -l. For more advanced use, aspell pipe mode (aspell -a) lets you send lines and get responses, which is how editors integrate it.
Alternatives to Terminal Spell Checkers
If the command-line tools feel limited, consider graphical alternatives that still run on Linux:
- LibreOffice Writer – Has built-in spell check using hunspell, with a GUI for adding words.
- Grammarly for Linux – Available as a browser extension, but not a native terminal tool.
- LanguageTool – An open-source grammar checker that can run locally and has a command-line interface (
languagetool), though it’s heavier than aspell.
For most terminal users, aspell or hunspell is sufficient. They are lightweight, scriptable, and work with any text stream.
Frequently Asked Questions
Does the terminal spell check my commands?
Not by default. The shell itself doesn’t check spelling of commands or arguments. You can enable spellcheck in zsh’s setopt, but it only corrects command names, not options or filenames. For prose, you need an editor or a pipe to aspell/hunspell.
How do I add a word to the dictionary?
In aspell’s interactive mode, pressing a adds the word to your personal dictionary (~/.aspell.en.pws). For hunspell, you can create a file ~/.hunspell_default and add words one per line, then use -p to point to it.
Which is better: aspell or hunspell?
For English, aspell is often faster and simpler. For languages with complex morphology or if you need compatibility with LibreOffice dictionaries, hunspell is better. Try both and see which handles your text correctly.
Can I use spell check in Vim or Nano?
Vim has built-in spell check (:set spell). Nano does not have a built-in spell check, but you can invoke aspell from within Nano by pressing Ctrl+T if you have the speller option set in your .nanorc.
Is there a way to check spelling in a PDF or Word document from the terminal?
Not directly. You’d need to extract text first using tools like pdftotext or docx2txt, then pipe the output to aspell or hunspell. For example: pdftotext file.pdf - | aspell list.