UNIX Shell Programming Interview Questions You'll Most Likely Be Asked
()
About this ebook
- 276 UNIX Shell Programming Interview Questions
- 76 HR Interview Questions
- Real life scenario based questions
- Strategies to respond to interview questions
- 2 Aptitude Tests
UNIX Shell Pro
Read more from Vibrant Publishers
Stakeholder Engagement Essentials You Always Wanted To Know: Self Learning Management Rating: 5 out of 5 stars5/5HR Analytics Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsDigital SAT Reading and Writing Practice Questions: Test Prep Series Rating: 5 out of 5 stars5/5Operations and Supply Chain Management Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsCore Java Interview Questions You'll Most Likely Be Asked: Job Interview Questions Series Rating: 4 out of 5 stars4/5Business Strategy Essentials You Always Wanted To Know: Self Learning Management Rating: 5 out of 5 stars5/5Diversity in the Workplace Essentials You Always Wanted To Know: Self Learning Management Rating: 5 out of 5 stars5/5Financial Accounting Essentials You Always Wanted to Know: 5th Edition: Self Learning Management Rating: 0 out of 5 stars0 ratingsGRE Master Wordlist: 1535 Words for Verbal Mastery: Test Prep Series Rating: 4 out of 5 stars4/5GRE Reading Comprehension: Detailed Solutions to 325 Questions: Test Prep Series Rating: 5 out of 5 stars5/5Project Management Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsGMAT Analytical Writing: Solutions to the Real Argument Topics: Test Prep Series Rating: 4 out of 5 stars4/5Leadership Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsGRE Text Completion and Sentence Equivalence Practice Questions: Test Prep Series Rating: 4 out of 5 stars4/5Business Law Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsWriting Impressive College Essays: Test Prep Series Rating: 0 out of 5 stars0 ratingsInnovative Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsHuman Resource Management Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsPrinciples of Management Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsGRE Verbal Reasoning Supreme: Study Guide with Practice Questions: Test Prep Series Rating: 4 out of 5 stars4/5Digital Marketing Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsData Analytics Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsLeadership Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsFinancial Management Essentials You Always Wanted to Know: 5th Edition: Self Learning Management Rating: 0 out of 5 stars0 ratingsGRE Analytical Writing: Solutions to the Real Essay Topics - Book 1: Test Prep Series Rating: 5 out of 5 stars5/5Winning Strategies For ACT Essay Writing: With 15 Sample Prompts: Test Prep Series Rating: 5 out of 5 stars5/5Time Management Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsBusiness Plan Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsGRE Words In Context: The Complete List: Test Prep Series Rating: 5 out of 5 stars5/5Marketing Management Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratings
Related to UNIX Shell Programming Interview Questions You'll Most Likely Be Asked
Titles in the series (33)
SQL Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsC & C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsC# Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsData Structures & Algorithms Interview Questions You'll Most Likely Be Asked Rating: 1 out of 5 stars1/5Advanced JAVA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJava / J2EE Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJSP-Servlet Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsHibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSoftware Testing Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsORACLE PL/SQL Interview Questions You'll Most Likely Be Asked Rating: 5 out of 5 stars5/5Hadoop BIG DATA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsCORE JAVA Interview Questions You'll Most Likely Be Asked Rating: 4 out of 5 stars4/5Python Interview Questions You'll Most Likely Be Asked Rating: 2 out of 5 stars2/5Automated Software Testing Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAP HANA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJavaScript Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsLinux System Administrator Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsOperating Systems Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsBase SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsCCNA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsUNIX Shell Programming Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSelenium Testing Tools Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsSAS Programming Guidelines Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsCloud Computing Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsSAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJava/J2EE Design Patterns Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratings
Related ebooks
UNIX Shell Scripting Interview Questions, Answers, and Explanations: UNIX Shell Certification Review Rating: 5 out of 5 stars5/5Linux System Administrator Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsLPIC-1 Primer Rating: 4 out of 5 stars4/5Linux Commands By Example Rating: 5 out of 5 stars5/5Bash Command Line Pro Tips Rating: 5 out of 5 stars5/5Learn Java Programming in 24 Hours Rating: 0 out of 5 stars0 ratingsOperating Systems Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsLinux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsLearning Linux Shell Scripting Rating: 4 out of 5 stars4/5Programming Concepts in C++ Rating: 0 out of 5 stars0 ratingsC Programmin Language Rating: 0 out of 5 stars0 ratingsLinux Services Deployment Rating: 0 out of 5 stars0 ratingsPython Interview Questions You'll Most Likely Be Asked Rating: 2 out of 5 stars2/5Java 8 Programmer II Study Guide: Exam 1Z0-809 Rating: 4 out of 5 stars4/5C & C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsUNIX Programming: UNIX Processes, Memory Management, Process Communication, Networking, and Shell Scripting Rating: 0 out of 5 stars0 ratingsLearn Linux in a Month of Lunches Rating: 3 out of 5 stars3/5Working with Linux – Quick Hacks for the Command Line Rating: 5 out of 5 stars5/5Linux Interview Questions: Open Source Operating Systems Interview Questions, Answers, and Explanations Rating: 5 out of 5 stars5/5Java / J2EE Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsDB2 Exam C2090-320 Preparation Guide Rating: 0 out of 5 stars0 ratingsLinux in Action Rating: 0 out of 5 stars0 ratingsLPI Linux Certification Questions: LPI Linux Interview Questions, Answers, and Explanations Rating: 4 out of 5 stars4/5Learning Apache Cassandra - Second Edition Rating: 0 out of 5 stars0 ratingsMastering Bash Rating: 5 out of 5 stars5/5Distributed Computing in Java 9 Rating: 0 out of 5 stars0 ratingsMastering Linux System Administration Rating: 0 out of 5 stars0 ratingsLinux Essentials Rating: 4 out of 5 stars4/5
System Administration For You
CompTIA A+ Complete Review Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 5 out of 5 stars5/5Cybersecurity: The Beginner's Guide: A comprehensive guide to getting started in cybersecurity Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsThe Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsLearn Windows PowerShell in a Month of Lunches Rating: 0 out of 5 stars0 ratingsMastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5Networking for System Administrators: IT Mastery, #5 Rating: 5 out of 5 stars5/5Git Essentials Rating: 4 out of 5 stars4/5Linux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsLearn PowerShell Scripting in a Month of Lunches Rating: 0 out of 5 stars0 ratingsLearn SQL Server Administration in a Month of Lunches Rating: 3 out of 5 stars3/5Linux Bible Rating: 0 out of 5 stars0 ratingsPowerShell: A Comprehensive Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Work with the Command-line: To Manage Files and Directories in Ubuntu Rating: 5 out of 5 stars5/5How To Speed Up Computer: Your Step-By-Step Guide To Speeding Up Computer Rating: 0 out of 5 stars0 ratingsWordpress 2023 A Beginners Guide : Design Your Own Website With WordPress 2023 Rating: 0 out of 5 stars0 ratingsMastering Salesforce CRM Administration Rating: 5 out of 5 stars5/5Ethical Hacking Rating: 4 out of 5 stars4/5e-Discovery For Dummies Rating: 0 out of 5 stars0 ratingsCompTIA Linux+ Practice Tests: Exam XK0-005 Rating: 0 out of 5 stars0 ratingsLinux for Beginners: Linux Command Line, Linux Programming and Linux Operating System Rating: 4 out of 5 stars4/5Mastering Bash Rating: 5 out of 5 stars5/5Summary of Lights Out: by Ted Koppel | Includes Analysis Rating: 0 out of 5 stars0 ratings
Reviews for UNIX Shell Programming Interview Questions You'll Most Likely Be Asked
0 ratings0 reviews
Book preview
UNIX Shell Programming Interview Questions You'll Most Likely Be Asked - Vibrant Publishers
UNIX Shell Programming Interview Questions
You'll Most Likely Be Asked
Job Interview Questions Series
www.vibrantpublishers.com
*****
UNIX Shell Programming Interview Questions You'll Most Likely Be Asked
Copyright 2021, By Vibrant Publishers, USA. All rights reserved. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior permission of the publisher.
This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. The author has made every effort in the preparation of this book to ensure the accuracy of the information. However, information in this book is sold without warranty either expressed or implied. The Author or the Publisher will not be liable for any damages caused or alleged to be caused either directly or indirectly by this book.
Vibrant Publishers books are available at special quantity discount for sales promotions, or for use in corporate training programs. For more information please write to [email protected]
Please email feedback/corrections (technical, grammatical or spelling) to [email protected]
To access the complete catalogue of Vibrant Publishers, visit www.vibrantpublishers.com
*****
Table of Contents
1. C Shell - Beginner
2. C Shell – Intermediate
3. C Shell – Advanced
4. Bash - Beginner
5. Bash - Intermediate
6. Bash - Advanced
7. Basics
8. Commands
9. Variables and Arrays
10. Special Shell Variables
11. Operators and Shell Substitutions
HR Interview Questions
INDEX
*****
UNIX Shell Programming
Interview Questions
Review these typical interview questions and think about how you would answer them. Read the answers listed; you will find best possible answers along with strategies and suggestions.
*****
C Shell - Beginner
1: What must you do before you are able to run your new script for the first time by its name or with an alias?
Answer:
You must make it executable, that is to execute the command:
chmod +x scriptname
2: The following command is included in the .login script of a user:
alias whois ´grep \!ˆ /etc/passwd´
What will be the output, when the user issues the following?
who is guru
Answer:
If there is a defined user account named "guru", or the string guru is contained elsewhere in /etc/passwd file, then the output will be the entry which contains the string "guru", otherwise, it will be an empty line.
3: If the condition If (-r filename)fails (returns false), what are the possible reasons?
Answer:
The possible reasons are:
a) filename is not readable by the owner of the process
b) filename does not exist
4: Which is the difference between the next two statements?
set var =99
@ var = 99
Answer:
Using the typical assignment form (set ...), the value assigned in var is the string 99. Using the @, the value is the integer 99.
5: Given the code snippet:
@ n = 5
while ($n)
# actions
...
end
What actions should be performed inside the loop, in order to get out of this loop?
Answer:
Any command that changes the value of variable n, for it to become 0 sometime. E.g., @ n—
6: What will the output of the following commands be? Explain.
set names =(Kathrin Chris Jacob)
shift names
echo $#names
Answer:
The output will be 2.
shift command gets rid of the first element of the array names. So, the echo command will display 2 as the number of elements of the array.
7: What does the command rehash do?
Answer:
Rehash recomputes the internal hash table for the PATH variable. If the new command resides in a directory not listed in PATH, add this directory to PATH, and then use rehash.
8: How could you ensure that a script will be run in csh?
Answer:
The first line of the script could be used to define the shell you want to use, as follows:
#!/bin/csh
This is sufficient to run the script in csh.
9: Given that script1 is an executable C shell script situated in directory /home/myhomedir/project1/data/dir1, use three ways to run it, explaining the pros and cons.
Answer:
a) cd/home/myhomedir/project1/data/dir1/script1 (You should first cd to the directory path)
b) /home/myhomedir/project1/data/dir1/script1 (You should include the absolute directory path)
c) script1 (shortest form, but it works only if the directory path is added to the PATH environment variable of the user)
10: What will be the value of the sixrem variable, after executing this command?
@ sixrem = $data[2] % 6
Answer:
The expression divides the value of second element of the data array by 6 and assigns the remainder of the division to the sixrem variable.
11: Name two ways to obtain the length of a string, giving a simple example for each one.
Answer:
The two ways to obtain the length of a string are:
a) Using the wc command:
set string = any string
@ ln = `echo $string | wc -c` -1
b) Using the awk function length:
set string = any string
set ln = `echo $string | awk '{print length($0)}'`
12: Create a script that displays a list of regular files from the current directory.
Answer:
#!/bin/csh -f
foreach i (*)
if( -f $i ) then
print $i
endif
end
13: Describe in short, the word-completion feature of the tcsh shell.
Answer:
If you want word completion to work, whether on commands or filenames, you just need to type the beginning of the word and press the Tab key. The Shell will substitute the unfinished word with a complete one which is available in the input buffer and also adds a /
to its end if it’s a directory and a space if it’s a word. The shell will check the buffer to identify whether the completed word is a word or a command, variable or filename. The buffer considers the first word in it and the words following {‘|’, ‘|&’, ‘;’, ‘&&’, ‘||’} as a command. If the word starts with a $ it’s a variable and everything else is a filename. If there’s an empty line, it is completed as a filename.
14: In tcsh, how are the remaining choices (if any) listed whenever the word completion fails?
Answer:
The remaining choices (if any), are listed only if the shell variable autolist is set.
15: In tcsh, how do you disable filename substitution?
Answer:
noglob shell variable can be set to disable the filename substitution feature.
16: Compare the sched tcsh built-in command with the UNIX/Linux at command.
Answer:
These commands are similar but not the same. sched command runs directly from the shell, so it has access to shell variables and settings at command can run a scheduled command at exactly the specified time.
17: Schedule a prompt change at 10:55 as a reminder for an oncoming event.
Answer:
sched 10:55 set prompt = 'It\'s time for the important meeting: >'
18: What is the impact of -f option in the first line of a csh script?
(#!/bin/csh
versus
#!/bin/csh -f)
Answer:
When you add the -f option to csh, the shell will skip loading the startup files .cshrc and resources. It will also skip the hashing process. The shell will load quicker because of that.
19: How can you start a job in the background, and then terminate your login session, without terminating the background job?
Answer:
We can start a job in the background and then terminate our login session, without terminating the background job using no hangup
command, nohup:
nohup command > output_file &
20: Which is the difference between
echo c{1,4,2,5,1}
and
echo [c]{1,4,2,5,1}?
Answer:
The first echo will display c1 c4 c2 c5 c1, while the second displays only c1.
21: Display the first and last arguments of a script, regardless of the number of arguments, and without a loop.
Answer:
my_var3 = $#argv
echomy_var1: $argv[$1]
echomy_last_var: $argv[$my_var3]
22: How will you set the ‘search path’ in csv?
Answer:
Search path in csv can be set as follows:
a) setenv PATH/myfolder1 /bin: /myfolder2 /myfile3
b) using list
set path =( /myfolder1 /bin /myfolder2 /myfile3 )
23: Create a tar archive into /home/user1/myarch.tar, including all files ending in .c, .h, .l, .y,.o and .cc and also the Makefile from two directories, ~/dir1 and ~/dir2.
Answer:
tar cvf /home/user1/myarch.tar ~/{dir1,dir2}/{Makefile,*.{c,h,l,o,y,cc}}
or
tar cvf /home/user1/myarch.tar ~/dir1/Makefile ~/dir1/*.[chloy] ~/dir1/*.cc ~/dir2/Makefile ~/dir2/*.[chloy] ~/dir2/*.cc
24: Your script must be executed with exactly two arguments, otherwise would be terminated. Write a code to implement these checks.
Answer:
if ($#argv <> 2) then
echo Usage: $0 arg1 arg2
echo "You must give exactly two