Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code: Skills Get Started
FAQ’s Sections
Linux Virtual Servers

How to Install and Use fzf on Linux: The Complete Guide to Fuzzy Finding in the Terminal

If you spend significant time in the Linux terminal, you already know that finding files, recalling commands, and navigating directories can slow you down. fzf (Fuzzy Finder) is a blazing-fast, interactive command-line tool that eliminates that friction entirely. Whether you're filtering thousands of files, searching command history, or switching Git branches, fzf transforms tedious terminal tasks into fluid, near-instant operations.

In this comprehensive guide, you'll learn how to install fzf on Linux, master its core features, integrate it with popular tools, and customize it to fit your exact workflow.

> Running your own Linux environment? A powerful development setup starts with the right infrastructure. AlexHost's VPS Hosting gives you full root access, high-performance SSD storage, and complete freedom to configure your server β€” the ideal foundation for building a productive Linux terminal workflow.

What Is fzf?

fzf is a general-purpose, command-line fuzzy finder written in Go. It reads a list of items from standard input and presents them in a real-time, interactive filtering interface. As you type, fzf narrows down results using a fuzzy-matching algorithm β€” meaning you don't need to type exact strings to find what you're looking for.

Key capabilities of fzf include:

  • File and directory search across large directory trees
  • Command history navigation with instant recall
  • Git branch and commit browsing
  • Process management and interactive killing
  • SSH host selection from your config file
  • Integration with virtually any command that produces line-based output

fzf is lightweight, dependency-free after installation, and works seamlessly with Bash, Zsh, and Fish shells.

Installing fzf on Linux

There are two primary installation methods: cloning the official Git repository or using your distribution's package manager. Both are straightforward.

Installing from the GitHub repository ensures you always get the most up-to-date version.

Step 1 β€” Clone the repository:

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf

Step 2 β€” Run the install script:

cd ~/.fzf
./install

During installation, you'll be prompted with three configuration questions:

  • Enable key bindings? (Recommended: Yes) β€” Adds Ctrl+T, Ctrl+R, and Alt+C shortcuts
  • Enable fuzzy auto-completion? (Recommended: Yes) β€” Enables tab-completion integration
  • Update shell configuration files? (Recommended: Yes) β€” Automatically sources fzf in .bashrc / .zshrc

After installation, reload your shell:

source ~/.bashrc   # For Bash users
source ~/.zshrc    # For Zsh users

Method 2: Install via Package Manager

Package manager installation is faster and integrates with your system's update mechanism, though it may provide a slightly older version.

Ubuntu / Debian:

sudo apt update && sudo apt install fzf

Fedora:

sudo dnf install fzf

Arch Linux / Manjaro:

sudo pacman -S fzf

macOS (Homebrew):

brew install fzf
$(brew --prefix)/opt/fzf/install

Verify your installation:

fzf --version

Basic Usage of fzf

Once installed, fzf is immediately usable. Here are the essential commands to build your foundation.

Launch fzf in your current directory to interactively search files:

fzf

An interactive prompt appears. Begin typing any part of a filename β€” fzf filters results in real time. Use the arrow keys to navigate, and press Enter to select.

Useful navigation shortcuts:

KeyAction
↑ / ↓Navigate results
EnterConfirm selection
TabMark multiple items
Ctrl+C / EscCancel

2. Search Command History

One of fzf's most popular use cases is interactive command history search:

history | fzf

If you enabled key bindings during installation, you can press Ctrl+R at any time in your terminal to trigger this instantly β€” far more powerful than the default reverse-search.

3. Combine fzf with find

Search recursively through your filesystem and pipe results into fzf:

find . -type f | fzf

To search only for directories:

find . -type d | fzf

4. Navigate to a Directory with Alt+C

If you enabled key bindings, pressing Alt+C opens an interactive directory navigator. Select a directory and fzf automatically runs cd to navigate there.

5. Search Git Branches

Quickly find and reference Git branches in large repositories:

git branch | fzf

To check out a branch interactively:

git checkout $(git branch | fzf)

Integrating fzf with Other Commands

fzf's real power emerges when you combine it with other tools using command substitution ($(fzf)).

1. Open a File Directly in vim or nano

vim $(fzf)
nano $(fzf)

Type part of a filename, select it, and the editor opens immediately β€” no need to type the full path.

2. Copy a File Path to the Clipboard

fzf | xclip -selection clipboard

On systems using xsel:

fzf | xsel --clipboard --input

3. Interactive SSH Host Selection

If you manage multiple servers, this integration is a game-changer:

ssh $(grep -i "^Host " ~/.ssh/config | awk '{print $2}' | fzf)

This parses your SSH config file and lets you interactively select a host before connecting β€” no more memorizing hostnames or IP addresses.

> Managing multiple remote servers? AlexHost's Dedicated Servers provide enterprise-grade hardware with full administrative control, making them perfect for teams that rely on SSH-heavy workflows.

4. Kill a Process Interactively

kill -9 $(ps aux | fzf | awk '{print $2}')

List all running processes, fuzzy-search for the one you want, and kill it β€” all without needing to know the PID in advance.

5. Preview File Contents While Searching

fzf supports a --preview flag that displays file contents alongside your search results:

fzf --preview 'cat {}'

For syntax-highlighted previews (requires bat):

fzf --preview 'bat --color=always {}'

Customizing fzf

fzf is extensively configurable through environment variables and shell configuration files.

1. Set Default Options with FZF_DEFAULT_OPTS

Add this to your ~/.bashrc or ~/.zshrc to apply options globally:

export FZF_DEFAULT_OPTS="--height 40% --reverse --inline-info --border"

Common options explained:

