LinuxHigh

Git command not found in Linux: causes and 3 ways to fix

This article helps solve the common 'git: command not found' error in Linux. You'll learn why the system can't find the git command and get three proven ways to fix the issue: from simple installation to environment variable configuration.

Updated at February 15, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04+Debian 11+CentOS 8+Fedora 35+Arch Linux

What the git: command not found Error Means

The git: command not found (or bash: git: command not found) error appears in a Linux terminal when the system cannot find the git executable file in the directories specified in the PATH environment variable. This means that either Git is not installed on the system, or it is installed but its path is not added to PATH, or there are permission issues.

Typically, the error looks like this:

$ git clone https://github.com/user/repo.git
bash: git: command not found

Or (in Zsh):

zsh: command not found: git

Common Causes

  1. Git is not installed — the most common reason. In a fresh Linux installation (especially minimal distributions), Git is often absent by default.
  2. Git's path is not added to PATH — Git is installed in a non-standard location (e.g., /usr/local/bin), and that directory is missing from the PATH variable.
  3. Corrupted Git installation — Git files were deleted or partially corrupted.
  4. Insufficient execution permissions — your user does not have permission to execute the git file (rare, but possible with manual installation).
  5. Shell configuration error — there are incorrect modifications in ~/.bashrc, ~/.profile, or ~/.zshrc that have broken the PATH.

If Git is not installed, the simplest way is to install it using your distribution's built-in package manager.

For Ubuntu/Debian and derivatives:

sudo apt update
sudo apt install git

For Fedora/RHEL/CentOS 8+:

sudo dnf install git

For CentOS 7 and older, use yum instead of dnf.

For Arch Linux:

sudo pacman -S git

Verify the installation:

After installation, check that the command is available:

git --version

Example output: git version 2.43.0.

Solution 2: Add Git's Path to the PATH Variable

If Git is already installed (check with which git), but the command is not found, its directory is most likely missing from PATH.

  1. Find the location of the git executable:
    sudo find / -type f -name git 2>/dev/null | head -10
    

    Typically, git is located in /usr/bin/git, /usr/local/bin/git, or /opt/git/bin/git.
  2. Identify the directory containing git (e.g., /usr/local/bin).
  3. Add this directory to PATH in your shell's configuration file.
    • For Bash (the standard shell in most distributions), edit ~/.bashrc:
      echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
      
      Replace /usr/local/bin with your actual directory.
    • For Zsh, edit ~/.zshrc:
      echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
      
  4. Apply the changes:
    source ~/.bashrc   # or source ~/.zshrc
    
  5. Verify:
    echo $PATH
    which git
    

💡 Tip: Ensure the directory is added at the beginning of PATH (as in the example above) if you want your version of git to take priority over the system version.

Solution 3: Check and Fix Permissions

If Git is installed in system directories (e.g., /usr/bin), but the command doesn't work due to permissions, do the following:

  1. Check permissions on the git file:
    ls -l $(which git 2>/dev/null || echo "/usr/bin/git")
    

    Example output:
    -rwxr-xr-x 1 root root 12M Jan 15 12:34 /usr/bin/git
    

    Permissions -rwxr-xr-x (755) mean all users can execute the file.
  2. If execution permission (x) is missing, fix it:
    sudo chmod +x $(which git)
    
  3. If the file belongs to another user (unlikely for system packages), check if the installation is corrupted. It's better to reinstall Git (Solution 1).

Prevention

  • Always install Git via your distribution's official package manager. This ensures correct PATH integration and dependency management.
  • Never move or delete Git files manually after installation.
  • When configuring PATH manually, check the syntax and avoid duplicate directories. Use echo $PATH to review the current value.
  • After changes to ~/.bashrc/~/.zshrc, always run source or restart the terminal.
  • Keep Git updated regularly through the package manager (sudo apt upgrade git, sudo dnf update git).

FAQ

What if which git returns nothing, but git --version works?

This may mean git is in a PATH directory, but which doesn't find it due to aliases or functions. Check if git is an alias: type git. If it is an alias, the settings are in ~/.bashrc/~/.zshrc.

Can I install Git only for the current user?

Yes, you can compile from source and install to ~/.local. Then add export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc. But for most users, using the system package manager is simpler.

Why is Git still not found after installing via apt?

This can happen if you use a non-standard shell or a session that doesn't load the profile. Check if ~/.profile or ~/.bashrc is being loaded. You can add the path to ~/.profile (which loads more frequently) or to /etc/profile.d/git.sh for all users.

How to completely remove Git and reinstall?

  • Ubuntu/Debian: sudo apt purge git && sudo apt install git
  • Fedora: sudo dnf remove git && sudo dnf install git
  • Arch: sudo pacman -Rns git && sudo pacman -S git After reinstalling, verify with git --version.

F.A.Q.

Why does 'git: command not found' occur if Git is already installed?
How to check if Git is installed on the system?
Do I need to reboot the system after installing Git?
Can I use Git without installing it system-wide?

Hints

Identify the cause of the error
Install Git via package manager
Add Git path to PATH variable
Check Git file permissions
Restart terminal or reload shell
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community