Complete this assignment by downloading this HTML file and editing it (using a text editor---not a special HTML editor). Wherever you see emphasized text (e.g. "Your name" and "Your Student Number" above) you should insert your own text, as appropriate. Submit via D2L at the end of the lab period.
Complete the tutorial at openvim.com. (There appear to be some minor bugs in this tutorial. Also some bad jokes.)
For all subsequent questions, you should have a running
instance of vi (actually vim) and be making changes to the
file Img.h
available within the following git
repository:
https://gitlab.com/COMP2718/lab4_init.git
.
Note that your answers to the following questions should all be executed in command mode (a.k.a. normal mode). When questions ask for a specific number of keys (e.g. a 2-key command) hitting the Escape key to return to command mode does not count.
There is a misspelled word on line 25. What keys can you enter to reach line 25 from any other line in the file.
Change this with your answer
Go to the beginning of this line by typing 0. What 3-key command can you use to get to the second 't' in "Construt". (One could also just move the cursor with 'l' but we are looking for a more efficient way here.)
Change this with your answer
What 2-key command fixes the typo.
Change this with your answer
Search for the term "inWidth" using "/". What sequence of keys replaces the "inW" with "w". There are multiple possible answers.
Change this with your answer
Give the ex-command that will substitute all instances of "inWidth" with "width".
Change this with your answer
Execute ":help <". Now give the keys to unindent all lines in the file, starting at the first line of the file..
Change this with your answer
In this exercise, you should start the firefox
browser (from the window manager) as well as two terminal
windows.
The ps
command with no arguments will list
only the processes attached to the same terminal as the
ps
command. In one of the terminals, execute
ps
and show the output below.
Change this with your answer
What is the TTY?
Change this with your answer
Record the output of ps
for the other
terminal.
Change this with your answer
What is the TTY? Change this with your answer
Using the PID of bash
from the first
terminal, enter this command in the second terminal:
% kill -9 PID_OF_BASH
Describe what happened?
Change this with your answer
Consult the course notes or use man ps
to
discover how to list all the processes. Use a pipeline
command to show only the lines containing
firefox
. Command
Change this with your answer
Look at the output and identify the PID of the
firefox
process. What command could you use to
kill the firefox
process?
Change this with your answer
Attempt to kill firefox
. Record what
happened?
Change this with your answer
Relaunch firefox
, and goto cbcnews.ca
and play any
video. In a terminal window, type the command
top
. After 10 seconds stop the video from
playing. Observe the terminal containing top
,
how has the information about firefox
changed?
Change this with your answer
Using the printenv
command, determine the
value of the following environment variables. HOME
Change this with your answer
USER
Change this with your answer
TERM
Change this with your answer
PATH
Change this with your answer
PS1
Change this with your answer
SHELL
Change this with your answer
The PS1
variable controls the prompt used by
BASH. Using man bash
and search for the
PROMPTING
section to see how to configure the
prompt. User PS1=STRING
to change the prompt by
customizing STRING. First set the prompt to display the
current time in 12 hour format followed by the current
directory.
Change this with your answer
Change the prompt to display the host name followed by the current user's name.
Change this with your answer
Change the prompt to display the base name of the current directory and the history number of the this command line. Change this with your answer
Change the PATH
with the following
command:
$ PATH=/bin
Determine which of the following standard commands are
still available: mv
, grep
,
less
, cp
, cd
,
which
, and firefox
. Available
Change this with your answer
If the PATH
is changed to:
$ PATH=/bin:/usr/bin
Which of the missing commands are now available:
Change this with your answer
Change the HOME
variable to
/tmp
. Now type cd
. What is the
current directory.
Change this with your answer
In a new terminal window, use an editor to edit the
~/.bashrc
file. At the end of the file add the
following line:
alias d="date +'%D %T'"
Save the file and quit from the editor. Open another
terminal window. In the new terminal, type the command
d
. What happened?
Change this with your answer
In the original terminal, type d
and explain
the result.
Change this with your answer