BASH Interview Questions

Last Updated: Nov 10, 2023

Table Of Contents

BASH Interview Questions For Freshers

How do you check if a string contains a specific substring in BASH?

Summary:

Detailed Answer:

What is the purpose of 'tail' command in BASH?

Summary:

Detailed Answer:

What is the purpose of 'uniq' command in BASH?

Summary:

Detailed Answer:

What is the purpose of 'cut' command in BASH?

Summary:

Detailed Answer:

What is the purpose of 'which' command in BASH?

Summary:

Detailed Answer:

How do you count the number of lines in a file using BASH?

Summary:

Detailed Answer:

How do you remove spaces from a string in BASH?

Summary:

Detailed Answer:

How do you declare and initialize a variable in BASH?

Summary:

Detailed Answer:

Explain the difference between single and double quotes in BASH.

Summary:

Detailed Answer:

How do you check if a file exists in BASH?

Summary:

Detailed Answer:

What is the purpose of the 'chmod' command in BASH?

Summary:

Detailed Answer:

How do you redirect the output of a command to a file in BASH?

Summary:

Detailed Answer:

How do you pass command line arguments to a BASH script?

Summary:

Detailed Answer:

Explain the 'for' loop in BASH and provide an example.

Summary:

Detailed Answer:

What is the purpose of 'if' statement in BASH? Give an example.

Summary:

Detailed Answer:

How do you create a new directory using BASH command?

Summary:

Detailed Answer:

Explain the 'while' loop in BASH and provide an example.

Summary:

Detailed Answer:

Explain what BASH is and what it is used for.

Summary:

Detailed Answer:

How do you read input from a user in BASH?

Summary:

Detailed Answer:

How do you perform arithmetic operations in BASH?

Summary:

Detailed Answer:

What is the purpose of 'grep' command in BASH?

Summary:

Detailed Answer:

How do you concatenate two strings in BASH?

Summary:

Detailed Answer:

What is the purpose of 'export' command in BASH?

Summary:

Detailed Answer:

Explain what 'cut' command does in BASH.

Summary:

Detailed Answer:

How do you find the length of a string in BASH?

Summary:

Detailed Answer:

How do you check if a directory exists in BASH?

Summary:

Detailed Answer:

BASH Intermediate Interview Questions

Explain how to use 'sort' command in BASH for sorting files.

Summary:

Detailed Answer:

How do you loop through a file line by line in BASH?

Summary:

Detailed Answer:

What is the purpose of 'basename' command in BASH?

Summary:

Detailed Answer:

Explain what the 'source' command does in BASH.

Summary:

Detailed Answer:

Explain the differences between 'grep', 'egrep', and 'fgrep' in BASH.

Summary:

Detailed Answer:

Explain what 'md5sum' command does in BASH.

Summary:

Detailed Answer:

How do you replace a specific string in a file in BASH?

Summary:

Detailed Answer:

Explain how to use 'find' command in BASH for searching files.

Summary:

Detailed Answer:

How do you read multiple variables from user input in BASH?

Summary:

Detailed Answer:

How do you calculate the MD5 hash of a file in BASH?

Summary:

Detailed Answer:

What is the purpose of 'xargs' command in BASH?

Summary:

Detailed Answer:

How do you perform string substitution in BASH?

Summary:

Detailed Answer:

Explain how to use 'tail' command in BASH for displaying the last lines of a file.

Summary:

Detailed Answer:

What is the purpose of 'tee' command in BASH?

Summary:

Detailed Answer:

Explain how to use 'grep' command with regular expressions in BASH.

Summary:

Detailed Answer:

What is the purpose of 'case' statement in BASH? Give an example.

Summary:

Detailed Answer:

What is the difference between a BASH script and a BASH function?

Summary:

Detailed Answer:

What is command substitution in BASH? Give an example.

Summary:

Detailed Answer:

What is the difference between '>>' and '>' in BASH for redirecting output?

Summary:

Detailed Answer:

What is process substitution in BASH? Give an example.

Summary:

Detailed Answer:

Explain how command substitution and process substitution differ in BASH.

Summary:

Detailed Answer:

What is the purpose of 'sed' command in BASH?

Summary:

Detailed Answer:

Explain the 'break' and 'continue' statements in BASH.

Summary:

Detailed Answer:

What is the purpose of 'awk' command in BASH?

Summary:

Detailed Answer:

BASH Interview Questions For Experienced

Explain how to use 'tar' command in BASH for archiving files and directories.

Summary:

Detailed Answer:

How do you remove duplicates from a file in BASH?

Summary:

Detailed Answer:

What is the purpose of 'exec' command in BASH?

Summary:

Detailed Answer:

How do you reverse the contents of a file in BASH?

Summary:

Detailed Answer:

What is the purpose of 'eval' command in BASH?

Summary:

Detailed Answer:

Explain how to use 'awk' command in BASH for text processing.

Summary:

Detailed Answer:

Explain how to use 'paste' command in BASH for merging files.

Summary:

Detailed Answer: