Sunteți pe pagina 1din 5

Explore   Hi Adjvane 

25+
£4.45

CMP5067 Open Systems UG2 B S1 2017/8

Search courses 

 My courses Computing, Engineering and the Built Environment School of Computing and Digital Technology CMP5067-B-S1-2017/8 Resources

Mock Exam - Practical

Started on Tuesday, 23 January 2018, 2:50 PM


State Finished
Completed on Thursday, 25 January 2018, 3:35 PM
Time taken 2 days
Grade 25.00 out of 100.00

Information

Flag question
SECTION B
Answer ALL questions
Credit will be given for partially correct answers, so always make an attempt
Write all answers in the spaces provided.
Remember Linux commands and paths are case sensitive.
Remember, you may make use of the Linux virtual machines to answer these questions
Where differences exist between implementations of the Linux operating system, provide an answer that will work in the virtual machines
provided.
Remember to create a PDF backup of your answers before proceeding to the next page. Ask if you are unsure how to do this.

Question 1 Match the command with the description of that command.


Partially correct
Description Command
Mark 9.00 out of
Concatenate files or display a file on the screen cat
10.00

Flag question Display the routing table route

Display text a screen at a time more

Delete a populated directory rm -rf

Archive files tar

Display a dynamic list of running processes ps

Change the working directory cd

Delete a file rm

Display a static list of running processes ps

Display text one line at a time less

Question 2 Complete the following table of options and associated functionality for the command 'cp'. You will need to make use of appropriate help resources within the
Not answered virtual machine to achieve this. When entering an option, enter only one of option including any leading dashes (-) that may be needed.

Marked out of 5.00 Option Summary of functionality


p y y

Flag question Operate recursively (copy sub-files and directories)

Do not overwrite existing files

Explain what is being done

-i

--update

Answer: man cp to open the man file for cp. Individual answers:
Operate recursively = -r, -R or --recursive
Do not overwrite existing files = -n or --no-clobber
Explain what is being done = -v or --verbose
-i = interactive mode = prompt before overwriting
--update = only overwrite files with newer versions

Question 3 Create at directory in your home directory called 'Buggles'.


Partially correct
student@admin:~ $ mkdir Buggles
Mark 3.00 out of
3.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: mkdir Buggles. mkdir is used to create a new directory. This question is made easier as the new directory needs to be in out home
directory. Take care though, 'Buggles' has a capital 'B' so using lower case would be wrong. Also, note that '/Buggles' would be wrong as this
would try to place the directory off the root of the file system.

Question 4 Create three files in the 'Videos' directory called 'tv', 'radio' and 'star' using the least number of commands.
Incorrect
student@admin:~ $ touch Videos/{tv.file,radio.file,star.file}
Mark 0.00 out of
4.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: touch Videos/tv Videos/radio Videos/star. Here the touch command is used to create blank files by supping the path and filename as an
argument. Note that multiple files can be created by supplying multiple arguments and that the path does not have a leading '/' as it is a relative
path in this case. Note also that the 'V' of 'Videos' is capital letter.

Question 5 Using the command line, create a user called 'bob' with a user ID (UID) of 1234'.
Partially correct
student@admin:~ $ sudo useradd -u 1234 bob
Mark 5.00 out of
5.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: sudo useradd -u 1234 bob. Here we use useradd to a user called bob (note his name is all lower case, Linux is case sensitive!). We use
the '-u' option to specify a user ID, with a value of '1234' as indicated in the question. As not everyone should be bale to add new users, this
command require root privileges, so we need to use the 'sudo' command to obtain this.

Question 6 Change the ownership of the file 'tv' such that the user 'bob' is the owner.
Incorrect
student@admin:~ $ cd Videos
Mark 0.00 out of
5.00
student@admin:~ $ sudo chown bob tv.file
Flag question

