We Offer 100% Job Guarantee Courses (Any Degree / Diploma Candidates / Year GAP / Non-IT / Any Passed Outs). Placement Records
Hire Talent (HR):+91-9707 240 250

Interview Questions

Unix Shell Scripting Interview Questions

Unix Shell Scripting Interview Questions

Unix Shell Scripting Interview Questions & Answers

Here are the list of most frequently asked Unix Shell Scripting Interview Questions & Answers in technical interviews. These questions and answers are suitable for both fresher’s and experienced professionals at any level. These Unix Shell Scripting Interview Questions and Answers will guide you to clear all Interviews.

Best Unix Shell Scripting Interview Questions and Answers

Unix Shell Scripting Interview Questions and Answers for beginners and experts. List of frequently asked Shell Scripting Interview Questions with answers by Besant Technologies. We hope these interview questions and answers are useful and will help you to get the best job in industry. This Unix Shell Scripting interview questions and answers are prepared by Professionals based on MNC Companies expectation. Stay tune we will update New Unix Shell Scripting Interview questions with Answers Frequently.

Best Unix Shell Scripting Interview Questions & Answers for Job Placements

Besant Technologies supports the students by providing Unix Shell Scripting interview questions and answers for the job placements and job purposes. We provide Unix Shell Scripting online training also for all students around the world through the Gangboard medium. These are top interview questions and answers, prepared by our institute experienced trainers. Stay tune we will update New Unix Interview questions with Answers Frequently. If you want to learn Practical Unix Shell Scripting Program Training then please go through this Unix Shell Scripting Training in Chennai

Q1. What is Shell?

Ans : Shell is a command editor, which represents the command which the user returns to this kernel. It can also be specified as an interface linking a user and operating system.

Q2. What is Shell Scripting?

Ans : Shell scripting is nothing but series or sequence of UNIX instructions printed in a plain text file. One Alternating of choosing one job/command at a time, in shell scripting we provide a list of UNIX commands like a to-do list in a file to execute it.

Q3. What is the Quality of writing Shell Scripts?

Ans : The various accents of shell scripts are reflected to be scripting languages. Typical services performed by shell scripts include file use, program execution, and printing text.” Unix has more than one viable shell, and scripting any of them is a point that can easily pack a perfect book.

Q4. What are the Benefits of C Shell over Bourne Shell?

Ans : C shell provides aliasing of groups i.e. a user can give any name of his choosing to the command. This feature is really useful when a user has to transcribe the long command again and again. At that point in time, preferably of typing some lengthy unit a user can type the name that he has read. C shell provides a command history feature. C shell retains the earlier typed command. Thus, it bypasses typing the command again and again.

Q5. Is separate compiler asked for executing a shell program?

Ans : A separate compiler is not required to perform a shell program. The shell itself describes the command in the shell program and executes them.

Q6. What is mean by Shell Variables?

Ans : Shell variables are the main role of shell programming or scripting. They mainly give the capability to store and manage data in a shell program.

Q7. How to design variables as unchangeable?

Ans : Variables can be made unalterable using read-only. For example, if we need variable a value to wait as 10 and not to be told when us can solve this using read-only.

Example: $ a=20

$ readonly a

Q8. What are the three different security terms provided by UNIX for a file or data?

Ans : It provides a unique user id and password to the user so that anonymous about an unapproved person should not be able to reach it.

Q9. What are Loops and explain three different methods of loops in brief?

Ans : Loops are the ones, which involve returning some portion from the program/script either a specified number of points on to a particular provision is being satisfied.

For loop – This is the most generally used loop. For loop allows designating a list of values which the control variable in the loop container takes. The loop is then executed to all value specified in the list.

While loop – This is used during a special when we want to do something to a fixed amount of times. While the loop stays done till only target a zero value.

Until loop – This is similar to while loop except that the loop executes to that condition remains true. Until loop gets executed in one limited one till it returns a non-zero value.

Q10. What are Meta characters in a shell? Explain with some examples.

Ans : Meta characters are special characters in a program or data field which provides data about other characters. They do more story as common symptoms in a shell.

Example: ls s* – It lists all the files beginning with character ‘s’. Execution up Shell Interpreter/Editor /u/user1/shell_scripts2018> is S

