COMP2718 Assignment 2

Your Name -- Your Student Number

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 by 2:15 p.m. on Monday, February 1.

Inodes, mtime, and ctime

Read the wikipedia page on inodes. Answer the following:

  1. Describe mtime.

    Change this with your answer

  2. Describe ctime.

    Change this with your answer

  3. The command ls -lt lists the files according to either mtime or ctime. Read the manpage and determine which time is used.

    Change this with your answer

  4. Dennis Ritchie is a famous Computer Scientist. Name two of his accomplishments.

    Change this with your answer

Options to ls

By consulting the man page for ls, answer the following:

  1. What option displays the directory contents sorted by file size?

    Change this with your answer

  2. What option(s) displays the directory contents sorted by file size in reverse?

    Change this with your answer

  3. What option produces a list, where a file is given one per line?

    Change this with your answer

  4. What is the effect of the --almost-all option? What is the short version?

    Change this with your answer

  5. What is the effect of the --directory option? What is the short version?

    Change this with your answer

Input to less

Study less man page (i.e., use the man less command) to answer the following questions:

  1. What input character causes less to display a help message?

    Change this with your answer

  2. What input character causes less to exit?

    Change this with your answer

  3. What character sequence scrolls down 10 lines?

    Change this with your answer

  4. Assuming less is running, what is the effect of the characters between the quotes: '/the'?

    Change this with your answer

  5. What is the effect of typing the character v.

    Change this with your answer

In a terminal window, enter the following, and then answer the list of questions. For each question, state what commands were used to answer the question.

% cd 
% mkdir my-tmp
% cd my-tmp
% mkdir a b c d
% ls /usr/bin > a/usrbin.list
% ls /bin > b/bin.list
% ls /etc > c/etc.list
% ln -s d e
% ln a/usrbin.list b/usrbin.list
% ln b/usrbin.list c/usrbin.list
% cat < b/bin.list > c/bin.list

What files are contained in the a directory?

*Change this with your answer*

What files (and directories) are contained in the my-tmp directory?

*Change this with your answer*

What is the link count for the my-tmp directory?

*Change this with your answer*

What is the link count for a/usrbin.list?

*Change this with your answer*

What happens to c/usrbin.list when a/usrbin.list is removed with the command rm a/usrbin.list?

*Change this with your answer*

What command could be used to remove the c directory? Do not remove the directory.

*Change this with your answer*

Assuming the current directory is my-tmp/d, what command would create a symbolic link called u.list that references the c/usrbin.list file (hint: use a relative path).

*Change this with your answer*

What happens to d when e is deleted?

*Change this with your answer*

Redirection and Text Commands

In a terminal window, enter the following, and then answer the list of questions. For each question, state what commands were used to answer the question.

% cd 
% mkdir my-testing
% cd my-testing
% mkdir dir1 dir2 dir3
% cd dir1
% echo "Red Orange Yellow Green Blue Indigo Violet" > colours
% echo "Red Orange Yellow Green Blue Indigo Violet" >> colours
% echo "==========================================" >> colours
% cat colours colours > ../dir2/more-col
% cd ..
% uniq dir2/more-col > dir3/another-col
  1. Provide a command that counts the number of words and lines in dir1/colours and dir2/more-col

    Change this with your answer

  2. Provide a command pipeline that counts the number of occurrences of lines containing ===== in dir1/colours and dir2/more-col.

    Change this with your answer

  3. Provide a command pipeline that counts the number of unique occurrences of lines containing Red in dir1/more-col and dir2/more-col. The output should be 1.

    Change this with your answer

  4. The command cat is short for what word? Why is the word a good description for the cat command.

    Change this with your answer

tail, head, sort

Using a command pipeline with some combination of tail, head, and sort (as well as other useful commands such as ls and cat) that accomplishes the following:

  1. Provides a sorted list (alphabetic) of all the files in /usr/bin. Do not provide the list of the files.

    Change this with your answer

  2. Provides a sorted list (alphabetic) of the first five files in /usr/bin.

    Change this with your answer

  3. Provide the first 10 lines in the file /usr/share/dict/words.

    Change this with your answer

  4. Provide the last 10 lines in the file /usr/share/dict/words.

    Change this with your answer

  5. Provide the first 10 occurrences of lines that contain con in the file /usr/share/dict/words.

    Change this with your answer

  6. Provide the second 10 occurrences of lines that contain con in the file /usr/share/dict/words.

    Change this with your answer