Starting from:

$30

Systems Programming Homework 1

 CSc 3320: Systems Programming
Homework1
KEY
# 1: Total points 100
PART 1
Points per question: 5
1. Tell the differences between Unix and Linux. Then please list some
operating systems (at least three) which belong to Unix but notLinux.
 A.
★ There are many differences. However, your answer must include “Linux
is one of the distributions of Unix system”. (3 points)
★ The following OS belongs to Unix, but not a linux:
○ BSD, Solaris, Mac OS and etc.
(2 points, -1 point if missing one or two)
Refer to more details under link below
https://www.cyberciti.biz/faq/what-is-the-difference-between-linux-a ndunix/
2. What is the pipe mechanism in UNIX? And show one command using pipe
and explain how the pipe works in it?
A.
 ★ Pipe: take the output from one command as the input of next command
(2 point)
 ★ Example & Explanation (3 points)
3. In a Linux system, you can issue the command ls / to check the sub
directories under root. Please describe the meanings of directory /bin, /dev,
/boot, /usr, /etc, /mnt, /sbin, /var separately. For example, you can say that
/bin contains binary executable files.
A. (each for half points)
★ /bin : contain binary executable files
★ /dev : contain device files
★ /boot : boot-loader related files
★ /usr : user’s programs and files
★ /etc : configuration files
★ /mnt : temporary mount directories
★ /sbin : contain binary executable files
★ /var : contain variable files
Refer to more details under the link below
http://www.thegeekstuff.com/2010/09/linux-file-system-structure/?u
tm_source=tuicool
4. What is the meaning of Multitask and Multi-user in a Unix system?
A.
Multitask: multiple tasks are running at the same time (2 Points)
Multiuser: multiple users can access to the system at the same time. (3 Points)
5. What does -rwxr-xr-x mean in terms of permissions for a file? What is the
exact unix command (with the octal representation) for changing the
permissions to this setting?
A.
Users can read, write, and execute. Group and others can read and
execute but cannot write. (3 Points)
rwx - read “on”, write “on”, execute “on” – 111 – 7
r-x - read “on”, write “off”, execute “on” – 101 – 5
r-x - read “on”, write “off”, execute “on” – 101 – 5
UNIX Command:
chmod 755 <file-name> (2 Points)
6. In class, you have learned the meaning of read, write and execute
permission for regular files. However, these permissions are also applied to
directories. So please describe the meaning of read, write, and execute
permission for directory.
A.
read : list the content in the directory (2 Points)
write : create , remove the directories or files in the directory (2 Points)
execute : enter into the directory (1 Point)
Part II-a
Regular Expression
Find outcomes for each given basic/extended regular expression
(maybe multiple correct answers)
Points per question: 2.5
Note: 7) to 10) are basic regexes; Note: 11) to 18) are extended regexes.
7) ‘a[ab]*a’
A. ababa, aaba, aabbaa, aa
Starts with ‘a’, ends with ‘a’, with 0 or more ‘a’s or ‘b’s in between
8) ‘a(bc)?’
A. abc, a
Starts with ‘a’ followed by 0 or 1 ‘bc’s
9) ‘.[ind]*’
A. wind, end
 Start with any character but end with a combination of “i”, “n” and “d”
10) ‘[a-z]+[a-z]’
A. xa
One or more lowercase letters followed by a lower-case letter. Matches any
string of lowercase letters of size 2 or more
11) ‘[a-z] (\+[a-z])+’
A. a +b+c, x +a
An expression for adding multiple variables followed by space, each variable
should be represented by a lower-case letter.
 12) ‘a.[bc]+’
 A. azbc, azbcbc, acc
 “a” appears at the beginning, followed by any single character, which is then
followed by a combination of “b” and “c”
Example:
‘ab+a’ (extended regex)
Answer: aba , abba ; Pattern : The matched string should begin and end
with ‘a’ and ‘b’ occurs at least once between leading and ending ‘a’)
13)‘a.[0-9]’
A. a01
Starts with ‘a’ followed by any character, followed by a number
14) ‘[a-z]+[\.\?!]’
A. good! hard? cool?
Starts with 1 or more lowercase letters followed by a ‘.’, ‘?’ or a ‘!’
15) ‘[a-z]+[\.\?!]\s*[A-Z]’
A. book. Z
Starts with 1 or more lowercase letters, followed by a ‘.’, ‘?’ or a ‘!’, followed by
0 or more whitespace characters, followed by a capital letter
16) ‘(very )+(cool )?(good|bad) weather’
 A. very good weather, very cool bad weather
Starts with 1 or more ‘very ‘s, followed by an optional ‘cool ‘, followed by ‘good’
or ‘bad’, followed by ‘weather’
 17) ‘-?[0-9]+’
 A. 3312(positive or negative integer), -2231
Starts with an optional ‘-’ followed by 1 or more numbers
18) ‘-?[0-9]*\.?[0-9]*’
A. 3312, -2231, 2/3
Starts with an optional ‘-’, followed by 0 or more numbers, followed by an
optional ‘.’, followed by 0 or more numbers.

Part II-b
 Regular Expression
Write down the extended regular expression for following questions.
E.g. Social security number in the format of 999-99-9999. Answer: [0-
9]{3}-[0-9]{2}-[0-9]{4}
Points per question: 5
19) Valid URL beginning with “http://” and ending with ".edu"(e.g.
http://cs.gsu.edu, http://gsu.edu)
A. http:\/\/.+\.edu
 http:\/\/ 2 point
 .+ 1 point
 \.edu 2 point
20) Non-negative integers. (e.g. 0, +1, 3320)
A. \+?[1-9][0-9]*|0
\+? 2 point
[1-9][0-9]* 2 points
|0 1 point
21) A valid absolute pathname in Unix (e.g. /home/ylong4, /test/try.c)
A. \/ 1 point
(\w*\/)* 2 point
(\w*|\w*.\w*) 2 point
22) Identifiers which can be between 1 and 10 characters long, must start
with a letter or an underscore. The following characters can be letters or
underscores or digits. (e.g. number, _name1, isOK).
A.
[a-zA-Z_][a-zA-Z0-9_]{0,9}
[a-zA-Z_] 2 point
[a-zA-Z0-9_] 2 point
{0,9} 1 point
23) Phone number in any of the following format: 9999999999,999-999-
9999, (999)-999-9999. (Note: all of these formats should be matched by a
single regular expression)
A. \(?[0-9]{3}\)?-?[0-9]{3}-?[0-9]{4}
\(?[0-9]{3}\)? 1 point
-? 1 point
[0-9]{3} 1 point
-? 1 point
[0-9]{4} 1 point
Part III
Programming
Points per question: 15
24. Create a file named homework_instructions.txt using VI editor and type in
it all the submission instructions from page1 of this document. Save the file in
a directory named homeworks that you would have created. Set the
permissions for this file such that only you can edit the file while anybody can
only read. Find and list (on the command prompt) all the statements that
contain the word POINTS. Submit your answer as a description of what you
did in a sequential manner (e.g. Step1 … Step 2… and so on..). Add a screenshot
(Points per step:1)
Step1: Create homeworks directory on the local machine (mkdir homeworks)
Step2: Change the directory to homeworks (cd homeworks)
Step3: Create homework_instructions.txt file (vi homework_instructions.txt)
Step4: Press i and enter into insert mode
Step5: Copy and paste the homework instructions
Step6: Press esc key and use command wq (write and quit)
Step7: Check the current permissions (ls -la)
Step8: Change the permission as required i.e you can edit the file while
anyone can only read (chmod 644 homework_instructions.txt)
Step9: use command (cat homework_instructions.txt) to display the contents
in the file
Step10: Search for POINTS keyword (grep POINTS)
(Screenshot is attached below) - 5 Points

More products