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

#!/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.0Practice node (graded) - spare /dev/sda2 Core4 GB50 GB + 15 GB

This guide includes

Use this before the four scripting objectives, every one of which assumes it. This matters because a script fails three different ways before it ever reaches your code - and each of the three has a different fix.

Before you start

  1. Three ways it fails, and three fixes

  2. The shebang

Official sources