################################################################ # # Final Quiz for CS 390 Spring 2020 # # Total POINTS: 20 # ################################################################ 1. Regarding shell variables, which of the following is true? a. A local shell variable is available to the shell where it is defined; while an environment variable is available to all the shells. b. Local shell variables are available to the shell where the variables are created, and all its subshells c. Environmental shell variables are available to every user of the system. d. Local shell variables are available to the shell where the variables are defined; while environment variables are available to the shell where they are defined, as well as all its subshells 2. Compare and contrast program and process 3. Explain very briefly the four system calls involved during a process life cycle? (the basic sequence these system calls involved) 4. Explain the following three special shell variables echo $$ echo $? echo $! 5. Program retrieve.sh take one argument and display the retrieved information to the screen. Give the command to run this retrieving process in background (redirect the screen output to a file retrieve.log, append to the file if exists) 6. If fname=home/cs/jsmith/script.sh, what will be displayed with the following commands. a. echo ${fname#*/} b. echo ${fname##*/} c. echo ${fname%/*} d. echo ${fname%%/*} 7. What file is created after executing command gcc hello.c on a Linux system? a. hello.o b. hello c. a.out d. hello.exe 8. What file is created after executing command c++ -c hello.cpp on a UNIX system? a. hello.o b. hello c. a.out d. hello.exe 9. Give the command to compile a C++ program test.cpp to create an executable “test” 10. GCC C++ compiler has several levels of optimization (0-3). What is the general purpose of these optimizations? a. make the program run faster b. make the size of the program smaller c. both (a) & (b) d. (a) OR (b) 11. Some functions used in C program salary.c are defined in a library libemployee.so. To build the executable salary, it needs to link to this library which is in the same directory as program salary.c a. Is this library: libemployee.so a shared or static library? Which of the following is the correct command line to build the application c. gcc salary.c -lm d. gcc -Wall -O2 -o salary -lemployee salary.c e. gcc salary.c -Lemployee.so -o salary f. gcc -O2 -L./ salary.c -llibemployee –o salary g. gcc -O2 -o salary -L./ salary.c -lemployee -lm 12. Compare and Contrast an program built with shared library and static library (pros and cons) 13. Keep the original below, followed with the fixed #/bin/bash # Buggy bash script to be fixed # After fixing it, it should display the files under that directory exist, and "File abcdef does not exist" # and display "DONE" to screen before exit # # create ls.txt ls -a > ls.txt echo abcdef >> ls.txt for $foo in "cat list.txt"; then if (-e foo); then echo File foo does not exist else echo File foo exist endif endif print DONE