LearnThatStack Ace your next interview
DevOps

Bash & Shell Scripting.

Start free Change topic Change
Practice · Questions

All questions

Showing of 40
Beginner 13
01

What is the difference between a shell and a terminal?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A terminal shows text and passes your keystrokes along, while a shell is the command-line interpreter that reads them as commands and runs them. The terminal never works out what ls means.

The shell does that work. It expands variables and wildcards, then starts the programs you asked for. It also manages environment variables and job control.

The two are independent. One terminal can host any shell, and a shell needs no terminal when cron runs a script with it. Common shells include Bash and Zsh. Fish and Dash are two more. Today's terminals are terminal emulators, software versions of the hardware terminals early Unix machines used.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

How do you make a shell script executable?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Run chmod +x script.sh to give the file execute permission, then start it with ./script.sh. The ./ is needed because the shell looks up bare command names only on PATH, which does not normally include the current directory.

chmod +x script.sh
# Or using octal notation
chmod 755 script.sh

+x adds the execute bit and leaves the read and write bits alone. The octal form 755 sets every bit at once. The owner can read, write and execute, and everyone else can read and execute.

The first line of the script should also be a shebang, which tells the kernel which interpreter runs the file.

#!/bin/bash
# or
#!/usr/bin/env bash

Execute permission only matters when you run the file directly. bash script.sh works without it, because Bash is the program being run and it just reads the file as input.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is the purpose of the shebang (#!) line?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The shebang is #! followed by an interpreter's path, and it tells the kernel which program runs the script. It must be the very first line of the file. With #!/bin/bash there, running ./deploy.sh makes the kernel run /bin/bash ./deploy.sh.

Each line below is a separate choice, and a script uses only one.

#!/bin/bash
#!/usr/bin/env bash
#!/bin/zsh
#!/usr/bin/env python3

#!/usr/bin/env bash runs the first bash on PATH, which is more portable than a fixed path. The other two lines choose zsh by a fixed path and python3 through env. Without a shebang, the calling shell runs the file itself, which breaks when the script needs a different shell.

Keep comments off the shebang line. Linux passes everything after the interpreter as one argument, so #!/usr/bin/env bash # comment fails to start.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

How do you declare and use variables in bash?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Assign with name=value, with no spaces around the =, and read the value back with $name or ${name}. The spaces matter, because name = value makes Bash run a command called name with = and value as its arguments.

# Declaration
name="John"
age=25

# Usage
echo "Name: $name, Age: $age"
echo "Name: ${name}, Age: ${age}"  # Preferred syntax

The braces mark where the name ends, so ${name}_backup works where $name_backup would look for a variable called name_backup. Wrap each use in double quotes, as in "$name", so a value with spaces stays one word.

A variable you create stays in the current shell, and programs the script starts do not see it. export passes it to them through the environment. local limits a variable to the function that declares it and the functions that function calls. readonly stops later changes anywhere in the script.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What's the difference between single quotes, double quotes, and backticks?

Part of Pro
06

How do you pass arguments to a shell script?

Part of Pro
07

What are exit codes and how do you use them?

Part of Pro
08

How do you redirect standard output and standard error?

Part of Pro
09

What is the difference between sh and bash?

Part of Pro
10

How do you implement conditional statements in bash?

Part of Pro
11

Explain different types of loops in bash

Part of Pro
12

What are pipes and how do you use them?

Part of Pro
13

What is command substitution and how do you use it?

Part of Pro
Intermediate 12
14

Explain the difference between $@ and $*

Part of Pro
15

What's the difference between [ and [[ in bash?

Part of Pro
16

How do you create and use arrays in bash?

Part of Pro
17

How do you define and call functions in bash?

Part of Pro
18

How do you handle errors in shell scripts?

Part of Pro
19

How do you process command-line options in bash?

Part of Pro
20

What is the difference between sourcing a script and executing it?

Part of Pro
21

What is a subshell, and when does bash create one?

Part of Pro
22

Why should you quote variables in bash?

Part of Pro
23

What are here documents and here strings in bash?

Part of Pro
24

How do you perform arithmetic operations in bash?

Part of Pro
25

What is the difference between .bashrc and .bash_profile?

Part of Pro
Expert 15
26

Explain parameter expansion and its advanced features

Part of Pro
27

How do you implement signal handling in bash scripts?

Part of Pro
28

What are file descriptors and how do you manipulate them?

Part of Pro
29

How do you implement process synchronization in bash?

Part of Pro
30

Explain process substitution and its use cases

Part of Pro
31

How do you implement a robust logging system in bash?

Part of Pro
32

How do you implement parallel processing in bash?

Part of Pro
33

What are coprocesses and how do you use them?

Part of Pro
34

How do you implement dynamic variable names and indirect references?

Part of Pro
35

How do you implement complex regular expressions in bash?

Part of Pro
36

How do you implement error recovery and retry mechanisms?

Part of Pro
37

How do you implement performance profiling in bash scripts?

Part of Pro
38

How do you implement secure scripting practices?

Part of Pro
39

How do you debug complex bash scripts effectively?

Part of Pro
40

When should you stop using bash and switch to Python or Go?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Bash & Shell Scripting? Send them this set.
Pro · $10/mo

36 of 40 Bash & Shell Scripting answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git