bat is the modern replacement for cat. Same interface, same pipe behaviour, but with syntax highlighting for hundreds of languages, Git integration that marks added and removed lines in the gutter, line numbers by default, and a sensible pager when output is longer than the terminal. It’s one of those small quality-of-life upgrades that you forget you installed because it feels like cat should have always worked this way. Pair it with ncdu for disk analysis and our systemctl reference for inspecting systemd unit files with color.
This guide installs bat on Rocky Linux 10, AlmaLinux 10, Debian 13, and Ubuntu 24.04, then shows the syntax highlighting, theme selection, and the binary name gotcha on Debian-family distros.
Verified: April 2026 on Rocky Linux 10.1 with bat 0.24.0 from the AppStream repo
Step 1: Install bat
On Rocky Linux 10, AlmaLinux 10, and RHEL 10, bat is in AppStream:
sudo dnf install -y bat
The binary installs as /usr/bin/bat and can be invoked as bat.
On Debian 13 and Ubuntu 24.04, the package is also called bat, but there’s a catch: because the bat name conflicts with an older utility shipped as part of bacula-console, Debian renamed the binary to batcat. Install it the usual way:
sudo apt update
sudo apt install -y bat
Then add an alias in your shell RC file so you can still call it bat:
echo 'alias bat="batcat"' >> ~/.bashrc
source ~/.bashrc
Or, if you prefer a symlink that works in scripts and under sudo:
sudo ln -sf /usr/bin/batcat /usr/local/bin/bat
Verify the install with the version command:
bat --version
The current release in both Debian 13 and Rocky Linux 10 AppStream is:
bat 0.24.0
Step 2: Basic usage
The simplest invocation prints a file with syntax highlighting, line numbers, and a header. Point it at /etc/os-release for a quick sanity check:
bat /etc/os-release
When you’re piping to other commands and want raw output without the header or line numbers, use --paging=never --color=never which effectively reverts to plain cat behaviour:
bat --paging=never --color=never /etc/os-release | head -5
On a Rocky 10.1 machine the first few lines come out exactly like cat would produce:
NAME="Rocky Linux"
VERSION="10.1 (Red Quartz)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="10.1"
Step 3: Language auto-detection
bat detects the language from the filename extension and, when that’s missing, from the shebang line or content. Drop a small Python file into /tmp and view it:
cat > /tmp/test.py <<'EOF'
#!/usr/bin/env python3
def hello():
print("hello world")
EOF
bat /tmp/test.py
The output shows the file with Python syntax highlighting, line numbers, and a header at the top naming the file. If the detection picks the wrong language, force a specific one with -l:
bat -l yaml /etc/ssh/sshd_config
List all supported languages with --list-languages. There are hundreds, from ActionScript to Zig:
bat --list-languages | head -10
The first ten entries of the list include scripting languages, assembly, and config file formats:
ActionScript:as
Ada:adb,ads,gpr
Apache Conf:envvars,htaccess,HTACCESS,htgroups,HTGROUPS,htpasswd,HTPASSWD,.htaccess...
AppleScript:applescript,script editor
ARM Assembly:s,S
AsciiDoc (Asciidoctor):adoc,ad,asciidoc
ASP:asa
Assembly (x86_64):yasm,nasm,asm,inc,mac
Authorized Keys:authorized_keys,pub,authorized_keys2
AWK:awk
Step 4: Themes
bat ships with around 20 color themes. List them with --list-themes and pick one you like. The default 1337 works well on dark terminals. On a light theme terminal, try GitHub or Solarized (light):
bat --list-themes | head -5
The first five themes shipped with bat 0.24:
1337
Coldark-Cold
Coldark-Dark
DarkNeon
Dracula
Set a theme for a single call with --theme:
bat --theme=Dracula /etc/fstab
Or persist it for every call by exporting the BAT_THEME environment variable in your shell RC:
echo 'export BAT_THEME="Dracula"' >> ~/.bashrc
Step 5: Git integration
When you run bat against a file inside a Git working tree, the left gutter shows markers for added, modified, and removed lines compared to the last committed version. This is genuinely useful during code review without leaving the terminal:
cd /path/to/your/repo
# edit some file
echo 'new line' >> README.md
bat README.md
You’ll see a green + in the margin next to the added line. If you committed a change that also modified existing lines, those show up with a yellow bar to indicate a modification.
Step 6: Use bat as your MANPAGER
bat makes an excellent man page reader because the man syntax has its own built-in parser. Export it as your MANPAGER so every man invocation automatically uses colored output:
echo 'export MANPAGER="sh -c '"'"'col -bx | bat -l man -p'"'"'"' >> ~/.bashrc
source ~/.bashrc
man ls
The result: option names are highlighted, examples are colored, and reading long man pages is much less tiring. Section headers stand out and you can scroll back through the pager without losing the formatting.
Wrap up
bat is a 5 MB binary that pays off the first time you need to read a config file. It doesn’t replace cat for every case (scripts that pipe to other tools still want plain cat for speed), but for interactive viewing and as your MANPAGER, it’s an upgrade you’ll stop noticing you made. Pair it with our Zsh and Oh My Zsh guide for a complete modern terminal setup, our sshfs reference for mounting remote filesystems to browse with bat locally, and our Rocky 10 post-install tips which gets bat and friends onto a fresh server.
For a related “modern replacement” upgrade, also see our FFmpeg conversion guide — the same principle applies: a small binary that replaces a half-dozen older tools at once.