Recent Question/Assignment

Student Name:
PLACE LABEL HERE
Student Number:
Student Signature:
Calculator Make & Model:
(Failure to complete this section may delay the release of your grade)
Faculty of Health, Engineering and Sciences
Course code: CSC2408 Course Name: Software Development Tools
Campus: Springfield, Toowoomba Mode: On-Campus, Online
Examination Period: Semester 1, 2019 Examination Duration: 2 hours 0 minutes
Perusal: 10 minutes
Total examination marks:
Examiner: Zhongwei Zhang Moderator: Leigh Brookshaw
Examination: ? End of Semester ? Deferred ? Supplementary
THIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM
Students are advised to use the perusal time to read through the examination paper, but are permitted to commence writing on any part of the examination paper, booklet or answer sheet if they wish.
Students must comply with USQ mandatory examination conditions.
Special Instructions:
This examination is: ? Closed ? Open ? Restricted
The following conditions apply to this examination:
Permitted calculator:
? No Yes ? Non-programmable ? Programmable
Permitted un-marked, non-electronic, non-technical, non-diagrammatic language translation dictionary: ? No ? Yes
Permitted un-marked, non-electronic, non-technical, non-diagrammatic language dictionary: ? No ? Yes
Other permitted printed or written material:
No additional materials are allowed in the exam room.
OFFICE USE ONLY
Questions / Part Result
Any non-USQ copyright material used herein is reproduced under the provisions of Section 200 (1) (b) of the Copyright Amendment Act 1980.
This page has been deliberately left blank

Part 1.
There are 14 multiple choice questions. (For each question, select one choice only on the
Answer Booklet) (Total:28)
1) Linux operating system is a powerful environment in developing computer software. Which one of the following statements is most appropriate?
A) It has a lot of utilities and system libraries that are necessary for the development of network applications and servers.
B) It has many GUI programs which can be used to do computer/network admin.
C) It is a product of many PC manufacture’s collaborative efforts.
D) It provides an excellent Desktop publishing and online gaming platform. (2 marks)
2) Programs and processes are two primary objects in Linux operating system. Which one of the following statements best describes a process?
A) A process is a program.
B) A process is a file.
C) A process is not a program.
D) A process is a program with a process ID(PID).
E) A process is a program in action. (2 marks)
3) Linux operating system comprises a kernel and filesystem. Which one of the following statements is true whilst describing a Linux filesystem?
A) A separate system residing on the top of Linux operating system.
B) A data structure that regulates all files including ordinary files, directory files, and device files, etc on the Linux system.
C) An open source software that mainly used on the Linux system to manage files.
D) A standard for Hierarchical Linux Filesystem. (2 marks)
4) Unlike on the ordinary files, the permission bits on the directory work differently. If a directory’s permission bits have the ‘r’ bit off, but the ‘x’ bit on, which one of the following operations cannot be performed on the directory ?
A) Changing into the directory (cd).
B) Listing the contents of the directory (ls -l).
C) Listing the directory information(ls -ld).
D) Performing any operations which have been granted on the files in the directory if you knew their filenames. (2 marks)
5) Which one of the following objects on the Linux filesystem uses the inode data structure? (2 marks)
A) Ordinary files, directories, devices and links.
B) Processes, programs and standard files.
C) Jobs, images, audio, video files.
D) Partitions, devices, soft links.
6) The Linux environment has been specified by many environmental variables (ie a series of name-value pairs). Which one of the following environmental variables is used to specify the character encoding scheme?
A) LC_COLLATE B) LC_CTYPE
C) LC_MESSAGES
D) LC_CONFIRMATION
E) LC_MONETARY (2 marks)
7) There are a variety of simple text editors available in Linux. Which one of the following text editors is available on all Linux distros and highly recommended to write computer softwares such as program source codes, configuration files and documentation on Linux systems?
A) vim – An improved version of vi editor available on traditional Unix.
B) notepad – An simple text editor available on all Windows system.
C) gedit – A text editor on Linux systems.
D) None of the above. (2 marks)
8) Which one of the following command lines copies all those HTML files from the current directory to the subdirectory called dest that don’t exist in dest or are newer than the versions in dest?
A) cp *.html dest
B) cp -u *.html dest
C) cp -new *.html dest
D) cp html dest
E) None of the above. (2 marks)
9) Disk Partitioning is a technology used to divide a large storage device into a number of partitions. What does /dev/sdb1 refer to ?
A) partition 2 on the second PATA hard disk.
B) partition 2 on the second SATA hard drive. C) partition 1 on the second SATA hard drive.
D) partition 1 on the second PATA hard disk. (2 marks)
10) The X Window System provides the foundation for the GUIs available in Linux environment. Window managers are X clients that control the appearance and behavior of the windows where the various graphical applications are drawn. Which one of the following is widely used as a Window manager on a Debian GNU/Linux system? (2 marks)
A) KDE B) FVWM
C) kwin
D) LightDM
E) GNOME
11) One of Linux’s most impressive strength is its rich software development environment. Which one of the following statements best describes a computer software?
A) A computer software is a snippet of code.
B) Computer softwares are computer instructions.
C) A computer software is a set of programs, which have been written in programming languages.
D) A computer software is one Bash script.
12) Revision control is vital to quality software development. What does the Revision Control System do within the software development process?
A) Checks in software into an archived file.
B) Releases an executable from an repository.
C) Updates the version number of software programs.
D) Controls what goes into a release of software and keep track of it after it is released. (2 marks)
13) TEX and LATEX are document typesetting packages. Which one of the following statements is most precise?
A) Like MS word, they are kind of what you see is what you get (WYSIWYG).
B) Like HTML, they are kind of tags/commands to describe how the enclosed text should display?
C) They are Linux utilities that can be used to edit LATEX text files.
D) They are Linux programs, which produce the table of contents, Greek symbols and math formula, tables, etc. (2 marks)
14) “Shell” is an important program on Linux operating systems. Which one of the following statements is most relevant? (2 marks)
A) A user command interpreter and an interface between the Kernel and user.
B) A protection layer preventing users from misusing the Kernel.
C) A border between user-space and kernel-space.
D) A program allowing users to log on to the system.
Part 2.
There are 15 multiple choice questions. (For each question, select one choice only on the
Answer Booklet) (Total:30)
15) The details of the information provided by the ls -l command as shown in Figure 1. Which of the following statements is true? (2 marks)
March 22 2019
zhongweilinuxstaff 1452 ass1.txt
Figure 1:
A) 1 is File Type, 2 is File Permissions, 3 is File Size;
B) 1 is File Permissions, 2 is File Name, 3 is Hard Link Count
C) 1 is File Permissions, 2 is Hard Link Count, and 3 is File Size
D) 2 is File Type, 1 is File Permissions, and 3 is File Size
25) The output listing of the command ‘locale’ is as follows:
LANG=en_US.UFT-8
LC_CTYPE=-en_US.UTF-8-
LC_TIME=-en_US.UTF-8- LC_COLLATE=-en_US.UTF-8-
.......
Which one of the following command lines changes the locale to use the traditional Unix behaviors?
A) export locale=UNIX B) export LANG=POSIX
C) export locale=POSIX
D) export locale Unix (2 marks)
35) Which one of the following command lines specifies the default permission of 755 for a directory when the directory is created by use of the Linux command mkdir? (2 marks)
A) umask 022
B) umask 033
C) umask 744
D) umask 755
45) egrep is used to search words in the named input file such as /usr/share/dict/words. Which one of the following command lines prints all English words containing no vowel?
A) egrep --no -^[aAeEoOiIuU]+$- /usr/share/dict/words B) egrep -^[^aAeEoOiIuU]+$- /usr/share/dict/words
C) egrep -![^aAeEoOiIuU]+$- /usr/share/dict/words
D) egrep -^[!aAeEoOiIuU]+$- /usr/share/dict/words E) egrep -^[aAeEoOiIuU]+$- /usr/share/dict/words
55) If you want to redirect all of a utility’s (ie. myprog) standard output and standard error into an ordinary file called outmess, which one of the following commands is to use?
A) myprog 1 outmess &2
B) myprog outmess 1 &2
C) myprog outmess 2 &1
D) myprog 1 outmess &2 outmess
E) myprog 1 outmess &2 (2 marks)
65) Variable substitution is one of many Bash features. Consider the following Bash commands:
[zhongwei@debian-d113-twb ~]$ foo=JPG.JPG
[zhongwei@debian-d113-twb ~]$ echo ${foo/%JPG/jpg}
Which one of the following filenames is the output listing of ‘echo’ builtin?
A) jpg.JPG
B) Jpg.jPG
C) jpg.jpg
D) JPG.jpg
E) JPG.JPG (2 marks)
75) Linux filename globing is a Bash feature. Which one of the following descriptions best explains what ‘ls a*bc.???’ does? (2 marks)
A) show a file whose filename body is ‘a*bc’, and its extension is ‘???’.
B) show all files whose filename’s body beginning with a letter ‘a’ followed by any characters and ending with two letters ‘bc’, and filename’s extension must have 3 characters.
C) show all files whose filename’s body beginning with zero or one occurrence of ‘a’, followed by ‘bc’, and filename’s extension must have three ‘?’.

85) Linux Bash filename expansion is a very useful feature. There are six ordinary files in the working directory as shown in Figure 2.

Figure 2:
There is an error message saying “rm: cannot remove ‘abc’ No such file or directory”. Which one of following explanations is true?
A) shell cannot remove ‘abc’ because ‘abc’ never existed. B) shell cannot remove ‘abc’ because ‘ab*’ doesn’t match ‘abc’
C) shell expands ‘ab*’ into ‘abc’, ‘abd’, ... so ‘rm abc ab*’ attempted to remove ‘abc’ twice.
D) shell cannot remove ‘ab*’ because there is no file with that name.
95) The SED is a stream editor, which has its own commands. Consider a sed command that copies a file to standard output, replacing a single SPACE as the first character on a line with a 0 (zero) only if the SPACE is immediately followed by a number (0-9). For example
abc == abc abc == abc 85c == 085c 55b == 55b
000 == 0000
Which one of the following command lines is the correct one?
A) sed ‘/( )([0-9])(.*)/d’ testfile
B) sed ‘s/([0-9])(.*)/012/’ testfile
C) sed ‘s/( )([0-9])(.*)/023/g’ testfile
D) sed ‘s/ (.*)/01/g’ testfile (2 marks)
105) Both the Linux filename globing and the regular expressions(REs) technique use some meta-characters. Which of the following descriptions best describes the command-line grep ‘abc*’ abc*? (2 marks)
A) display all the lines containing ‘ab*’ in the file whose filename is ‘ab*’.
B) show all the lines containing ‘ab’ or ‘abc’, or ‘abcccccc’ in all files whose filename starts with ‘abc’.
C) list all the lines containing ‘ab’ or ‘abcccccc’ in all files whose filename starts with ‘abc’.
D) print out all the lines containing ‘ab’ or ‘abcccccc’ in the files whose filename is
‘ab*’.
115) The SUID is a special permission bit, which gives the process executing the file the privileges of the file’s owner. Consider the output listing from the command ls -l /usr/bin
-rwsr-xr-x 1 root root 23420 Aug 3 2010 passwd
Which one of the following statements is correct when passwd is run
A) The owner: root cannot run this program
B) Only the owner: root can run this program
C) Anybody can run this program but with the effective user ID of the owner:root
D) None of the above
125) Which one of the following command lines deletes all files that have the filename extension .BAK in the user’s home directory?
A) find /usr/home ’BAK’ | rm
B) find ~ -type f -name ’BAK’ delete
C) find ~ -type f -name ’*.BAK’ -delete
D) find ~ | rm *.BAK (2 marks)
135) The following sequence of command lines will print out the file: list.
$ sort list temp
$ lpr temp
$ rm temp
Which one of the following command lines will do the same?
A) lpr list | sort
B) cat list | lpr
C) sort list | lpr
D) rm list | sort list (2 marks)
145) To produce the equation , which one of the following Latex commands (2 marks)
is correct?
A) ( lim{x ightarrow 0}e^{frac{sin(x)}{x}} = e ) B) $lim_{x ightarrow 0}e^{frac{sin(x)}{x}} = e$
C) [ lim{x rightarrow 0}e{frac{sin(x)}{x}} = e ]
D) lim^{x rightarrow 0}e_{frac{sin(x)}{x}} = e
155) GIT is the most versatile distributed version control system. Which one of the following statements is true about? git clone gituser@git.usq.edu.au:~/CSC2408 (2 marks)
A) Creates a local repository of the project under the CSC2408/.git directory in your home directory.
B) Create a directory where you can directly see the files. This is called the working area.
C) Create a staging area. The staging area is designed to store changes to files before you commit them to the local repository. D) All of the above.
E) None of the above.
Part 3.
There are 10 multiple choice questions. (For each question, select one only from multiple choices on the Answer Booklet) (Total:20)
1) Which one of the following command lines will print the current date in the form of
DD-MM-YYYY? (for example 31-08-2018)
A) date DD-MM-YYYY B) date --current
C) date +%d-%m-%Y
D) date +%D%M%Y (2 marks)
2) Which one of the following statements will add the directory /usr/games to the end of the list of directories in PATH in Debian GNU/Linux Bash?
A) set PATH=$PATH:/usr/games B) set PATH=PATH:/usr/games
C) export PATH=PATH:/usr/games
D) export PATH=$PATH:/usr/games (2 marks)
3) There are a number of running processes as shown in Figure 3. (2 marks)

Figure 3:
Which one is the PID of the grandparent process of the process started by ‘find’ command?
A) 21977
B) 22000
C) 22010
D) 22020
E) 22038
4) Which one of the following statements defines an alias for converting and shrinking a GIF image to PNG format?
A) set gif2png=‘giftopnm image.gif | pmnscale 0.25 | pnmtopng smallimage.png’ B) define gif2png=‘giftopnm image.gif | pmnscale 0.25 | pnmtopng - smallimage.png’ C) alias gif2png=‘giftopnm image.gif | pmnscale 0.25 | pnmtopng smallimage.png’ D) gif2png=‘giftopnm image.gif | pmnscale 0.25 | pnmtopng smallimage.png’
5) While vim is in the command mode, which one of the following key strokes moves the (2 marks) cursor to line 24?
A) type Shift+: w 24, then ENTER B) type Shift+G 24, then ENTER
C) type 24, then Shift+G
D) type Shift+G, then 24
6) While vim is in the command mode, it’s possible to insert an entire file (f.txt). Which (2 marks) one of the following key strokes is right?
A) Move the cursor to the line where to insert. Then type f.txt, then ENTER
B) Move the cursor to the line where to insert. Then type Shift+:, then r f.txt, then ENTER
C) Move the cursor to the line where to insert. Then type Esc, then ENTER
D) Move the cursor to the line where to insert. Then type Shift+G, then ENTER
7) Which one of the following Latex markup tags will typeset the algebra expression? (2 marks)
N
XaixN-i = a1xN-1 + a2xN-2 + ··· + aN
i=1
A) $ sum_{i=1}^N a_i x^N-i $ = a_1 x^{N-1} + a_2 x^{N-2} + cdots + a_N $ B) ( S a_i x^{N-i} = a_1 x^{N-1} + a_2 x^{N-2} + cdots + a_N )
C) [ sum_{i=1}^N a_i x^{N-i} = a_1 x^{N-1} + a_2 x^{N-2} + cdots + a_N ]
D) ( S_{i=1}^N a_i x^{N-i} = a_1 x^{N-1} + a_2 x^{N-2} + cdots + a_N ) E) ( S{i=1}^N a_i x^{N-i} = a_1 x^{N-1} + a_2 x^{N-2} + cdots + a_N )
8) Linux Bash is also a programming language. Which one of the following statements best (2 marks) describes what the command line doe:
[ ! -e temp -o ! -d temp ] && cd temp
A) checking if a subdirectory called temp exists,
B) if temp exists and it is a directory, then change the subdirectory called temp as the present working directory.
C) if temp dose not exist or it is not a directory, then change the subdirectory called temp as the present working directory.
D) checking if temp is a subdirectory,
9) The process of sending files from the working directory to the remote repository has to go through a series of steps as shown in Figure 4 . Which of the following statements best describes the Staged area? (2 marks)