student@admin:~ $
Answer: sudo chown bob Videos/tv. Here we use the chown command to change the owner of a file. We need to specify the file (Videos/tv) and
the new owner (bob) as arguments to this command. Ownership needs to be changed by the root user, so we need to prefix our command with
'sudo'.

Question 7 From the command line, create a new user group called 'fish'.
Partially correct
student@admin:~ $ sudo groupadd fish
Mark 3.00 out of
3.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: sudo groupadd fish.


Here, we use the command 'groupadd' to add the group. We need to supply the group as an argument (fish). As adding a new group is not
something every user should be permitted to do, we need to use 'sudo' to gain root privileges.

Question 8 Modify the permissions of the file 'star' such that the owner can read, write and execute, the owning group can read and execute and everyone
Incorrect else has read-only access.

Mark 0.00 out of student@admin:~ $ chmod u=rwx,g=rx,o=r-- Video/star.file


6.00

Flag question student@admin:~ $

student@admin:~ $

Answer: chmod 754 Videos/star or chmod u=rwx,g=rx,o=r Videos/star.


Explanation: Here we use the 'chmod' command to change the permissions (or mode) or the file. This needs the arguments of the file permissions
and the file we need to change the permissions of. In this case the file is 'Videos/star' and the permissions are 754 (where read = 4, write = 2 and
execute = 1). We do not need to use 'sudo' as we are the owner of the file.

Question 9 Configure the eth1 network interface with an IP address of 192.168.5.2 and a subnet mask of 255.255.224.0
Incorrect
student@admin:~ $ ifconfig 192.168.5.2 netmask 255.255.224.0
Mark 0.00 out of
6.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: sudo ifconfig eth1 192.168.5.2 netmask 255.255.224.0. The 'ifconfig' command can be used to set and display IP address information as
well as enabling and disabling a network interface. Here we use it with the arguments of the network interface that we wish to add an address to
(eth1), the IP address (192.168.5.2) the argument 'netmask' followed by the subnet mask (255.255.255.224)

Question 10 Archive the contents of the 'Downloads' directory into a zipped tar file stored in your home directory called 'tarball'
Incorrect
student@admin:~ $ tar -czvf tarball.tar.gz Downloads
Mark 0.00 out of
8.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: tar -czf tarball Downloads


Here we use the tar command with the -c option to create a new tar archive. In addition, we need to specify the -z option to compress the file and
then -f to specify the name and path to the file we wish to create (tarball). Finally, the final argument is the name and path to the directory we
wish to archive (Downloads). we do not need to provide additional paths as all of the files and directories are contained in our home directory and
that is our present working directory. 

Question 11 Install the program 'xfonts' from a file using the relevant command. The file can be found in the packages directory on the Packages2014.iso
Partially correct virtual CD ROM (see rubric for location)

Mark 5.00 out of student@admin:~ $ sudo dpkg -i /media/student/Packages2014/packages/xfonts-100dpi_1.0.


5.00
Flag question student@admin:~ $

student@admin:~ $

Answer: sudo dpkg -i /media/student/Packages2014/packages/xfonts-100dpi_1.0.3_all.deb


Explanation: Here we use the 'dpkg' command with the option '-i' to install a package. The path to the package must be supplied as an argument
which we in this case is '/media/student/Packages2014/packages/xfonts-100dpi_1.0.3_all.deb'. As not everyone should e able to install software
to the system, we need to use the 'sudo' command to obtain root privileges.

Question 12 Specify a command that will list files in the /sbin directory with an extension of '.ext3', showing the permissions of each file. The result should be
Not answered displayed on the screen.

Marked out of 5.00 student@admin:~ $


Flag question
student@admin:~ $

student@admin:~ $

Answer: ls -l /sbin/*.ext3. Here we use the 'ls' command with the '-l' option to list the contents of a directory showing file permissions. As we want
to list the contents of the '/sbin' directory we need to supply the path as an argument. Additionally, we are only looking for files with a '.ext3'
ending, so we use the wildcard '*' to allow us to match zero or more characters in the file name followed by the ending of '.ext3'.

Question 13 Append to a file in your home directory called 'water.txt' a list of all processes that have the string 'er' at the end of their name.
Not answered
student@admin:~ $
Marked out of 8.00

Flag question student@admin:~ $

student@admin:~ $

Answer: ps -A | grep er$ >> water.txt. Here we need to use the 'ps' command with the option '-A' to generate a list of all running processes. Once
this has been done, this output is sent via a pipe (|) to the command 'grep' that searches the output using a regular expression. The expression
used is 'er$' where the '$' indicates that the string 'er' should be the last item on a line. The results of this are then redirected to a file via the '>>'
operator. This operator adds to an existing file (appends) whereas '>' would overwrite any existing file.

Question 14 List the contents of the '/var' directory ensuring that any hidden files are shown, appending the result to a file called 'list' in your home directory.
Not answered
student@admin:~ $
Marked out of 6.00

Flag question student@admin:~ $

student@admin:~ $

Answer: ls -a /var >> list. 'ls' is the command used to list the contents of a directory. In order to display files that are normally hidden (those
starting with a dot), we need to use the option 'a-'. As we are not listing the contents of the present working directory, we also need to supply the
path to directory we wish to list, in this case '/var'. Normally, this would display via standard output on the screen, but we wish to redirect it so it is
appended to a file in out home directory called 'list' we do this with the '>>' operation which redirects and appends, not overwrites (which would be
the '>' operator). Note that we do not need to supply a path to the file 'list' as it needs to be in our home directory which is our present working
directory.

Question 15 Remove all software with the string 'libreoffice' in its name from the system.
Not answered
student@admin:~ $
Marked out of
21.00
student@admin:~ $
Flag question

student@admin:~ $

Answer: sudo dpkg -P --force-depends `dpkg-query --list | grep "libreoffice" | tr -s " " | cut -f 2 -d " "`. This is quite a complicated one – so hold on!
Here we need to find out what packages have the string 'libreoffice' in before we can remove them with 'dpkg' command. In order to do this, we
use 'dpkg-query --list' to display all installed software and then pipe the output of this to 'grep' to pull out just the lines containing 'libreoffice'
command Once we have those lines we then need to pull from this just the names of of the software from all of the other information We use the
command. Once we have those lines, we then need to pull from this just the names of of the software from all of the other information. We use the
'cut' command to do this, but we need to remove multiple spaces before we can do this with the 'tr -s “ “' sequence. Once this has been done and
each filed is separated by just one space, we can use 'cut -f 2 -d “ “' to pull out the second filed (the software name) from the data. Note that the
sequence '`dpkg-query --list | grep "libreoffice" | tr -s " " | cut -f 2 -d " "`' is in backticks (``). This means it is executed first, so the list of installed
software is first obtained and the passed to 'dpkg -P –force-depends' to remove. '--force-dependes' is needed as the software supplied to 'dpkg -
P' may be in such an order that dependent packages are removed before ones that depend upon them.

Information

Flag question
END OF EXAM
REMEMBER TO MAKE A PDF BACKUP BEFORE SUBMITTING - ASK IF YOU ARE UNSURE HOW TO DO THIS
Once you have submitted, please use remember to upload your PDF to the 'Backup Submission' link in the assessment section on
Moodle

Finish review

Quiz navigation

i 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i
Finish review

Contact Us
Birmingham City University
University House
15 Bartholomew Row
Birmingham
B5 5JU
United Kingdom
+44 (0)121 331 5000

Our Faculties
 Art, Design & Media
 Business, Law & Social Sciences
 Computing, Engineering & The Built Environment
 Health, Education & Life Sciences
Connect




Help
 Accessibility
 Availability
 Moodle Help
 Moodle Feedback
 IT Help
 IT Feedback

© Birmingham City University 2014

Page loaded in 0.44 seconds

S-ar putea să vă placă și