Lab 3

advertisement
Out: Sept 21st, 2014
Due: Oct 6th, 2014 (start of lecture)
This assignment is marked out of 32
CENG 200 – Lab 3
1. Web
Page Markup (12 marks)
Create a web page in your public_html directory in a file called index.html using
HTML markup.
Write a short biography two paragraph of yourself. At the end place a sample of some
code that you have written – either in C or in java along with a short description of
what the code does. The article should include the following features:
a. It should include an HTML generated heading and title. Using the HTML
macro in vim is recommended. Fill in the title with your name. (1)
b. You should use at least 2 of the h1-h6 tags for headings (1)
c. Add a picture with a caption to your biography. You can deep link to a
picture on the internet. (1)
d. Add a favourite quotation, either enclosed in a q tag or a blockquote tag. (1)
e. Add at least 4 additional text markups to your biography. (2 marks)
f. Format your program listing any two of code, var, pre, tty and samp tags.
(2)
g. Add a couple of HTML comments documenting some of what you’ve done
(1)
h. At the end include 2 hypertext links – one to the course web page and
another to the web site of a company that you would like to work for. (1)
i. Use curl to transfer an image from the internet to your public_html
directory and add the image to your web page. (Record your use of the curl
command.) (1)
j. Colourize two sections of your text using the font tag. In one case use hex
values; In another use rgb values. Note: the colours you use should be
readable against the web page’s background.
2. Hard
links and symbolic links. (6 marks, 1 mark each)
Record all commands used:
a. Record your terminal’s tty. In your home directory try creating a hard link
and a symbolic link to your terminal. Do both commands work? If either
command fails record the error message.
b. What is the inode # of the directory /usr and one of the directories in it?
c. How many hard links are there to the directory /usr? How would you
account for that number?
d. In your home directory create a hard link and a symbolic link to one of the
commands that you know how to use in /usr/bin. For each verify whether
or not you can use your hard or symbolic link to execute the command.
e. Create both a hard link and a symbolic link to the symbolic link you created
in the previous step. If either of these work this introduces 2 levels of
indirection which you can think of as: file2 -> file1 -> cmd
Record the commands you used. Test and report on which (if any) of these
secondary links can be used as an alias to the command
f. Use the file command on each of the files created in step e. What does it report?
Try again using the -L flag of the file command - refer to the man page for the
file command and explain the results.
3. Testing
the date command. (6 marks)
a. What is the difference in output between the following versions of the date
command:
date
date –u
b. Issue the following commands and record the results:
export TZ=Singapore
date
export TZ=Canada/Newfoundland
date
To restore the date to Toronto time,
export TZ=Canada/Eastern
c. Refer to the directory /usr/share/zoneinfo
the command:
To reset the current timezone issue
export TZ=filename
where filename is the name of a file within this directory. If the timezone file is in
one of the subdirectories you need to use the file name relative to the zoneinfo
directory: ie: TZ=Canada/Yukon. Search through the directories and set TZ to the
timezone for Nicosia which is the capital of Cypress in the eastern Mediterranean.
Note the time (and date) for the time here in Toronto and for the time and date in
Nicosia.
d. Issue the following command: date +"%A day %j of ‘%C"
Refer to the man pages for the date command. Describe the effect of each format
codes used.
e. What is the command to produce a date with the following (sample) format:
Its Tue, the 24th day of September, and 18 minutes past the hour. – you
should use 4
different format codes.
f. Put your birth date and the date you expect to graduate in a file. Use the date -f
option to display the dates both as the number of seconds since the epoch and in
the form YYYY/MM/DD with leading zeroes for month and day.
Show the original data file, the command used and the output in your answer.
4)
head, tail, cat, tac – horizontal slicing of files (8 marks)
Each question is designed to have you build up a larger command in stages. In each case
record the commands used and any numerical results. Note: You may have to use the |
(pipe) symbol to chain more than one command together. Piping your data thru the cat –n
command will add line numbers to your data and help you verify that you’ve selected the right
lines.
a. Use a combination of head and tail to extract the following information from the
file /usr/share/X11/rgb.txt (2 marks)
The last 15 lines of the file
The 1st 6 lines of the file
Lines 200 to 215 (inclusive of both endpoints) of the file using head and tail.
b. Repeat the previous exercise a. using only the sed command . A discussion of
the sed command appears in Chapter 4. (2 marks)
c. The following command will list all the times a given user has been logged on
since the system log was last restarted, ordered from most recent to least recent.
last username
Record the Unix commands to produce a report showing the 1st 3 and the last 3
times you’ve been logged on , ordered from least recent to most recent. Note that
the line containing the phrase “wtmp begins Wed Jan 1 06:15:00 2014” should not
be in the report. A sample output for king can be found in the file
~king/sample1.txt (2 marks)
d. The ls command normally displays all files in alphabetical order. Display the
names of all the non .h files with start with the letters std or lib in the directory
/usr/include in reverse alphabetical order. (2 marks)
Download