I remember the exact moment terminal productivity tools stopped feeling like a luxury and started feeling essential. I was knee-deep in a production incident, scrolling through hundreds of log files on a server, trying to find the one that held the clue. My find and grep commands were getting longer and uglier. Then a coworker pinged me: “Just pipe it through fzf.” That single suggestion changed how I work on the command line forever. If you want to learn how to use fzf command in Linux, you’re about to discover the same productivity leap I did.
What Is fzf (And Why Every Linux User Needs It)
fzf stands for “fuzzy finder.” It’s an interactive command-line tool that lets you search through any list using approximate (fuzzy) matching. Instead of typing exact filenames or scrolling through endless output, you type a few characters and fzf narrows the results in real time.
The numbers speak for themselves. The official fzf GitHub repository has over 77,000 stars. That puts it among the most popular CLI tools ever built. Created by Junegunn Choi, fzf has earned a loyal following because it does one thing brilliantly: it makes finding stuff fast.
“If you spend a lot of time on the terminal, fzf can really change the way you work and make you much more productive.”
— FreeCodeCamp Developer Guide
Here’s the key difference. With the traditional find command, you need to know exactly what you’re looking for. With fzf, you just need to roughly remember it. Type “confnginx” and fzf will match config/nginx.conf. That fuzzy matching saves you from typos, forgotten paths, and the mental overhead of remembering exact names.
Get a VPS from as low as $11/year! WOW!
Installing fzf on Linux
Getting fzf installed takes about two minutes. If you’re new to installing software on Linux, don’t worry. There are a few paths depending on your distro.
Installing on Ubuntu/Debian
sudo apt install fzf
This gets you fzf from your distro’s repositories. It works, but the version might lag behind the latest release.
Installing on Arch Linux
sudo pacman -S fzf
Arch keeps packages pretty current, so this is usually close to the latest version. And yes, I use Arch, by the way. I had to say it at least once.
For more details on Arch-specific setup, check the Arch Wiki fzf documentation.
Installing from Git (All Distros)
For the latest features, install directly from Git:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
The install script asks if you want to enable shell integration (key bindings and fuzzy completion). Say yes. This is what unlocks the real power of fzf.
Quick Tip: Always Run the Install Script
Even if you install fzf through a package manager, run ~/.fzf/install afterward. Without this step, you won’t get the key bindings that make fzf truly useful. This script adds the necessary lines to your .bashrc or .zshrc.
Understanding fzf Basics: Your First Fuzzy Search
At its core, fzf reads a list from standard input and writes your selection to standard output. That simplicity is what makes it so powerful. It plugs into any Unix pipeline.
Run fzf by itself in a terminal. It will index all files under the current directory and let you search through them interactively. Start typing, and the list shrinks in real time.
# Find a file in your current directory
fzf
# Pipe any list through fzf
cat /etc/passwd | fzf
# Use fzf with find
find /var/log -name "*.log" | fzf
The fuzzy matching algorithm is smart. You don’t need to type characters in order. Searching for “sshcnf” will match ssh_config. This is a massive upgrade over the grep command for text searching, which requires exact patterns.
When I was still a Windows sysadmin, I used to envy tools like “Everything Search” for instant file lookups. fzf gave me that same feeling on Linux, except it works with anything, not just files.
Essential fzf Key Bindings That Save Hours
Once shell integration is enabled, fzf gives you three key bindings that replace clunky workflows you probably use every day.
CTRL-R: Command History Search
Press Ctrl+R and fzf takes over your shell history search. Instead of cycling through one result at a time, you see your entire history and can fuzzy search through it.
# Press CTRL-R, then type fragments of a past command
# Example: type "docker compose" to find that complex docker command from last week
This alone justified the install for me. I used to dread remembering long commands with specific flags. Now I type two or three words and fzf finds it.
CTRL-T: File Finder
Press Ctrl+T while typing a command, and fzf pops up a file search. Select a file, and its path gets inserted into your command line.
# Start typing a command, then hit CTRL-T
vim [CTRL-T]
# fzf opens, search for a file, press Enter
# Result: vim path/to/selected/file.txt
This replaces the awkward tab-completion dance where you’re guessing directory names. It’s especially helpful when you’re deep in a project with nested folders.
ALT-C: Directory Navigation
Press Alt+C and fzf lists directories under your current path. Pick one, and you cd into it instantly.
# Press ALT-C, search for a directory name
# fzf will cd into your selection
I use this constantly when jumping between project folders. It pairs perfectly with a tmux terminal multiplexer setup where you’re managing multiple sessions.
Advanced fzf Use Cases
The basics are great, but fzf really shines when you combine it with other tools. This is where it goes from “nice utility” to “can’t live without it.”
File Preview with bat Integration
The --preview flag lets you see file contents while you search. Pair it with bat syntax highlighter for color-coded previews:
fzf --preview 'bat --color=always --style=numbers {}'
This turns fzf into a visual file browser. I use this in my homelab all the time when hunting through config files. You see the content before you open anything, which saves a lot of wasted vim sessions.
Git Workflow Automation
Switching Git branches becomes effortless with fzf:
# Interactive branch checkout
git branch | fzf | xargs git checkout
# Browse recent commits
git log --oneline | fzf --preview 'git show {1}'
If you’re already comfortable writing bash scripts, you can wrap these into functions in your .bashrc for one-command access.
Process Management (fzf + ps + kill)
Need to kill a process in Linux but can’t remember the PID? Let fzf find it:
# Interactive process killer
ps aux | fzf | awk '{print $2}' | xargs kill -9
This pipes your process list through fzf, lets you select the offender, extracts the PID with awk command, and kills it. Much faster than squinting at ps aux output.
Integration with ripgrep for Code Search
Combine fzf with ripgrep for interactive code searching:
# Search file contents interactively
rg --line-number . | fzf --delimiter ':' --preview 'bat --color=always --highlight-line {2} {1}'
This is my go-to when I’m digging through a codebase and I half-remember a function name. Where sed text processing handles transformations and grep handles exact searches, fzf + ripgrep gives you the interactive exploration layer.
Configuring fzf: Environment Variables and Options
fzf behavior is controlled through environment variables. Add these to your .bashrc or .zshrc. If you’re not sure how, check out our guide on setting environment variables.
Recommended fzf Configuration
# Use fd instead of find for better performance
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
# Customize fzf appearance
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border --info=inline'
# Better CTRL-T behavior
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# Better ALT-C behavior
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
Notice I’m using fd alternative to find instead of the default find command. fd is roughly 23x faster in benchmarks. On large codebases or deep directory trees, this difference is very noticeable. fzf itself is fast. The bottleneck is almost always the tool feeding it data.
You can also save common fzf patterns as aliases. Our guide on creating command aliases walks through the basics. Here’s a quick example:
# Add to .bashrc
alias preview='fzf --preview "bat --color=always {}"'
alias branches='git branch | fzf | xargs git checkout'
Common fzf Troubleshooting
I’ve helped enough people set up fzf to know where things usually break. Here are the fixes for the most common problems.
- Key bindings not working: Run
~/.fzf/installand restart your shell. If you installed via a package manager, you may need to source the integration script manually. Check if the lines were added to your.bashrcor.zshrc. - Slow performance in large directories: Replace the default
findbackend withfdusingFZF_DEFAULT_COMMAND. This makes a dramatic difference. - Preview not showing: Make sure
bat(orcat) is installed and in your PATH. Test the preview command outside fzf first to isolate the issue. - Custom command errors: Double-check your environment variable syntax. Quotes matter. Export the variable and start a new shell to test.
When I first set up fzf on my Arch system years ago, I spent an embarrassing amount of time wondering why key bindings weren’t working. Turns out I’d installed it with pacman but never ran the shell integration script. Don’t make my mistake. Run that install script.
Making fzf Part of Your Daily Workflow
fzf isn’t just another tool to learn and forget. It’s one of those rare utilities that changes how you think about the command line. Once fuzzy finding clicks, you’ll find yourself piping everything through it.
Start with the three key bindings: Ctrl+R for history, Ctrl+T for files, Alt+C for directories. Use them for a week. Then explore the advanced integrations with bat, ripgrep, and fd. Build a few custom functions. Before long, you’ll wonder how you ever worked without it.
If you’re building out your terminal workflow, I’d suggest pairing fzf with the Vim editor (which has excellent fzf plugins) and setting up scheduled cron jobs for any automation tasks you build around it. You can also explore how fzf fits into Docker command examples for interactively selecting containers.
The terminal is already the most powerful interface on your machine. fzf just makes it faster to navigate. Give it a shot, customize it to fit your workflow, and enjoy the productivity boost.




