Interview Quizz Logo

 
  • Home
  • About Us
  • Electronics
  • Computer Science
  • Physics
  • History
  • Contact Us
  • ☰
  1. Computer Science
  2. Programming Technologies
  3. BASH (Bourne Again Shell) Interview Question with Answer

BASH (Bourne Again Shell) Questions and Answers for Viva

Frequently asked questions and answers of BASH (Bourne Again Shell) in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best BASH (Bourne Again Shell) Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download BASH (Bourne Again Shell) FAQs in PDF form online for academic course, jobs preparations and for certification exams .

Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.




Interview Question and Answer of BASH (Bourne Again Shell)


Question-1. What is BASH?

Answer-1: BASH (Bourne Again Shell) is a Unix shell and command language used for scripting and system administration.



Question-2. Who developed BASH?

Answer-2: BASH was developed by the GNU Project as a free software replacement for the Bourne Shell (sh).



Question-3. How do you create a variable in BASH?

Answer-3: Using VAR_NAME=value, e.g., name="John".



Question-4. How do you print a variable in BASH?

Answer-4: Using echo, e.g., echo $name.



Question-5. What is the difference between $VAR and ${VAR}?

Answer-5: Both reference a variable, but ${VAR} helps avoid ambiguity.



Question-6. How do you get user input in BASH?

Answer-6: Using read, e.g., read name; echo "Hello, $name".



Question-7. How do you define a function in BASH?

Answer-7: Using function myFunc() { commands; } or myFunc() { commands; }.



Question-8. How do you call a function in BASH?

Answer-8: Simply by using the function name, e.g., myFunc.



Question-9. How do you execute a BASH script?

Answer-9: Using bash script.sh or ./script.sh (if executable).



Question-10. How do you make a script executable?

Answer-10: Using chmod +x script.sh.



Question-11. What is the shebang (#!) in BASH?

Answer-11: It specifies the interpreter, e.g., #!/bin/bash at the start of the script.



Question-12. How do you use command-line arguments in BASH?

Answer-12: Using $1, $2, etc., e.g., echo "First arg: $1".



Question-13. What does $@ and $* do in BASH?

Answer-13: Both represent all command-line arguments, but $@ preserves arguments as separate words.



Question-14. How do you check if a command was successful?

Answer-14: Using $?, where 0 means success.



Question-15. How do you use an if statement in BASH?

Answer-15: if [ condition ]; then commands; fi.



Question-16. How do you check if a file exists?

Answer-16: Using [ -f filename ], e.g., if [ -f myfile ]; then echo "Exists"; fi.



Question-17. How do you check if a directory exists?

Answer-17: Using [ -d dirname ], e.g., if [ -d mydir ]; then echo "Exists"; fi.



Question-18. How do you use a for loop in BASH?

Answer-18: for i in 1 2 3; do echo $i; done.



Question-19. How do you use a while loop in BASH?

Answer-19: while [ condition ]; do commands; done.



Question-20. How do you use a case statement in BASH?

Answer-20: case $var in pattern1) commands;; pattern2) commands;; esac.



Question-21. What is the difference between = and == in BASH?

Answer-21: = is for assignment, while == is used in string comparison.



Question-22. How do you redirect output to a file?

Answer-22: Using command > file (overwrite) or command >> file (append).



Question-23. How do you redirect errors to a file?

Answer-23: Using command 2> file or command 2>> file.



Question-24. How do you redirect both output and error to a file?

Answer-24: Using command > file 2>&1.



Question-25. How do you list all environment variables?

Answer-25: Using printenv or env.



Question-26. How do you export a variable in BASH?

Answer-26: Using export VAR=value.



Question-27. What is the difference between local and export in BASH?

Answer-27: local defines variables within a function, while export makes them available to child processes.



Question-28. How do you find the path of a command?

Answer-28: Using which command or type command.



Question-29. How do you check the number of arguments passed?

Answer-29: Using $#, e.g., echo "Arguments: $#"



Question-30. How do you read a file line by line in BASH?

Answer-30: while read line; do echo $line; done < file.txt.



Question-31. What does set -e do in a script?

Answer-31: It makes the script exit immediately on error.



Question-32. What does set -x do in a script?

Answer-32: It enables debugging by printing each command before executing it.



Question-33. How do you execute a command stored in a variable?

Answer-33: Using eval, e.g., cmd="ls -l"; eval $cmd.



Question-34. How do you run a command in the background?

Answer-34: Using command &.



Question-35. How do you bring a background job to the foreground?

Answer-35: Using fg.



Question-36. How do you kill a process in BASH?

Answer-36: Using kill PID or pkill process_name.



Question-37. How do you find all running processes?

Answer-37: Using ps aux or top.



Question-38. What is the difference between > and >>?

Answer-38: > overwrites a file, while >> appends to it.



Question-39. How do you check disk usage?

Answer-39: Using df -h or du -sh folder_name.



Question-40. How do you check memory usage?

Answer-40: Using free -h.



