CertGrid CertGrid
Hands-on Lab·Red Hat Certified System Administrator

Running Shell Scripts

Not an objective on its own, and assumed by all four that are. Three things stop a new script running and all three are demonstrated: no execute bit, the current directory not being on `PATH`, and the shebang.

Shell Scripts Guide 61 of 67 Beginner

Written against the versions above. `#!/usr/bin/bash` and `#!/bin/bash` both work on RHEL - `/bin` is a symlink to `/usr/bin`. `#!/bin/sh` is a *different* request: it asks for POSIX shell behaviour, and bashisms like `[[ ]]` may not work under it.

Every command on this page runs on RHCSA-A01.
Server NameIP AddressOSRolesCPURAMHDD
RHCSA-A01192.168.0.31RHEL 10.0 (Coughlan)Practice node (graded) - spare /dev/sda2 Core4 GB50 GB + 15 GB

Before you start

  1. Three ways it fails, and three fixes

  2. The shebang

Official sources