2

Click here to load reader

NITA 212 - Open Source Platform & Network Administration - Lab #7

Embed Size (px)

Citation preview

Page 1: NITA 212 - Open Source Platform & Network Administration - Lab #7

8/3/2019 NITA 212 - Open Source Platform & Network Administration - Lab #7

http://slidepdf.com/reader/full/nita-212-open-source-platform-network-administration-lab-7 1/2

Lab #7 - Package Management, C/BASH Programming Stanislav

Lab Steps:I. Package Installation with pirut 

A. Open the Add/Remove Software application under GNOME and authenticate as root.B. Select Desktop Environment from the left-pane and then select KDE (K Desktop

Environment) from the right-pane.

C. Click the Optional Packages button and check the box for kdeadmin from the list.D. Click Close and then click Apply on the Package Manager.

E. Click Continue when prompted to install the new package.F. Click OK after the package has been installed.

II. Package Installation with yum A. Open pirut if it isnʼt already.

B. Open the Terminal if it isnʼt already. Make sure to leave pirut open still.C. Type su - root to login as the root user. Enter the root password when prompted.

D. Type the command yum install wireshark -- you will notice that you receive an error that

“Another app is currently holding the yum lock...”. This is because pirut and yum utilize the samesoftware in different ways.

E. Close pirut and you will notice that the installation will now proceed.

F. When prompted, type yes and press the Enter key to agree to the installation.

III. Package Installation with rpm 

A. Open your Terminal and su - root if you already havenʼt.

B. Obtain a copy of the Adobe Acrobat Reader RPM file from your instructor.1. Use this command if told to do so: wget http://bit.ly/8jGF6l

C. Make sure that you are inside of the same directory as where your Acrobat Reader RPM file is

stored and then type the command rpm -iUv AdbeRdr9.2-1_i486linux_enu.rpmD. In your terminal, execute the acroread command to execute Adobe Acrobat Reader.E. Close acroread.

F. Using yum we can find out the status of packages. Type yum list Adobe* and you will be able tosee all package that start with ʻAdobeʼ. Observe the version number and ʻinstalledʼ status.

G. Exit the root user shell by simply typing exit.

H. Verify that you are your normal user by typing the whoami command. It should output your

username and not root.

IV. Compiling a “Hello World!” C Program

A. Create a new file in vim called hello.cB. Type the following lines of code into the file:!! #include <stdio.h> int main() {

printf(“Hello World!\n”); return 0; }

C. Compile the program into an executable binary by typing the command gcc hello.c -o helloD. Execute the program by typing ./hello and pressing Enter. The program should output onto your

terminal screen Hello World! 

Page 2: NITA 212 - Open Source Platform & Network Administration - Lab #7

8/3/2019 NITA 212 - Open Source Platform & Network Administration - Lab #7

http://slidepdf.com/reader/full/nita-212-open-source-platform-network-administration-lab-7 2/2

V. if-then-else BASH Script Creation & Testing 

A. Create a new file in vim called itescript.sh and type the following code into the file:!! #!/bin/bash 

if [ $# -eq 0 ]; then  echo "$0 : You must supply one integer."  exit 1  else  if [ $1 -gt 0 ]; then  echo "$1 number is positive."  else  echo "$1 number is negative."  fi fi

B. Make the script executable by typing chmod 755 itescript.shC. Execute the script passing a single number each time. Try 3 different values including a negative.

VI. Create and Execute a BASH Script Utilizing the “Case” Statement

A. Open a file in vim called case.sh.B. Type the following BASH scripting into the file changing the values for yourself: #!/bin/bash

if [ $# -eq 0 ]thenecho "You may ask the following questions:"echo -e "\tage - How old am I?"echo -e "\tvehicle - What kind of vehicle do I drive?"echo -e "\tpet - What kind of pet do I have?"exit 1

fi

case $1 in"age") echo "I am 24 years old.";;"vehicle") echo "I drive a Ford Escape.";;"pet") echo "I have a dog.";;*) echo "Sorry, I don't have an answer for that question.";;

esac

C. Type chmod +x case.sh to make the script executable.D. Execute the case.sh script passing one of the three questions to the script.

VII. Create and Execute a Script Using a for Statement

A. Create a file using vim called forloop.sh.B. Type the following BASH scripting into the file:

#!/bin/bash

for i in {1..10}do

echo "The current number is: $i"done

C. Type chmod +x forloop.sh and execute the script. Review the output.