Skip to content
Jenkins: /usr/bin/bash: No such file or directory

Jenkins: /usr/bin/bash: No such file or directory

DodaTech 2 min read

The Jenkins error "/usr/bin/bash: No such file or directory" appears in build logs when a shell step tries to use /usr/bin/bash but the file does not exist on the Jenkins agent.

What It Means

Jenkins executes shell build steps using the path configured in the system — by default /usr/bin/bash. When the agent does not have bash installed at that exact path, the shell step fails immediately.

Why It Happens

  • The Jenkins agent is a minimal container image (e.g., Alpine Linux) that uses /bin/sh instead of /usr/bin/bash.
  • Bash is not installed on the agent machine.
  • The shell path is hardcoded as /usr/bin/bash in the Jenkins node configuration or pipeline.
  • The agent is running on a non-Debian distribution where bash lives at /bin/bash.

How to Fix It

1. Install bash on the agent

Debian / Ubuntu:

sudo apt update && sudo apt install bash -y

Alpine (Docker agents):

apk add bash

CentOS / RHEL / Fedora:

sudo yum install bash -y

2. Configure the correct shell path in Jenkins

Manage Jenkins → Nodes → Select agent → Configure → Set “Shell executable” to:

/bin/bash

3. Check the current shell path

which bash

Expected output: /bin/bash or /usr/bin/bash.

4. Create a symlink if needed

sudo ln -s /bin/bash /usr/bin/bash

FAQ

Why does Jenkins use /usr/bin/bash instead of /bin/sh?
Jenkins defaults to bash because it supports advanced shell features like set -e, source, and arrays that POSIX /bin/sh does not. The path is configurable per node.
Can I use sh instead of bash in my pipeline?
Yes. Use sh 'command' in Declarative Pipeline, or set the shell executable to /bin/sh in node configuration. Note that some syntax may not work in strict POSIX mode.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro