/
Topic Materials
ICT374 Lab 2:
Unix Shells, Standard I/O Redirections, Archiving and Compressions; C's Formatted
Input and Output, and Obtaining Command Line Arguments.
Learning Objectives:
1. Learn to use Unix shells, especially bash shell
2. Learn to do standard I/O redirections.
3. Learn to use command
tar
to archive files and to extract files from archives
4. Learn to use command
gzip
and
gunzip
to compress and uncompress files
5. Learn to use standard I/O functions for formatted output:
printf
,
fprintf
, and
sprintf
6. Learn to use standard I/O functions for formatted input:
scanf
,
fscanf
, and
sscanf
.
7. Learn to use command line arguments from C programs.
Required Reading:
Lecture Notes for Topic 2
Rute: Ch 4.18, Ch 7.1, Ch 12, Ch 20.8
A
mini manual
for vi editor
Access to Software:
Internal students will use the lab at 245.3.063. You must bring a USB drive with you to copy your work from the lab computer. This is
necessary as you cannot retain anything on any one of the lab computers.
For external students, if you have already installed Linux on your own computer, then use your own computer. Otherwise, you may use
the university's Linux server (
ceto.murdoch.edu.au
) temporarily until you have installed the Linux on your computer. More
information on how to install Linux is available from Unit Resources page.
Unix Exercises
The following exercises are designed to get you familiar with Unix (Linux) systems. More information about these basic Unix
commands is available from the relevant chapters in Rute. See the Required Readings.
1.
Unix Shells
When you start up a terminal program, Unix runs a shell program automatically inside the terminal. The default shell for most
Linux distributions is bash shell (/bin/bash). You can confirm this by typing the command
ps
to see the list of processes that are
running on your login session, which should include bash.
You can also start and stop a shell manually. For example, typing the command
bash
would start another bash shell process. You
can exit from the shell by typing the command
exit
at its prompt.
Now try to start a new shell. For example, bash or tcsh. Type the command
ps -H
to confirm that different (instances of) shells are
running. Exit the shell by typing command
exit
.
A shell is a command interpreter. It prints a shell prompt on your terminal, inviting you to enter a command line. It then tries to
locate the command and once located, creates a process to run that command line.
