All questions
Showing of 40What is the difference between a shell and a terminal?
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:
Last attempt -
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.
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 ↓
How do you make a shell script executable?
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:
Last attempt -
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.
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 ↓
What is the purpose of the shebang (#!) line?
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:
Last attempt -
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.
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 ↓
How do you declare and use variables in bash?
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:
Last attempt -
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.
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 ↓
What's the difference between single quotes, double quotes, and backticks?
How do you pass arguments to a shell script?
What are exit codes and how do you use them?
How do you redirect standard output and standard error?
What is the difference between sh and bash?
How do you implement conditional statements in bash?
Explain different types of loops in bash
What are pipes and how do you use them?
What is command substitution and how do you use it?
Explain the difference between $@ and $*
What's the difference between [ and [[ in bash?
How do you create and use arrays in bash?
How do you define and call functions in bash?
How do you handle errors in shell scripts?
How do you process command-line options in bash?
What is the difference between sourcing a script and executing it?
What is a subshell, and when does bash create one?
Why should you quote variables in bash?
What are here documents and here strings in bash?
How do you perform arithmetic operations in bash?
What is the difference between .bashrc and .bash_profile?
Explain parameter expansion and its advanced features
How do you implement signal handling in bash scripts?
What are file descriptors and how do you manipulate them?
How do you implement process synchronization in bash?
Explain process substitution and its use cases
How do you implement a robust logging system in bash?
How do you implement parallel processing in bash?
What are coprocesses and how do you use them?
How do you implement dynamic variable names and indirect references?
How do you implement complex regular expressions in bash?
How do you implement error recovery and retry mechanisms?
How do you implement performance profiling in bash scripts?
How do you implement secure scripting practices?
How do you debug complex bash scripts effectively?
When should you stop using bash and switch to Python or Go?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Bash & Shell Scripting cheatsheet
- Shell Basics01
- Variables02
- Operators03
- Control Structures04
- Functions05
- Input/Output06
- File Operations07
- Process Management08
- Text Processing09
- System Administration10
- Advanced Topics11
- Best Practices12
- + 2 more inside
- + 8 more inside
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.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.