Question 2: Manipulate directory structures in Unix/Linux (24 marks – 2 marks each)
Use any OS that you set up from Question 1 (Puppy is allowed). Assume you are started at your home directory.
Let your first name be XXX, so XXX = ‐‐Mark", if your name is Mark. XXX from now on refers to your first name (e.g. Mark).
Perform a command that displays the absolute path of your home directory (your current location).
1. Create a new directory inside your home directory and name it ‐‐XXX"
2. Now navigate to the XXX directory and create directory XXX-COMP501WORK and change your current working directory to XXX-COMP501WORK.
3. Create three new subdirectories called Sec1, Sec2, and Sec3 in XXX-COMP501WORK directory.
4. Create a new file called ‐‐MyFave.txt" using the touch command and insert three lines into the file (you may use echo command and >> command).
a. The first line should contain your name and ID number.
b. The second line should be the first sentence of your favourite song.
c. The third line should be the name of your favourite movie.
And display the contents of the file ‐‐MyFave.txt" to the standard output screen (you may use cat command).
5. Display the number of words in the file ‐‐MyFave.txt" (you may use wc command).
6. Copy the file ‐‐MyFave.txt" to directory ‐‐Sec1" and rename it to ‐‐MyFaveCopy.txt". Make another copy of ‐‐MyFaveCopy.txt" just made in directory ‐‐Sec1" and name it ‐‐MyFaveCopyCopy.txt" (also store in the same directory ‐‐Sec1"). Then, display the contents of the directory ‐‐Sec1" using the long format.
7. Copy all the contents of directory ‐‐Sec1" to directory ‐‐Sec2" and display the contents of the directory ‐‐Sec2".
8. Assume that you are now at the current working directory XXX-COMP501WORK; create 15 new files (in directory XXX-COMP501WORK) named as follows:
a. FICT.bak
b. unix.txt
c. thistest.bak
d. wumbo.file
e. wumbology.txt
f. moreThings.woot
g. FundalT.txt
h. doodad.text
i. coursetxt
j. Test‐1‐2.xtxt
k. Test‐2‐2.xtxt
l. Test‐1‐1.bak
m. Test‐1.txt
n. File‐1.bat
o. Assignment1.file
And display a listing of all the files and directories in long format in the current working directory XXX-COMP501WORK.
9. Display a listing of all the files in the current working directory ending with letter 't' using one command, e.g. unix.txt or doodad.text.
10. Display a listing of all the files in the current working directory starting with 'T' and ending with 't' using one command, e.g. Test-1.txt.