Question-41. What does && and `

Answer-41:



Question-42. How do you search for a string in a file?

Answer-42: Using grep "pattern" filename.



Question-43. How do you replace text in a file?

Answer-43: Using sed, e.g., sed -i 's/old/new/g' file.txt.



Question-44. How do you count lines in a file?

Answer-44: Using wc -l filename.



Question-45. How do you list only directories?

Answer-45: Using ls -d */.



Question-46. How do you find the current shell?

Answer-46: Using echo $SHELL.



Question-47. How do you check if a user is root?

Answer-47: Using if [ $(id -u) -eq 0 ]; then echo "Root user"; fi.



Question-48. How do you schedule a cron job?

Answer-48: Using crontab -e and adding * * * * * command.



Question-49. How do you create an alias?

Answer-49: Using alias name='command', e.g., alias ll='ls -la'.



Question-50. How do you remove an alias?

Answer-50: Using unalias name, e.g., unalias ll.




Tags

Frequently Asked Question and Answer on BASH (Bourne Again Shell)

BASH (Bourne Again Shell) Interview Questions and Answers in PDF form Online

BASH (Bourne Again Shell) Questions with Answers

BASH (Bourne Again Shell) Trivia MCQ Quiz

FAQ Questions Sidebar

Related Topics


  • API Testing
  • Python
  • AWS Amazon Web Services
  • Java
  • C++
  • JavaScript
  • C#
  • PHP
  • Swift
  • Ruby
  • Kotlin
  • TypeScript
  • Go Golang
  • Rust
  • SQL
  • R
  • MATLAB
  • Perl
  • Scala
  • Dart
  • Haskell
  • Objective-C
  • Shell Scripting Bash
  • Visual Basic VB
  • Lua
  • Groovy
  • F#
  • Julia
  • COBOL
  • Fortran
  • Assembly Language
  • PL/SQL
  • Scratch
  • D
  • Erlang
  • Elixir
  • Clojure
  • Pascal
  • Ada
  • Lisp Common Lisp, Scheme
  • Prolog
  • Apex Salesforce
  • ActionScript
  • ABAP SAP
  • Racket
  • Nim
  • Crystal
  • Smalltalk
  • VHDL
  • Verilog
  • SASS Syntactically Awesome Style Sheets
  • Less CSS Preprocessor
  • CoffeeScript
  • J Sharp
  • Tcl (Tool Command Language)
  • XQuery
  • XSLT
  • OpenCL
  • CUDA
  • OpenGL Shader Language (GLSL)
  • VBScript
  • Solidity (Blockchain/Smart Contracts)
  • Yaml
  • JSON
  • XML
  • GDScript (Godot Engine)
  • UnrealScript (Unreal Engine)
  • Maple
  • Mathematica
  • Max/MSP
  • AutoLISP
  • LabVIEW
  • ScratchJr
  • AWK
  • sed (Stream Editor)
  • PostScript
  • Xojo
  • Q Sharp
  • Ring
  • ActionScript 3
  • OpenEdge ABL
  • RPG (IBM)
  • Inform
  • Modula-3
  • Rebol
  • Tcl/Tk
  • Haxe
  • SML (Standard ML)
  • Eiffel
  • Chapel
  • Red
  • MUMPS
  • PASCAL ABC
  • Icon
  • BCPL
  • Simula
  • SNOBOL
  • Hack (Meta)
  • PowerShell
  • Batch Script
  • AppleScript
  • Glue
  • Oz
  • Io
  • Mercury
  • Wren
  • Genie
  • PureScript
  • MoonScript
  • Turing
  • ALGOL
  • Seed7
  • Kotlin Native
  • Kotlin Multiplatform
  • Elm
  • PureBasic
  • QB64 (QuickBASIC)
  • Nemerle
  • Ocaml
  • Alloy
  • Cobra
  • Forth
  • Ballerina
  • Deno (JavaScript Runtime)
  • WASM (WebAssembly)
  • Z shell (Zsh)
  • Fish Shell
  • Redscript
  • Felix
  • ReScript
  • Agda
  • Idris
  • Coq
  • SPARK
  • Vala
  • PicoLisp
  • Wolfram Language
  • BASH (Bourne Again Shell)
  • Hy (Lisp-like for Python)
  • Terra
  • Boo
  • ATS
  • K (Kdb+)
  • Picat
  • Nimrod
  • Pawn
  • Papyrus (Bethesda Games)
  • J Programming Language
  • X++
  • MQL4/MQL5 (MetaTrader)
  • Transact-SQL (T-SQL)
  • BASH Shell Scripting

More Subjects


  • Computer Fundamentals
  • Data Structure
  • Programming Technologies
  • Software Engineering
  • Artificial Intelligence and Machine Learning
  • Cloud Computing

All Categories


  • Physics
  • Electronics Engineering
  • Electrical Engineering
  • General Knowledge
  • NCERT CBSE
  • Kids
  • History
  • Industry
  • World
  • Computer Science
  • Chemistry

Can't Find Your Question?

If you cannot find a question and answer in the knowledge base, then we request you to share details of your queries to us Suggest a Question for further help and we will add it shortly in our education database.
© 2025 Copyright InterviewQuizz. Developed by Techgadgetpro.com
Privacy Policy