Shell Scripting Interview Questions

Get Technical Answers for Shell Scripting Interview Questions by Scripting Developers, Advanced Technical Questions for Freshers and Experience Persons.

1. What Are Pids?

They are process IDs given to processes. A PID can vary from 0 to 65535.

2. How Do You Remove A File?

"rm" removes each specified file argument (provided that it is a valid path name). If you specify either. or.. as the final component of the path name for a file, rm displays an error message, and moves onto the next file. If you specify a file you do not have write permission for, rm asks you for confirmation.

3. How Do You Remove Recursively?

rm -rf.

4. How Do You Find Out Your Own Username?


5. How Do You Count Words, Lines And Characters In A File?


6. How Do You Search For A String Inside A Given File?

grep string filename.

7. How Do You Search For A String Inside A Directory?

grep string *.

8. How Do You Search For A String In A Directory With The Subdirectories Recursed?

grep -r string *.

9. How Do You List Currently Running Process?


10. How Do You Find Out What's Your Shell?

echo $SHELL.

11. How Do You Fire A Process In The Background?

process-name &.

12. What's The Conditional Statement In Shell Scripting?

if {condition} then …... fi.

13. How Do You Do Number Comparison In Shell Scripts?

-eq, -ne, -lt, -le, -gt, -ge.

14. How Do You Test For File Properties In Shell Scripts?

-s filename tells you if the file is not empty,

     -f filename tells you whether the argument is a file, and not a directory,

     -d filename tests if the argument is a directory, and not a file,

     -w filename tests for writeability,

     -r filename tests for readability.

     -x filename tests for executability

15. How Do You Do Boolean Logic Operators In Shell Scripting?

tests for logical not, -a tests for logical and, and -o tests for logical or.

16. How Do You Find Out The Number Of Arguments Passed To The Shell Script?


17. What's The Way To Do Multilevel If-else's In Shell Scripting?

if {condition} then {staternent} elif {condition} {statement} fi.

18. How Do You Write A For Loop In Shell?

for {variable name} in {list} do {statement} done.

19. How Do You Find Out The Current Directory You're In?


20. What's The Command To Find Out Users On The System?


21. What's The Command To Find Out Today's Date?


22. How Do You Stop A Process?

kill pid.

23. How Do You Find Out About All Running Processes?

ps -ag.

24. How Do You Stop All The Processes, Except The Shell Window?

kill 0.

25. How Do You Define A Function In A Shell Script?

function-narne() { #some code here return }.

26. How Do You Read Keyboard Input In Shell Scripts?

read { variable-name}.

27. How Does A Case Statement Look In Shell Scripts?

case { variable} in {possible-value-1} {statement} ;; {possible-value-2}) {statement};; esac.

28. How Do You Write A While Loop In Shell?

while {condition} do {statement} done.

29. What Is Shell Scripting?

Shell scripting is used to program command line of an operating system. Shell Scripting is also used to program the shell which is the base for any operating system. Shell scripts often refer to programming UNIX. Shell scripting is mostly used to program operating systems of windows, UNIX, Apple, etc. Also this script is used by companies to develop their own operating system with their own features.

30. State The Advantages Of Shell Scripting?

There are many advantages of shell scripting some of them are, one can develop their own operating system with relevant features best suited to their organization than to rely on costly operating systems. Software applications can be designed according to their platform.

31. What Are The Disadvantages Of Shell Scripting?

·         There are many disadvantages of shell scripting they are

·         Design flaws can destroy the entire process and could prove a costly error.

·         Typing errors during the creation can delete the entire data as well as partition data.

·         Initially process is slow but can be improved.

·         Portbility between different operating system is a prime concern as it is very difficult to   port scripts etc.

32. Explain About The Slow Execution Speed Of Shells?

Major disadvantage of using shell scripting is slow execution of the scripts. This is because for every command a new process needs to be started. This slow down can be resolved by using pipeline and filter commands. A complex script takes much longer time than a normal script.

Shell Scripting Training Certification

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning


33. Give Some Situations Where Typing Error Can Destroy A Program?

There are many situations where typing errors can prove to be a real costly effort. For example a single extra space can convert the functionality of the program from deleting the sub directories to files deletion. cp, cn, cd all resemble the same but their actual functioning is different. Misdirected > can delete your data.

Subscribe to our youtube channel to get new updates..!


34. Explain About Return Code?

Return code is a common feature in shell programming. These return codes indicate whether a particular program or application has succeeded or failed during its process. && can be used in return code to indicate which application needs to be executed first.

Shell Scripting Training Certification

Weekday / Weekend Batches


Submit an interview question


Request for more information


Python tutorial for beginners

5th April | 08:00 AM

150 Registered

cloud computing
My name is tabres Am from hkr trainings I have good knowledge about the cloud computing services. I have been working on this field more than 10 years. Being here it is good opportunity because possibilities for enterprise engagement and as well as chance to attract with very good PhD students. Cloud computing has become one of the most used structures to installation High Availability (HA) solutions for its flexibility, and elasticity. Connect with me LinkedIn and twitter. Thank you

To Top