An executable named healthcheck is in the current directory.
The current directory is not included in PATH.
The current directory is neither the root nor the home directory. There is no healthcheck alias, shell function, or cached command; explicitly execute this ordinary executable file.
Which invocation is correct?
When a command contains a slash, Bash executes the specified path instead of searching PATH. ./ denotes the current directory.
Detailed explanation
healthcheckIncorrect. Without a slash Bash searches PATH and will not find the current directory here.
A bare name does not explicitly select the current file. It may run another executable on PATH, or ordinarily fail to find one if none exists.
/healthcheckIncorrect. /healthcheck refers to a file at the filesystem root.
A leading slash selects the filesystem root. The stated current directory is elsewhere, so this path does not specify the target here.
~/healthcheckIncorrect. ~/healthcheck refers to a file in the home directory, not the current directory.
The leading tilde selects the home directory. The stated current directory is not home, so this is not equivalent to ./healthcheck.
./healthcheckCorrect. ./healthcheck explicitly names the executable in the current directory.
The ./ prefix explicitly selects the current path. A command name containing a slash bypasses PATH lookup; executable permissions and a usable interpreter remain separate prerequisites.
Try it yourself
An example you can run in a temporary verification environment.
LAB_DIR=$(mktemp -d) || exit 1
(
cd "$LAB_DIR" || exit 1
mkdir search || exit 1
printf '#!/bin/sh\nprintf "CURRENT\\n"\n' > healthcheck
printf '#!/bin/sh\nprintf "SEARCH\\n"\n' > search/healthcheck
chmod u+x healthcheck search/healthcheck || exit 1
(
PATH="$LAB_DIR/search"
hash -r
healthcheck
./healthcheck
)
rm -- healthcheck search/healthcheck
rmdir -- search
)
rmdir -- "$LAB_DIR"Official references
- Official documentation 1
- Official documentation 2
- Official documentation 3
- Official documentation 4
- Official documentation 5
Expected result
SEARCH
CURRENTKey points
- PATH lookup
- The relative path ./
- Execute permission
Notes
- Environment: Bash 5.2 / GNU coreutils / /bin/sh in a new temporary directory. The comparison PATH and hash changes stay in an inner subshell; HOME is unchanged.
- Temporary-directory creation and cd are checked before creating fixtures. All created names stay inside the newly created directory; cleanup is nonrecursive.
- The additional executable on the comparison PATH deliberately shows why a bare name does not select the current file. Existing HOME and PATH values are not modified.
Foundation review
Use distinct outputs to identify the selected executable
The verification creates two executables with the same name. The PATH search prints SEARCH, while ./healthcheck prints CURRENT, exposing a difference that identical outputs could hide.
Home and current directory are different concepts
If the current directory were home, the tilde path could name the same file. The question excludes home and root so its alternatives have a stable meaning.
Keep the comparison environment local
Only an inner subshell changes PATH and its command hash. The outer subshell retains normal cleanup commands, and removes only the created files and empty directories.