Skip to content
Learn Netverks

Lesson

Step 6/36 17% through track

hello-world-bash

Hello, World in Bash

Last reviewed May 28, 2026 Content v20260528
Track mode
none
Means
Read / quiz
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Hello, World in Bash: the syntax, patterns, and safety habits you need before advancing in Bash.

Teams still ship Hello, World in Bash in Bash codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Hello, World in Bash in contexts like: CI jobs, server maintenance, local dev automation, and Git hooks.

Read each lesson, copy bash examples into your own terminal, and complete the lesson MCQs—there is no in-browser runner for security reasons. Also practice in a dedicated folder; run bash --version to confirm your shell.

When you can explain the previous lesson's ideas without copying starter code.

The smallest Bash program is often a one-liner using echo. Unlike Python print(), the shell expands variables before external commands run.

One-liner

echo "Hello, World"

echo writes arguments to stdout, separated by spaces, followed by a newline.

Script file

#!/usr/bin/env bash
echo "Hello, World"

Save as hello.sh, make executable, run:

chmod +x hello.sh
./hello.sh

Shebang explained

#!/usr/bin/env bash finds bash on PATH—more portable than hard-coding /bin/bash on mixed systems.

Important interview questions and answers

  1. Q: What does echo do?
    A: Writes arguments to standard output; the shell performs variable expansion first.
  2. Q: Why chmod +x?
    A: The kernel needs execute permission to run a file as a program (when invoked by path).

Self-check

  1. Which command prints text in these examples?
  2. What does the shebang line tell the OS?

Challenge

Hello script locally

  1. Save the shebang example as hello.sh.
  2. Run chmod +x hello.sh then ./hello.sh.
  3. Also try bash hello.sh without execute bit.

Done when: both invocation styles print Hello, World.

Interview prep

echo vs printf?

echo is simple; printf offers finer format control for scripts.

chmod +x why?

Grants execute permission so ./script can run the shebang interpreter.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • echo vs printf?
  • chmod +x when?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump