Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
41 views

Assignment SysProg1

This document provides instructions for completing Assignment 1 for the CSCP4073 System Programming course. Students are asked to: 1. Install Ubuntu and use their full student ID as the username. 2. Open the terminal and execute various Linux commands, taking screenshots of the outputs. 3. Create a PDF file with their student ID containing the screenshots. The document then lists exercises involving basic Linux commands like ls, cat, grep, and managing services like postfix. It provides instructions for becoming root, working with files and directories, pipes, command history, auto-completion and updating software packages.

Uploaded by

rana muneeb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Assignment SysProg1

This document provides instructions for completing Assignment 1 for the CSCP4073 System Programming course. Students are asked to: 1. Install Ubuntu and use their full student ID as the username. 2. Open the terminal and execute various Linux commands, taking screenshots of the outputs. 3. Create a PDF file with their student ID containing the screenshots. The document then lists exercises involving basic Linux commands like ls, cat, grep, and managing services like postfix. It provides instructions for becoming root, working with files and directories, pipes, command history, auto-completion and updating software packages.

Uploaded by

rana muneeb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSCP4073 System Programming

Assignment 1
Learning Objective
1. To learn “how to create a working Linux environment”.
2. To familiarize with different Install options.
3. To familiarize with the Linux environment.
4. Get to know the basic Linux commands.

Task
1. Install latest build of Ubuntu on your computer.
2. Use your full roll number when prompted for a username.
3. Once you are done with installation, open the terminal.
4. Execute the commands presented in the exercises section and take screenshots of the outputs.
5. Create a single PDF with your roll no as the filename.
6. If you do not execute a command, mention the command and write “Not executed” instead of a
screenshot.

Notes:
1. Commands preceded with $ imply that you should execute the command as a general user - not as
root.
2. Commands preceded with # imply that you should be working as root.
3. Commands with more specific command lines (e.g. “rtrX>" or “mysql>") imply that you are
executing commands on remote equipment, or within another program.
4. If a command line ends with "\" this indicates that the command continues the next line and you
should treat this as a single line.

Instructions
1. Links to detailed Install tutorials are included in lecture 1 slides.
2. Each screenshot should clearly show your username (roll-no).
3. If the command is to be executed as root, before changing to root, execute “whoami”.
4. The output of this command is to be added to any screenshots not clearly showing your roll-no.
CSCP4073 System Programming

Exercises
Log in to your machine.
Become the root user
At the command prompt type the following command:

$ sudo -s
Enter your password when prompted

Now that you are root the command prompt will change. We indicate this using the “#” symbol.

You are now the super user - be careful!

Ok, exit the root account:

# exit
$

Look at the network configuration of your host


$ cat /etc/network/interfaces
Notice that configuration of your host is done using DHCP. “cat” is for “concatenate” and is one way to
view what is in a file.

List files:
Use ls to list files:

$ cd [go to your home directory]


$ ls
Do you see anything? Try this instead:

$ ls -lah
What's inside one of these files?

$ cat .profile
$ less .profile
$ clear
Press “q” to get out of the less display.

If you don't understand what cat, clear or less do, then type:

$ man cat
$ man clear
CSCP4073 System Programming

$ man less

Working with the command prompt:


You can recall previous commands by using the up-arrow and down-arrow keys. Give this a try now.

Alternately, try typing this command:

$ history
If you wish to execute one of the commands in the list you saw type:

$ !nn
Where “nn” is the number of the command in the history list. This is useful if you want to run a past
command that was long and/or complicated.

Command completion:
With the bash shell you can auto-complete commands using the tab key. This means, if you type part of
a command, once you have a unique string if you press the TAB key the command will complete. If you
press the TAB key twice you'll see all your available options. Your instructor will demonstrate this, but
give it a try by doing:

$ hist<tab>
$ del<tab><tab>
$ rm <tab><tab> [Include the space after the “rm”]

Working with pipes:


We saw an example of using pipes when we sorted the contents of our /sbin directory during the
presentation. What if you wanted to have this information available in a file and sorted?

$ cd
$ ls /sbin | sort > sbin.txt
Now view the contents of what is in sbin.txt to verify that this worked.

$ less sbin.txt
Press the “q” key to quit viewing the contents.

Finding text strings:


Use the command grep to print lines matching a pattern in a data stream (such as a file). For example,
view the entry for the sysadm account in the system passwd file:

$ sudo grep sysadm /etc/passwd


You should see something like:

sysadm:x:1000:1000:System Administrator,,,:/home/sysadm:/bin/bash
CSCP4073 System Programming

The previous items above are:

userid:passwd:uid:gid:Name,extrastuff,,:HomeDir:LoginShell

grep is often used with a pipe to FILTER the output of commands. For instance:

$ history | grep ls
Will display your previous use of the ls command from exercise 2.

Update and installing services


Update your software package repository
$ sudo apt-get update

This might take a few moments if everyone in class is doing this at the same moment.

Install the “joe” editor package


$ sudo apt-get install joe

The joe editor package just like vi. Try using the editor to create a new file in your home directory:

$ cd
$ joe newfile.txt
Install the postfix mailerver software and some mail utilities
At the command line type:

$ sudo apt-get install postfix mutt mailutils


You will several prompts. If you are using putty ssh sometimes the screens can be harder to read.

When you are prompted (a fair number of packages will be installed):

• At the initial prompt press {Enter} for {Ok}


• When available, select “Internet Site” (use tab key to move to {Ok} and press {Enter} to
continue)
• Accept the hostname presented (tab to {Ok} then press {Enter}

Several tools will use the postfix mailserver during the week. In addition, we will use a number of the
mail utilities (such as mail) and you will use the mutt email reader later in the week.

Stopping and starting a service


Restart the mail service, postfix

$ sudo service postfix restart


To do this you can do:
CSCP4073 System Programming

$ sudo service postfix stop


You can see if a service is running by typing:

$ sudo service postfix status


Now you can start the service again and check the status using the command above.

$ sudo service postfix start


You can see if a service is running by typing:

$ sudo service postfix status


If a process ID is displayed, then the service is running, but our next exercise will show you another way
to verify this.

You might also like