Q1 : In shell scripting, what is the significance of the Shebang line?
A : It simply provides information regarding the location where the engine is placed. The engine is the one that executes the script. The Shebang line is present at the top of the script and it can be neglected by the users if they want the same
Q2 : Where exactly you can store the Shell programs in the system?
A : They are stored in a file which is tagged as Sh (Bourne Shell)
Q3 : What are the different types of commonly used shells on a typical Linux system?
A : csh,ksh,bash,Bourne . The most commonly used and advanced shell used today is “Bash” .
Q4 : What are zombie processes?
A : These are the processes which have died but whose exit status is still not picked by the parent process. These processes even if not functional still have its process id entry in the process table.
Q5 : What is the importance of writing Shell Scripts?
A : The points given below explain the importance of writing shell scripts.
Shell script takes input from the user, file and displays it on the screen.
Shell scripting is very useful in creating your own commands.
It is helpful in automating some tasks of the day to day life.
It is useful for automating system administration tasks.
Mainly it saves time.
Q6: What is the equivalent of a file shortcut that we have a window on a Linux system?
A : Shortcuts are created using “links” on Linux. There are two types of links that can be used namely “soft link” and “hard link”.
Q7 : What are signals?
A : Signals are software interrupts. Signal provides a way of handling asynchronous events: a user at a terminal typing the interrupt key to stop a program or the next program in the pipeline terminating prematurely.
Q8 : What is Shell?
A : A shell acts as an interface between the user and the system. As a command interpreter, the shell takes commands and sets them up for execution.
Q9 : What are Shell Variables?
A : Shell variables are the main part of shell programming or scripting. They mainly provide the ability to store and manipulate information within a shell program.
Q10 : How many Shell Scripts come with Unix Operating System?
A : There are approximately 280 shell scripts that come with the UNIX operating system.
Q11 : In Shell scripting, how can you say that C Shell is better than Bourne Shell?
A :
- All the commands can be aliased simply with the C shell whereas the same is not possible in case of Bourne Shell
- Lengthy commands can be used again and again in C shell whereas the Bourne doesn’t allow the same in all the cases
- The command history can be accessed through the C shell but it cannot be accessed through the Bourne
- There is no need to type the command again and again in case of C
Q12 : When should we use “if” condition (before)?
A : When running several commands “if
” condition meets.
Q13 : Is separate compiler required for executing a Shell Program?
A : A separate compiler is not required to execute a shell program. The shell itself interprets the command in the shell program and executes them.
Q14 : How you will make the soft link inactive in the scripting
A : The soft links can simply be made inactive in your delete the file and the same doesn’t have any impact on the hard link and i.e. the users can access the file copy.
Q15 : What is the difference between soft and hard links?
A : Soft links are linked to the file name and can reside on different filesystems as well; however hard links are linked to the inode of the file and have to be on the same file system as that of the file. Deleting the original file makes the soft link inactive (broken link) but does not affect the hard link (Hard link will still access a copy of the file)
Q16 : How Many Fields Are Present In A Crontab File And What Does Each Field Specify?
A : The crontab file has six fields. The first five fields tell cron when to execute the command: minute(0-59), hour(0-23), day(1-31), month(1-12), and day of the week(0-6, Sunday = 0).
And the sixth field contains the command to be executed
Q17 : What are the different types of Shells available?
A : There are mainly 4 important types of shells that are widely used.
And they include:
- Bourne Shell (sh)
- C Shell (csh)
- Korn Shell (ksh)
- Bourne Again Shell (bash)
Q18 : What is the significance of $#?
A : $# shows the count of the arguments passed to the script.
Q19 : What is Unix Shell?
A : A Unix shell is a command-line interpreter that provides a Unix-like command line user interface.
Q20 : What command can be used to test if $a greater than 12?
A : The following command is used: [ $a -gt 12 ]
Q21 : What is the difference between $$ and $!?
A : $$ gives the process id of the currently executing process whereas $! Shows the process id of the process that recently went into the background.
Q22 : What is Shell Scripting?
A : Shell Scripting is a collection of commands put together into a file. Script is a command or an instruction given to process and these set of instructions put together in a file to perform some task.
Q23 : Shell Programs Are Stored In Which File?
A : Shell programs are stored in a file called sh.
Q24 : How To Accomplish Any Task Via Shell Script?
A : Any task can be accomplished via shell script at the dollar ($) prompt and vice versa.
Q25 : Basis Of Shell Program Relies On What Fact?
A : The basis of shell programming relies on the fact that UNIX shell can accept commands not just only from the keyboard but also from a file.