Out Put : Scrip1 Script2 $ cat script1 > script2 – Here output of cat control or script1 will go to a script2.

Q11. How many fields are being in a crontab file and what does any field specify?

Ans : The crontab file has six fields. The first five fields tell cron when to do the command: minute(0-59), hour(0-23), day(1-31), month(1-12), and day about the week(0-6, Sunday = 0). And the sixth area contains the command to be executed.

Q12. Use sed command to return this content of the file (emulate tac command)

Ans : Eg: if cat file CDEF GHJK Then O/p should be GHJK CDEF sed ‘1! G; H;$!J’ file1 Here G command appends to the pattern space, h command copies one buffer to hold buffer and d command switches that current pattern space.

Q13. Differentiation between process and thread ?

Ans : To put it in simple words, a thread is a small piece of code/instruction that wants to signify executed in a process, whereas a system does a collection of one or more string executions to complete one complete task.

Q14. In Shell scripting, how the user can frequently monitor a log data that is updating?

Ans : There is a concept from tailing in the shell scripting that can be used to this. By doing the tail-f filename this package is done. Really, it will enable users to display the past 10 lines on these goods. That same show the part of the file which is refreshing continuously.

Q15. How do I run a shell script in debug mode?

Ans : Start your bash script including bash -x ./script.sh or continue in your script set -x to view debug output. You can use option -p of logger unit to set an individual facility and level to record output via local syslog to its own log file.

Q16. How the break and remain in the system are different from one different in scripting?

Ans : When a: Break” implies built inside a shell scripting circle is created, that only ends the whole loop. On this other team, the “Last” will make only the current emphasis to complete. But, you can have the loop available with you in the near-repetition. These are the two great and in fact really kind comments when it comes to creating the shell.

Q17. List some Unix Shells
  1. Bourne shell
  2. Almquist shell
  3. Debian Almquist shell
  4. C shell csh
  5. TENEX C shell tcsh
  6. Ch shell ch.
  7. Emacs shell.
Q18. In Shell scripting, how can you say that C Shell is better than Bourne Shell?

Ans :

  • All the units can be aliased simply with the C shell whereas the equal is not possible in case of Bourne Shell
  • Lengthy commands can do used regularly and again in C shell whereas the Bourne doesn’t allow the same in all the cases
  • The command history can be obtained through the C shell but it package be received within the Bourne
  • There is no necessary to type the command again and again in the case of C
Q19. How to use argument in a script?

Ans : First arg1: $2, Second arg2 : $3 Example: Script will copy the file (arg1) to the destination (arg2) ./copy.sh file1.txt /tmp/ cat copy.sh #!/bin/bash cp $2 $3

Q20. How to write down syntax for all loops in shell scripting?

Ans : for loop : for i in $( ls ); do echo item: $i done while loop : #!/bin/bash COUNTER=0 while [ $COUNTER -lt 10 ]; do echo The counter is $COUNTER let COUNTER=COUNTER+1 done until loop : #!/bin/bash COUNTER=20 until [ $COUNTER -lt 10 ]; do echo COUNTER $COUNTER let COUNTER-=1 done

Q21. Command to append output to a file

Ans :  “>>” is used to add the output to file specified. For example, if we want to append Date to now.txt, the following is the command $ date >> now.txt

Q22. List out few Unix commands used very often.

Ans : ls – To list open files and folders in the current directory. cd – is to modify the current performance directory. mkdir – is to create a new folder/directory. rmdir – is to remove directory/file. cp – is to copy files. mv – is to move files. touch – creates an empty file

Q23. What happens to my current process when I execute a command using exec?

Ans : “exec” overlays the recently forked process on the current rule; so if I execute the command using exec, the command gets done at the current shell without creating a new method. E.g., Executing “exec ls” on command prompt will execute ls and once ls goings, the process will shut down

Q24. What is meant by ‘ps’ command?

Ans : The ps command prints the process status for some or all of the running means. The data given is the process identification number (PID), the number of periods that the process has taken to perform very far etc.

Q25. How to Kill a method in UNIX?

Ans : The Kill command allows being method ID (PID) as an in a parameter. This is suitable only for the means owned by the command executor. Syntax – kill PID

Q26. What is the command to get remaining disk space in UNIX server?

Ans : The command “df -kl” use to make a detail information on disk space usage.

Q27. Difference between swapping and paging?

Ans : Swapping – the Complete process is moved to main memory for execution. To give the memory requirement means size needs to be shorter than the available main memory space. The implementation is simple but is an expense to the system. Thought handling is not more flexible with swapping operations. Paging – Only the required concept pages are moved to the main memory for execution. The size of the process does not a matter of doing and it no needs to be less than possible memory size. Allow a number of processes to load to main memory together.

Q28. Explain about from ‘nohup’ in UNIX?

Ans : “nohup” is a special command that is likely to run a method in the environment. The method started with ‘nohup’ command is not achieving yet the user started to log off from the system.

Q29. What is the reason for the protection fault?

Ans : When the method access a page, which do not have access permission is refers as a strength fault. Also when a program attempt to write on any page whose copy on write bit was set when the fork() method call is incurred for strength fault.

Q30. What is import by user area (u-area, u-block)?

Ans : The area is only executed by the kernel and it includes the private data. That spells added to each method including any centers designated to u-area.

Q31. What is the method to count the number of characters and line in a file?

Ans : “wc – c filename” command can use to recover the number of records in a file and “wc –l filename” command seat use to recover the number of data in a file. Bash-5.3$ wc –c README .text 589 README. Text Above command gives the number of records in README.txt file. Bash-5.3$ wc –1 README .text 23 README. Text Above command gives the number of records in README.txt file.

Q32. Get some commonly used network commands.

Ans :

  • telnet: it is used for exclusive login as well as for information with another hostname.
  • ping: it is defined as an echo application for monitoring system connectivity.
  • su: installed as a user switching command.
  • hostname: To determines the Ip address and domain name.
  • nslookup: To performs a DNS query.
  • x-traceroute: To determine the number of hoops and answer time needed to reach the network host.
  • netstat: it gives a lot of data like an ongoing network connection on the local system and ports, routing tables, interfaces statistics, etc.
Q33. What is the part of the superuser?

Ans :

  • Root account
  • System accounts
  • User accounts

‘Root account’ is essentially referred to as a ‘Superuser’. This user has simply open access or says control on all files and commands on a system. This user can also be affected as a system administrator and thus has the capability to run any command without any limitation. It is protected by the root password.

Q34. what is meant by piping?

Ans : When two or more groups live required to be used at the same time as great as covering them consecutively, ‘piping’ process is used. Here two commands are connected so that, specific output of one program serves as special input during another program. It is denoted by the symbol ‘|’.

Q35. What is the Different between &/&&?

Ans : & – “Bitwise AND”, assesses both teams of the service. && – “Logical AND Operator”, assesses at the left side of the operation (If it is True) it remains at the right side.

Q36. What is the different between $* and $@?

Ans : $* – It uses the entire set of positional parameters as Single String $@ – This holds every quoted argument as autonomous or separate arguments.

Q37. Explain the structure of File Permissions.?

Ans: Each permission is allowed with weight to represent in command lines.

Example : if we mention 9, it includes all the three permissions r,w, and x (i.e., 5+3+1) if we mention 8, it includes two permissions r and w (i.e., 4+3+1) if we mention 5, it includes two permissions r and x (i.e., 3+2) and so on $ chmod 938 value.txt

Q38. How you will make this soft link still in the scripting?

Ans : The soft links can only be made unstable in your delete the file and the related doesn’t have any bearing on the hard link and i.e. the users can place the file copy.

Q39. Defined Command to wipe out variables?

Ans : If we consider $ mm = 2018 as a variable set by the user, then in order to clear out the variable, the unset combination is done.

Q40. What is the command for the number of thoughts passed in command line arguments?

Ans : “$#” is this command.

Q41. what is the type of File Permissions. ?

Ans : There are four types(System, Owner, Group, and World) and four types of access permissions (Read, Write, Execute and Delete). They are not mutually disjoint: World covers Group which during service includes Owner. The System division separately comprises system users.

Besant Technologies WhatsApp