CS2211a Assignment 1 Solved

30.00 $ 15.00 $

Category:

Description

QUESTION 1 (12 marks)

On gaul, change your working directory to /bin/

Use only the ls Unix command to display the following file names in the /bin/ directory:

  • (2 marks) whose names that are of length exactly 17 characters
  • (2 marks) whose names that have a z as the second letter (c) (2 marks) whose names that end with i or j
  • (3 marks) whose names that begin with an uppercase letter (do not display any of the directory contents, if any—you may want to read the ls man pages to know how to do so)
  • (3 marks) whose names that begin with an uppercase letter other than D, or M (do not display any of the directory contents, if any—you may want to read the ls man pages to know how to do so)

 

You must include in your report the Unix command that you used in each part and the results that you got when executing the command (i.e., the list of required file names).

 

QUESTION 2 (12 marks)

On gaul, accomplish the following tasks using one or two Unix commands:

(a) (2 marks) Go to your home directory and create a directory called public_html under your home directory (b) (2 marks) Display the permissions of public_html

  • (1 mark) change your working directory to public_html
  • (1 mark) using touch command, create a text file called abc under the public_html directory
  • (1 mark) change your working directory one level up (f) (1 mark) change the public_html permission to 300

(g) (4 marks) Why can you see information about abc when executing ls public_html/abc but can not you see such information when executing ls public_html? Fully explain the reason.

 

You must include in your report all Unix commands that you used in each part and the results that you got, if any, when executing the command

 

QUESTION 3 (12 marks)

On gaul, accomplish the following tasks using one or two Unix commands:

  • (2 marks) Display a list of all hidden files in your home directory (do not display any of the hidden directory contents—you may want to read the ls man pages to know how to do so) sorted in reverse lexicographical (alphabetical) order of file names that end with letters rcyou may want to read the sort man pages to know how to do so.
  • (1 mark) Use the finger command to find yourself on obelix (finger userID) and show what you will get (long format).
  • (1 mark) Create and edit a text file in your home directory called .plan outlining some of your plans.
  • (1 mark) Change the permissions of .plan to make it readable to everyone.
  • (1 mark) Use the finger command again to find yourself on obelix and show what you will get.
  • (1 mark) Change the permissions of .plan file to 600
  • (1 mark) Use the finger command for one more time to find yourself on obelix and show what you will get.
  • (4 marks) Did you see a different between the (b), (e) and (g) outputs? Explain

 

You must include in your report all Unix commands that you used in each part and the results that you got, if any, when executing the commands.

 

QUESTION 4 (20 marks)

On gaul, accomplish the following tasks using Unix commands:

  • (2 mark) Go to your home directory and create a directory called Working-Area under your home directory
  • (2 marks) under Working-Area directory, create a sub-directory called Dir1 and a text file called File1
  • (2 marks) under Dir1, create two directories called Dir3 and Dir4
  • (2 marks) under Dir3, create a text file called File3
  • (2 marks) under Dir4, create three text files called File4, File5 and File6
  • (2 marks) under Working-Area directory, create Dir2, a symbolic link that points to Dir1/Dir4 directory

 

Set the permissions of:

  • (2 marks) Working-Area to give all permissions to the owner user, and none to others and group users
  • (2 marks) Dir3 to give all permissions to the owner user, while read and execute to group users, and none to others
  • (2 marks) File3 to give read and execute permission to others and group users, as well as all permissions to the owner
  • (2 marks) File5 to give execute permission alone to others and group users, as well as read and execute permission to the owner user

 

You must include in your report all Unix commands that you used.

 

QUESTION 5 (16 marks) to be performed on gaul

(a) (2 marks) Go to your home directory and create a text file called letter.txt. Write at least 12 lines in this file, where each line will have just a number from the list {01, 02, 03, …  , 11, 12} in this order. (b) (2 marks) Display the content of letter.txt.

  • (2 marks) What does the command tail -3 ~/letter.txt do and what does the command tail +3 ~/letter.txt do?
  • (2 marks) What does the command head -3 ~/letter.txt do and what does the command head +3 ~/letter.txt do?
  • (2 marks) What does the command who | tee ~/letter2.txt | wc -l do?
  • (2 marks) Give the Unix command that shows the calendar for November, 1955 (g) (2 marks) Explain the difference between cat < txt and cat letter.txt.

(h) (2 marks) What does echo cat command do and what does cat echo command do?

 

You must include in your report all Unix commands that you used in each part and the results that you got, if any, when executing the commands.

 

QUESTION 6 (9 marks) to be performed on gaul

  • (3 marks) Assume that you are in your home directory and there is a directory called courses/ under your home directory. Give one Unix command that copy all the files and directories under the courses/ directory to your home directory. Explain whatever copying options to be used, if any.
  • (3 marks) Give one Unix command to accomplish the same task as in (a), assuming that your current working directory is not your home directory
  • (3 marks) Give one Unix command that will change the permission of all files and directories under courses/ to only allow the owner to read/write/execute, but not anyone else

 

QUESTION 7 (19 marks) to be performed on gaul

(a) (3 marks) Briefly explain (with examples) the Unix absolute pathname and relative pathname. (b) (1 mark) What is the ./ directory?

(c) (1 mark) What is the ../ directory? (d) (1 mark) What is the ~/ directory?

  • (3 marks) The Unix command rmdir abc_dir fails with the message saying that the directory is not empty. On running ls abc_dir, no files are displayed. Why did the rmdir command said it is not empty?
  • (3 marks) The Unix command cp file1 backup/file1.bak did not work even though all files exist. Name three possible reasons for such failure.
  • (3 marks) Run the tty Unix command, and note the device name of your terminal. Now, use this device name (say, /dev/pts/6) in the Unix command cp ~/.login /dev/pts/6. What do you observe? Explain.
  • (4 marks) If umask shows the value (i) 000, (ii) 002, what implication does it have from the security view point?