InterviewPitch

Land the job you want — prepare
with Real interviews Q&A

Curated interview questions, company-wise guides and coding rounds. Practice mock interviews, improve with feedback, and track your progress.

Q&A
Top curated interview packs
Company-wise & role-wise packs, quality assured.
Mock interview
AI scoring
Coding rounds
Top 10 sets
Beginner
1. What is Bash?

Bash stands for Bourne Again Shell. It is a command-line shell and scripting language used mainly in Linux and Unix systems.

Bash allows users to:

  • Run commands
  • Automate tasks
  • Create shell scripts
  • Manage files and processes
bash
#!/bin/bash
echo "Hello World"
Beginner
2. What is a shell script?

A shell script is a file containing a sequence of Bash commands that are executed automatically.

Shell scripts help automate repetitive tasks.

bash
#!/bin/bash

name="AK"

echo $name
Beginner
3. How do you declare variables in Bash?

Variables in Bash are declared without data types.

No spaces should be used around =.

bash
#!/bin/bash

name="AK"

echo $name
Beginner
4. How do you perform arithmetic operations in Bash?

Arithmetic operations in Bash are usually done using $(( )).

bash
#!/bin/bash

num1=10
num2=20

sum=$((num1 + num2))

echo $sum
Beginner
5. What is an if statement in Bash?

An if statement is used to execute commands conditionally.

bash
#!/bin/bash

if [ 10 -gt 5 ]
then
  echo "10 is greater"
fi
Beginner
6. What is a for loop in Bash?

A for loop is used to repeat commands multiple times.

bash
#!/bin/bash

for i in 1 2 3 4 5
do
  echo $i
done
Beginner
7. What is a while loop in Bash?

A while loop repeatedly executes commands while a condition remains true.

bash
#!/bin/bash

count=1

while [ $count -le 5 ]
do
  echo $count
  count=$((count + 1))
done
Beginner
8. What are functions in Bash?

Functions are reusable blocks of code used to perform specific tasks.

bash
#!/bin/bash

function greet() {
  echo "Hello AK"
}

greet
Beginner
9. What are positional parameters in Bash?

Positional parameters are command-line arguments passed to a script.

  • $1 → first argument
  • $2 → second argument
  • $# → total arguments
bash
#!/bin/bash

echo $1
echo $2
Beginner
10. How do you take user input in Bash?

The read command is used to take input from the user.

bash
#!/bin/bash

read -p "Enter your name: " name

echo "Welcome $name"
Intermediate
11. How do you check if a file exists in Bash?

Bash provides test operators to check files and directories.

bash
#!/bin/bash

touch file.txt

if [ -f file.txt ]
then
  echo "File exists"
fi
Intermediate
12. What is a case statement in Bash?

A case statement is used for multiple condition checks.

bash
#!/bin/bash

case $1 in
  start)
    echo "Starting"
    ;;
  stop)
    echo "Stopping"
    ;;
  *)
    echo "Invalid option"
    ;;
esac
Intermediate
13. What are arrays in Bash?

Arrays store multiple values in a single variable.

bash
#!/bin/bash

arr=("apple" "banana" "mango")

echo ${arr[0]}
echo ${arr[1]}
Intermediate
14. What is command substitution?

Command substitution allows the output of a command to be stored in a variable.

bash
#!/bin/bash

today=$(date)

echo $today
Intermediate
15. What is grep in Linux?

grep is a command used to search text patterns inside files.

bash
#!/bin/bash

grep "hello" file.txt
Intermediate
16. How do you check running processes in Linux?

The ps command shows running processes.

bash
#!/bin/bash

ps aux | grep nginx
Advanced
17. What is the find command?

The find command searches for files and directories.

bash
#!/bin/bash

find . -name "*.txt"
Advanced
18. What is chmod?

chmod changes file permissions in Linux.

bash
#!/bin/bash

chmod +x script.sh
Advanced
19. What is tar command?

tar is used to archive and compress files.

bash
#!/bin/bash

tar -czvf backup.tar.gz folder/
Advanced
20. What are environment variables in Bash?

Environment variables store system-wide values used by the shell and applications.

bash
#!/bin/bash

#!/bin/bash

echo "Current User: $USER"
echo "Home Directory: $HOME"
Advanced
21. What is exit status in Bash?

Every command in Bash returns an exit status.

  • 0 → Success
  • Non-zero → Error
bash
#!/bin/bash

echo "Exit Status: $?"