Exercise sheet 1 - for the week commencing 2nd March 2020
These exercises are performed by entering commands to the bash
command interpreter (or shell),
an acronym for the Bourne-again shell,
using the Terminal
window application (under either Linux or macOS).
While Terminal provides a visible interface,
supporting variations in fonts and colours,
the 'real' work of executing our required commands is performed by bash.
bash indicates that its ready to accept a new command by issuing a prompt,
we type our required command,
press the Return (or Enter) key,
and read the required command's output (if any).
These exercises are very simple;
they are not designed to provide a lot of take-away knowledge,
but to overcome any hesitation you may have about controlling your computer
through a character interface,
rather than a graphical-user interface (GUI).
We commence our story assuming that you have logged into either Linux or macOS,
and have started an Xterm or Terminal process....
Remember, that the man command is likely to be the first one you'll need.
- What is the current date and time on the computer you're using?
- On what day of the week is the last day of this month?
- On what day of the week is the last day of this year?
- Each instance of a bash process
has a working directory -
a location in the computer's file system where
files may be read and created (by default).
What is your shell's present working directory?
As you have just started a new bash process,
you're actually in your home directory,
in and below which you can create, edit, and store all of your own files.
- What is the current date and time in London,
which uses Coordinated Universal Time (UTC)?
- For this, and some following exercises, you may like to open the operating
system's graphical file and directory browser
Files (under Linux) or Finder (under macOS).
We previously listed the working directory of the shell.
Now, use the ls command (that's 'EL' 'S') to list any files and (sub)directories
in that working directory.
- Next, use the mkdir command to make a new directory,
named cits4407, in the present working directory.
Did you notice a new icon appear in your graphical file browser?
Use the ls command to 'ensure' that the new directory has been created
in the present working directory,
and then ls again (with an argument) to see that the new directory is empty.
Navigate to this new directory using your graphical file browser.
- Now, change the shell's directory into your new directory named cits4407.
Use ls again to see that it's (still) empty.
- Next, create a new file,
by executing touch in this cits4407 directory.
Using the ls command to display a longer, detailed
listing of the contents of the current directory.
- Now, touch the file newfile again.
What attribute/property of the file has changed?
- OK, let's cleanup this temporary work we've done.
Use the cd command to change back to your home directory.
How do you know you're in the right place?
OK, we've created a new directory named cits4407 and, in it,
a new file named newfile.
Your task is to remove both of them,
so that your home directory is as it was at the start of these exercises.