Home > Undergraduate > Open Source Tools and Scripting >    Labs

  CITS2003 OPEN SOURCE TOOLS AND SCRIPTING
 
 

Lab 2: Shell Basics

Remember to start a Docker container before beginning the lab exercises, and save your work in the mounted directory. Lab files for each week are provided inside the /lab directory.

It is recommended that you create a new directory for each week (week1, week2, etc) within the mounted directory to store any files you create for that week's lab. You may wish to copy the lab content into this directory using cp.

Questions

  1. What does open source mean? How is that different from free-to-use?
  2. What are the two meanings of / in the file path /lab/week2/thing.txt?
  3. What is the absolute path of the home directory of the user stud?
  4. What is the file called .? How is this different to a file called .stuff?
  5. Create a directory called week2 in the mounted directory if you haven't already. Then create a file in week2 using the following command:
    /usr/games/cowsay "MOO" > lol.txt
  6. Print the first 3 lines of lol.txt using a command ("print" means "display in the terminal", not "send to a printer").
  7. Print the last line of lol.txt using a command
  8. How many lines are in lol.txt?
  9. What is the difference between cat lol.txt and head lol.txt? Would this change on a larger file?
  10. How many files are in /lab/week2? Don't count . or .. (why are we ignoring these?).
  11. What does the -p option mean for ls?
  12. List the contents of /lab/week2 in size order. Which is largest?
  13. What command would you use to copy Alice_in_Wonderland.txt from /lab/week2 to your mounted directory?
  14. How many words are in Alice_in_Wonderland.txt?
  15. Open Alice_in_Wonderland.txt using the less. In less:
    • Space bar goes one page ahead, b goes one page back
    • G goes to end of file, gg goes to the start
    • To go to a line number, type the line number then G
    • To search for a string, type / then the string, then press enter. Press n to cycle through results or N to cycle backwards.
    Using less, answer the following:
    1. What chapter begins on line 1252?
    2. What food is described as rich and green?
    3. How many times does the word "verdict" appear?
  16. You've decided you don't want to keep a whole book in your mounted directory. How can you remove Alice_in_Wonderland.txt from your mounted directory?


Department of Computer Science & Software Engineering
The University of Western Australia
Last modified: 8 February 2022
Modified By: Daniel Smith

UWA