How to Fix the "xxd command not found" Error If you’ve just tried to dump a binary file into a hex representation or reverse a hex dump and were met with the frustrating -bash: xxd: command not found error, you aren't alone.
While xxd is a staple for developers and sysadmins, it isn't always included in the "minimal" installs of modern Linux distributions. Here is the quick guide to getting it back on your system. What is xxd?
xxd is a powerful command-line utility that creates a hex dump of a given file or standard input. It can also convert a hex dump back into its original binary form. It is most commonly distributed as part of the Vim text editor package. Why is it missing?
Most lightweight Docker images (like Alpine or Ubuntu Slim) and "minimal" server installs strip out non-essential utilities to save space. Since xxd is technically a "feature" of Vim, if Vim isn't installed, xxd usually isn't either. How to Install xxd
The installation command depends on which Linux distribution you are using. You will likely need sudo privileges. 1. Ubuntu / Debian / Kali Linux / Linux Mint
On Debian-based systems, xxd is often packaged within vim-common.
sudo apt update sudo apt install xxd # If that doesn't work, install the full vim package: sudo apt install vim Use code with caution. 2. CentOS / RHEL / Fedora / Rocky Linux
Red Hat-based systems usually include it in the standard vim-common or vim-enhanced packages.
sudo dnf install vim-common # Or for older versions: sudo yum install vim-common Use code with caution. 3. Arch Linux
Arch keeps it simple. It is included in the base vim package. sudo pacman -S vim Use code with caution. 4. Alpine Linux
If you are building a Docker container and need xxd, use vim: apk add vim Use code with caution.
xxd comes pre-installed on macOS as part of the Command Line Tools. If it's missing, you likely need to install or reset your Xcode tools: xcode-select --install Use code with caution. Verifying the Installation
Once the installation is complete, verify that the command is working by checking its version: xxd -v Use code with caution. xxd command not found
You should see output similar to xxd 2023-08-28 by Juergen Weigert. Common Alternatives
If you cannot install xxd for some reason (e.g., lack of permissions), most Linux systems have hexdump or od pre-installed: To see hex output: hexdump -C filename To see octal/hex: od -t x1 filename
The "xxd command not found" error is almost always resolved by installing the Vim or Vim-common package. It’s a tiny utility, but it’s an essential part of any developer's toolkit for debugging binary data.
The midnight oil burned low in the dimly lit server room. , a veteran systems administrator, was facing a ghost in the machine. A critical configuration file had been corrupted, and he needed to examine its raw binary structure to find the stray null byte wreaking havoc on the production database.
"Just a quick hex dump," Elias muttered, his fingers dancing across the mechanical keyboard. He typed the familiar command: xxd config_backup.bin
He pressed Enter, expecting a neat grid of hexadecimal values. Instead, the screen spat back a cold, indifferent error: bash: xxd: command not found The Investigation
Elias froze. xxd was the Swiss Army knife of the binary world—a standard utility that should be there by default. He checked his environment, wondering if his PATH had been mangled.
Step 1: He ran echo $PATH. Everything looked normal: /usr/local/bin, /usr/bin, /bin. Step 2: He tried which xxd. Nothing.
Step 3: He checked the OS version. It was a minimal install of CentOS—a "lean and mean" build meant for high performance, but it had been stripped of its essential tools. The ghost wasn't a bug; it was a missing package. The Realisation
In many Linux distributions like Fedora, RHEL, and CentOS, xxd isn't a standalone tool—it is bundled within the vim-common or vim-core packages. The developers of this server image had installed a minimal version of Vim, or perhaps no Vim at all, leaving the system "blind" to binary data. The Resolution
Elias sighed, reaching for the package manager. "If you want a job done right," he whispered, "you have to give the server its eyes back."
He typed the command to summon the missing utility:sudo yum install vim-common How to Fix the "xxd command not found"
The terminal scrolled with progress bars as the system fetched the 700KB package. Once finished, Elias tried again: xxd config_backup.bin | head -n 5
This time, the screen filled with the beautiful, rhythmic rows of hex and ASCII. There it was—at offset 0x000045: a 00 where a 20 should have been. With a quick edit and a restart, the production database hummed back to life. The ghost was gone, and xxd was home. How to Fix "xxd: command not found"
If you find yourself in Elias's shoes, use the command for your specific system: Operating System Command to Install Ubuntu / Debian sudo apt-get install xxd CentOS / RHEL / Fedora sudo yum install vim-common Arch Linux sudo pacman -S vim Fedora CoreOS rpm-ostree install vim-common If you'd like, I can: Show you common xxd commands for debugging files. Explain how to convert a hex dump back into a binary file.
Provide a bash-only alternative if you can't install new packages.
Let me know how you'd like to dive deeper into binary analysis! ubuntu - VS code - xxd: command not found - Stack Overflow
Here’s a write-up explaining the "xxd: command not found" error, its causes, and how to resolve it.
On RHEL-based distributions, xxd is included in the vim-common package.
For Fedora (dnf):
sudo dnf install vim-common
For CentOS 7 / RHEL 7 (yum):
sudo yum install vim-common
For CentOS 8+ / RHEL 8+ (dnf):
sudo dnf install vim-common
After installation, confirm:
which xxd
# Should output: /usr/bin/xxd
Option 1 – Install Vim (includes xxd): On Red Hat / CentOS / Fedora (yum
brew install vim
Option 2 – Install only xxd via MacPorts:
sudo port install xxd
vim-common packageOn Debian-based systems (e.g., Ubuntu):
sudo apt-get update
sudo apt-get install vim-common
On Red Hat-based systems (e.g., CentOS):
sudo yum install vim-common
On macOS (with Homebrew):
brew install vim
Using an administrative PowerShell:
choco install xxd
Since xxd is part of the Vim distribution, installing Vim usually resolves the dependency.
Debian / Ubuntu / Kali Linux:
sudo apt-get update
sudo apt-get install vim-common
# or simply
sudo apt-get install vim
Red Hat / CentOS / Fedora:
sudo dnf install vim-enhanced
# or for older systems
sudo yum install vim-enhanced
Arch Linux / Manjaro:
sudo pacman -S vim
Alpine Linux:
apk add vim
macOS:
xxd is installed by default on macOS. If missing, install via Homebrew:
brew install vim