Figure 4:
A) The Staged area is the last place when the file will be sent to the Remote repository.
B) The Staged area is the only place where the file is being committed to the Local repository.
C) The Staged area is the place where the file is stored after the file is changed in the Working directory, but before it is pushed to the Remote repository.
D) The Staged area is the place where the file is stored after the file is changed in the Working directory, but before it is committed to the Local repository.
10) Which one of the following statements best describes the command execution environment or the environment? (2 marks)
A) A Linux environment contains many environmental variables such as PATH, HOME, PWD, PS1, etc.
B) When the Linux kernel invokes a program, the kernel passes to the program a list comprising an array of strings. This list is called the environment.
C) A list which holds a series of name-value pairs in the form name=value, is called the command execution environment.
D) A Linux environment is a workspace within the memory allocated by the Linux kernel for a program to be executed.

Part 4.
There are 9 subquestions. (Select one choice only on the Answer Booklet) (Total:22)
1) Read through the following Bash script, then determine which of the following statements best describes what the script does.
1#!/bin/bash
2
3echo -Your programs:-
4ps -fe | grep $USER | more
5
6echo -n -Enter a PID to stop-
7read proc
8kill $proc
9
10echo -n -Enter name username or press enter: -
11read person
12
13echo -${person:-$USER} process:-
14ps -fe | grep -^${person:-$USER}- | more
A) First, it lists out all running process of the user: USER, then it prompts the user to stop a PID. Finally, the script prompts to list out the running process of the users:person and $USER.
B) First, it lists out all running processes of the user: $USER, then it prompts the user to type in a PID to kill. Finally, the script prompts the user to list the person’s all running process. The person could be a different user or the same user.
C) First, it lists out the running process of the all users, then it reads and stops the proc. Finally, the script lists and filters the person’s USER when the person’s name is the same as $USER. (2 marks)
2) There are 4 errors or mistakes in the Bash script as given below. (2 marks)
1!#/bin/bash
2
3prog=${0#*/};
4if test # -eq 0; then
5echo -Usage: $prog file-;
6exit 1
7fi
8
9if [ -f -$1- ]; then
10echo ’$1 is an ordinary file in the working directory’
11else
12echo -$1 is NOT an ordinary file in the working directory-
13fi
Which of the following statements is true?
A) 4 errors in line 1, 3, 4 and 9;
B) 4 errors in line 1, 9, 10, and 12; C) 4 errors in line 3, 9, 10 and 12;
D) 4 errors in line 1, 3, 4, and 10;
3) Which one of the following statements describes what the following Bash script does. (2 marks)
1#!/bin/bash
2
3prog=$(basename $0)
4for file in $(ls *.txt); do
5echo -n -Display $file? -
6read answer
7if [ -a${answer}- == -ay- ]; then # ’a’ is deliberately used here
8more $file
9fi
10done
A) For the file with an extension of txt in the current directory, it displays a request without moving the cursor to the next line, waits for user’s answer, if the user types in ‘y’, then pages out the content of the file, otherwise, moves to the next file.
B) For the file with an extension of txt in the current directory, it displays a request, waits for user to type in his/her answer, if the user types in ‘y’, then pages out the content of the file, otherwise, moves to the next file.
C) For each of the files with an extension of txt in the current directory, it displays a request without moving the cursor to the next line, waits for user’s answer, if the user types in ‘y’, then pages out the content of the file, otherwise, moves to the next file.
4) The aspell utility checks the words in a text file against a dictionary of correctly spelled words. Consider the three code snippets given below:
# snippet A: #!/bin/bash prog=$(basename $0)
if [ $# -ne 2 ]; then
echo -usage: $prog dictionary_name file_name- exit 1
fi
---------------------------------------------------------# snippet B: aspell list -$2- | while read line do if ! grep -^$line$- -$1- /dev/null; then echo $line
fi
done exit 0;
-----------------------------------------------------------#snippet C:
if [ ! -r -$1- || ! -r -$2- ]; then echo -$1 or $2 is not readable- exit 1
fi
Which one of the following sequences combines all given snippets of code into a complete and workable Bash script?
A) A, C, B;
B) C, A, B;
C) A, B, C;
D) none of the above; (2 marks)
5) Which one of the following statements is best describe what snippet B given in 4) does? (2 marks)
A) aspell reads a list of strings from the file referred by the second argument ($2) in the command line, and sends each string to the shell and the shell reads each string into a variable called line, and then grep searches through the file referred by the first argument ($1) for the line which exactly matches the value of the variable (^$line$).
B) aspell reads a list of strings from the file referred by the second argument ($2) in the command line, and sends each string to the shell and the shell reads each string into a variable called line, and then grep searches through the file referred by the first argument ($1) for the line which is only composed by no more other than the value of the variable (^$line$). The if-statement will send the standard errors to a special file /dev/null, echo the mismatched word if grep is returned with a non-zero value.
C) aspell reads a list of strings from the file ($2) in the command line, and sends each string to the shell and the shell reads each string into a variable called line, and then grep searches through the file ($1) for the line containing the value of the variable (^$line$). The if-statement will send the standard errors to a special file /dev/null, echo the mismatched word if grep is returned with a non-zero value.
6) Given a Bash script as follows:
1#!/bin/bash
2# print a series numbers conditionally
3
4for index in 1 2 3 4 5 6 7 8 9 10; do
5if [ $index -le 3 ]; then
6echo -n -continue-
7continue
8fi
9echo -n $index
10if [ $index -ge 8 ]; then
11echo -break-
12break
13fi
14done
Which of the following is the output from execution of the script?
A) 1 2 3 4 5 6 7 8 9 10
B) continue continue continue 4 5 6 7 8 break
C) continue continue continue 4 5 6 7 8 break break
D) none of the above (3 marks)
7) Given a Bash script as below. (3 marks)
1#!/bin/bash
2
3FILE=~/.bashrc
4
5if [ -e -$FILE- ]; then
6if [ -f -$FILE- ]; then
7echo -$FILE is a regular file-
8elif [ -d -$FILE- ]; then
9echo -$FILE is a directory-
10elif [ -r -$FILE- ]; then
11echo -$FILE is readable- 12elif [ -w -$FILE- ]; then
13echo -$FILE is writable-
14elif [ -x -$FILE- ]; then
15echo -$FILE is executable-
16fi
17else
18echo -$FILE does not exist-
19exit 1
20fi
21exit 0
Choose the right answer for each of the questions
A) what does this Bash script do?
a) It checks the types of a hidden file in the user’s home directory
b) It defines the permission bits of a hidden file in the user’s home directory
c) It checks the types of a standard file in the root directory
d) It defines the types of a hidden file in the user’s home directory
B) what does the tilde ( ~ ) stands for (on line 3)?
a) It’s a special directory, links to user’s home directory.
b) It’s a meta-char, used to represent any letter of filename.
c) It’s a typo.
d) It’s a link file, always change to user’s home directory.
8) In the Bash script given in question 7) above, choose the right answer for each of the questions
A) what does the statement if [ -e -$FILE- ] do?
a) It checks whether the file $FILE exists and is executable.
b) It checks whether the file .bashrc in user’s home directory exists.
c) It checks the file ~/.bashrc equals to null.
d) None of the above.
B) what different between line 6 and line 10?
a) line 6 and 10 actually do the same check since a regular file is readable.
b) line 6 is to check if the file is a regular file; while line 10 checks whether the file is readable.
c) line 6 is to check if the file is a directory file; while line 10 checks whether the file is readable and regular file. (3 marks)
9) Still in the Bash script in question 7), choose the right answer for each of the questions. (3 marks)
A) line 5 is equivalent to
a) test -e -$FILE-; then
b) if test -e -$FILE-; then
c) -e -$FILE-; then
d) if [ test -e -$FILE- ]; then
B) what does line 8 (elif [ -d -$FILE- ]; then ) do?
a) it checks whether the file $FILE is removable file.
b) it checks whether $FILE is a directory file.
c) it checks $FILE is a hidden file.
d) none of the above.
Total mark: 100

End of the exam questions.