Out: Jan 28, 2015
Due: Feb 11, 2015 start of lecture
This is a 2 week lab. It will have 1.5x the weight of Lab 1 or Lab 2.
TECH154 – Lab 3: Winter 2015
Preliminary Step
Issue the following command:
ln -s ~king/.vimrc $HOME/.vimrc
Note the use of the tilde (~) and the dot before the file name. Now issue the following command:
ls -la $HOME
stat ~/.vimrc
Both should verify that you’ve created the .vimrc resource file as a symbolic link in your home directory. Now edit a file and enter the following as text: HC
It should automatically expand to say: Humber College
Now type in HTML - it should expland to create a template for a web page.
Part I: Creating a Web Page Using HTML Markup (14 marks)
1.Create a web page in your public_html directory in a file called index.html using HTML markup. Hand in an HTML listing with your assignment.
In this file write a short biography two of yourself in two paragraphs. 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)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. Add a 2nd image by deep linking to it on the internet. (2)
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, not including any of h1-h6. (2 marks)
f)Add a couple of HTML comments documenting some of what you’ve done (1)
g)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)
h)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. (1)
i)Use the vim command :r ~king/public_html/CTEC104/readFile.c. to add the contentes of the file readFile.c to your index.html. Notice that it looks different when viewed as a web page than when viewed in vim. The idea is to make it look like a program listing on the web. (3 marks)
- Add the pre tag so that the indentation is presevered. (1/2)
- Note that stdout.h> is missing – replace the & macro that it displays properly. (1/2)
- Surround the C declarations with the var tag. Describe the difference using a C like comment immediately above the delarations. (1)
- Hilite the function names fprintf, fscanf and fopen so that they appear bolded and in blue. (1)
j)Add HTML comments above your bio and above the program code. (1)
Part II: Working with Files and Directories (22 marks)
- Permissions and Groups (4 marks)
For this set of exercises you need to work with a partner who is a member of group other than yours. For example, if you are a shark, partner with a minnow or a dolphin. If there you find that there are no available partners you can partner with someone who has already done the exercise with someone else. - In your home directory create and edit the files .plan and .project filling .plan in with a short version of your long term plans and .project with information about some short term project you are working in. Verify that this works by fingering yourself. Show the command you used and summarize the result. (1)
- Try and finger your partner’s account. You should not be able to see each other’s .plan or .project. Keeping in mind that both you and your parterner are members of the group students, change the group permission on both files so that other members of your group can read the files. Record the command you used. Finger each other again and verify that the plan and project information are both visible. (1)
- Use the chgrp command to change the group ownership of .plan and .project files, and verify the change of ownership. Can you finger each other and see each others’s .plan and .project information? Record the commands used.
- Alter the permissions of the .plan and .project files so that others can read the files. Can you finger each other and see each others’s .plan and .project information? Record the commands used.
The exercises that follow are to be done individually and not with a partner:
- Aliases: Hard Links and Symbolic Links (6 marks)
- Determine where the executable file vim is located. Issue the following commands:
cd ~
which vim
Try to create a hard link to the gcc file
ln /usr/supply directory path here/vim myvim
Ok - it doesn't work. Write down the error message.
Use the stat command on both the vim file and on your home directory and look at the device information. Using the information provided, explain why you were unable to create a hard link.
- Try to create a symbolic link to the vim command:
ln /usr/supply directory path here/vim myvim -s
(This should work)
Issue the command: ls -l myvim
Describe 2 indicators that myvim is a symbolic link
Prove that mygcc is an effective alias for the vim command by issuing:
myvim
myvim -v
#Record the version of vim that is on the system. - Note the number of hard links to your home directory. Create two subdirectories in it. Now note the number of hard links again. Explain the change in the number of hard links. Now look at the number of hard links to the names of each of the new subdirectories. Explain why the number of hard links to a subdirectory is always at least 2.
- Create a new symbolic link to one of your new directories and record the command used. Did this add to the hard link count? Why or why not?
- Create a symbolic link to the symbolic link you created in part b. Now try the readlink command on each of the symbolic links you created and on a hard link. Record the commands used. Explain what readlink does.
- A symbolic link can be created to point to a non-existant file. Create a symbolic link from a to b. Now create a symbolic link from b back to a. Record the commands used. What happens when you try to cat either file?
- Wildcards in the Bash shell (1 mark each/6 marks)
Apply the following commands in the /usr/bin directory on munro.
Record the command used in each case. Record the number of files matched. by piping the result through the wc command. (I am not looking for an actual list of files)
eg (for all files): ls | wc -l - list the name of all the files in the /usr/bin directory that start with the letters ma.
- list the name of all the files in the /usr/bin directry that end with the letters am
- list the name of all the files that start with the letter p and end with the number 3
- list the name of all the files that consist of 2 letters where the 1st letter is in the range from c to n.
- List the name of all the files that start and end with a vowel.
- List the name of all files that have a period in the name. List the name of all files that have a period somewhere in the name that is not immediately followed by a vowel. (The result should be different.)
4.Redirection (6 marks)
The purpose of this exercise is to give you practice with shell metacharacters for redirecting input and output. At the end you should understand the use of > > < 1> 2> ( ) and ; |
Run the following sets of commands. Observe what is output to the screen and examine the contensts of the files that get created. A short 1-2 line English explanation of what's happening is all that's needed. The paired commands are similar, but different in some way – note the differences.
a) Explain he difference in the result of the following sets of commands?
- cal 1 2014> January ; cal 1 2015 > January ; cal 1 2016 > January
- (cal 2 2014; cal 2 2000; cal 2 1902) > Feb
b)What is the difference in the result of the following commands? Note that the file October should still exists from 1a) and that the file November should not exist.
- cat January Feb 1> result1
- cat January Feb 2> result2
c)What is the difference in the result of the of following sets of commands. Explain what happens:
- cat January Feb 1> result3 2> result4
- cat October November 2> /dev/null
d)What is the difference in the result of the following sets of commands.
- date > logfile; date > logfile; date > logfile;
- date > logfile2; date > logfile2; date > logfile2
e)Refer to the man pages on the tee command and pay attention to the -a option. Run the following commands and check the contents of the result file after each one. Explain the contents of the resulting files, especially the number of lines
- date | tee r1 r1 r1
- date | tee -a r2 r2 r2
f)Type in the following commands, enter a few lines of text and then press <CTRL>D (end of file.) Explain what the commands do
- cat </dev/tty >/dev/tty
cat | tee copy1 copy2 >copy 3