OptionDescription
--height 40%Display fzf in the lower 40% of the terminal
--reverseShow results top-to-bottom (input at top)
--inline-infoDisplay match count inline
--borderDraw a border around the fzf window
--multiEnable multi-select with Tab

2. Customize Colors

Match fzf's color scheme to your terminal theme:

export FZF_DEFAULT_OPTS="--color=bg+:#3c3836,bg:#282828,fg:#ebdbb2,fg+:#ebdbb2,hl:#fabd2f,hl+:#fabd2f,info:#83a598,prompt:#bdae93,spinner:#fabd2f,pointer:#83a598,marker:#fe8019,border:#665c54"

This example uses the popular Gruvbox color scheme. Adjust hex values to match your preferred theme.

3. Custom Key Bindings

Add custom bindings to your shell configuration file:

# Ctrl+T β€” fuzzy file finder
export FZF_CTRL_T_COMMAND="find . -type f 2>/dev/null"

# Alt+C β€” fuzzy directory navigator
export FZF_ALT_C_COMMAND="find . -type d 2>/dev/null"

# Ctrl+R β€” command history search with preview
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"

4. Set a Default File Source with FZF_DEFAULT_COMMAND

By default, fzf uses find to list files. You can replace this with faster tools like fd or ripgrep:

# Using fd (faster alternative to find)
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git"

# Using ripgrep
export FZF_DEFAULT_COMMAND="rg --files --hidden --follow --glob '!.git'"

5. Persistent Configuration File

For Zsh users, you can store persistent fzf settings in a dedicated file:

echo "export FZF_DEFAULT_OPTS='--height 40% --reverse --inline-info --border'" >> ~/.fzf.zsh

Ensure this file is sourced in your ~/.zshrc:

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

Practical fzf Workflow Examples

Here are ready-to-use functions you can add to your .bashrc or .zshrc:

Interactive cd with fzf

fcd() {
  local dir
  dir=$(find ${1:-.} -type d 2>/dev/null | fzf +m) && cd "$dir"
}

Open Recent Files in vim

fvim() {
  local file
  file=$(find . -type f -name "*.${1:-*}" | fzf --preview 'cat {}')
  [ -n "$file" ] && vim "$file"
}

Search and Apply Git Stash

fstash() {
  local stash
  stash=$(git stash list | fzf | cut -d: -f1)
  [ -n "$stash" ] && git stash apply "$stash"
}

Troubleshooting Common fzf Issues

ProblemSolution
fzf: command not foundEnsure ~/.fzf/bin is in your $PATH; re-run ~/.fzf/install
Key bindings not workingRe-run the install script and confirm shell config is sourced
Slow performance on large directoriesSet FZF_DEFAULT_COMMAND to use fd or rg instead of find
Colors not displaying correctlyEnsure your terminal supports 256 colors; add --color=always to preview commands
fzf not found after package installRun source ~/.bashrc or open a new terminal session

Why Your Hosting Environment Matters for Developer Productivity

A powerful terminal workflow like fzf is only as effective as the environment it runs in. Slow I/O, limited resources, or restricted permissions can undermine even the best tooling.

  • For developers and sysadmins who need full control, AlexHost's VPS Hosting provides dedicated resources, root access, and the flexibility to install any tool without restrictions.
  • For teams managing web applications, pairing your server with a VPS with cPanel gives you both terminal power and a graphical management interface.
  • For projects requiring a domain and web presence, AlexHost's Domain Registration and Shared Web Hosting offer an affordable, fully managed starting point.

Conclusion

fzf is one of the most impactful tools you can add to your Linux terminal workflow. Its fuzzy-matching algorithm, real-time filtering, and seamless integration with shell commands make it an indispensable productivity multiplier β€” whether you're searching files, recalling commands, managing Git branches, or navigating remote servers.

Key takeaways from this guide:

  • Install fzf via Git clone for the latest features, or use your package manager for simplicity
  • Enable key bindings (Ctrl+T, Ctrl+R, Alt+C) for instant access to fzf's most useful features
  • Combine fzf with vim, ssh, git, kill, and find using command substitution
  • Customize appearance and behavior through FZF_DEFAULT_OPTS and shell configuration
  • Use --preview to turn fzf into a full-featured file browser

Start with the basics, gradually incorporate the integrations that match your workflow, and you'll quickly wonder how you ever managed the terminal without it.

Linux Virtual Servers Windows
Dedicated Servers Virtual Servers
Security Virtual Servers

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code: Skills Get Started
Quick access to information
Quick access to information

Save your time and get a quick answer to your question

Solve problems yourself
Solve problems yourself

The knowledge base contains detailed tutorials, allowing you to handle technical tasks yourself.

Improving skills
Improving skills

By using the knowledge base, you expand your knowledge about web hosting and related topics

Illustrations and diagrams
Illustrations and diagrams

Many articles are accompanied by illustrations and diagrams, making complex processes and settings easier to understand.

Useful Tricks
Useful Tricks

You'll find useful tips and tricks to improve the performance of your site or web application.

Relevance of the given topics
Relevance of the given topics

Information in the knowledge base is regularly updated to reflect the latest changes and trends in the field of IT infrastructure and AlexHost service

Didn’t find the topic you were looking for? There is a perfect solution

Outstanding Guests and Customers! Your convenience is our priority! If you are having difficulty installing any specific software or deploying a server, please do not hesitate to contact us. We value your opinion and are always ready to help you solve your problems.

Moreover, we give you the opportunity to actively participate in the creation of our knowledge base. If you have topics or questions that you would like included in our database, let us know! We are ready to write detailed articles and guides based on your needs.

We strive to make your experience with AlexHost as convenient and efficient as possible, and your contribution to the knowledge base helps us achieve this goal. Contact us ->
info@alexhost.com and let us know how we can make your stay with us even better.

Solution Image