Labs‎ > ‎Linux Labs‎ > ‎

Linux Lab 02 - Installing Applications

Summary

In this lab we will learn how install programs in Linux using multiple methods.  You should run this lab form the shell in a terminal window when logged into the desktop environment.  If you run it from a tty some things will not work properly.

Installing from the Shell

The distribution of Linux we're using comes with an office application called LibreOffice.  If contains a word processor caller Writer.  While Writer is a great program, we want to use a word processor called AbiWord.  Unfortunately AbiWord is not installed by default so we need to install it.

We're going to install AbiWord using the shell.  Open the shell on your computer and type sudo apt-get install abi-word.  

The command fails because it can't find a package named "abi-word".  We may not have the correct name for the package so we are going to try and search for it.  Type apt-cache search abi-word.

Nothing was located when we searched for abi-word.  Let's try a search for AbiWord without the dash instead.  Type apt-cache search abiword.

Now we know the name of the package we can run the command to install it.  Type sudo apt-get install abiword.  Press Y when prompted.

If everything went ok AbiWord should be installed.  Run AbiWord from the shell by typing abiword.  Notice, when AbiWord opens you will be able to use AbiWord, but not the shell.  The shell will become available again once AbiWord is closed.  

Close AbiWord by clicking the x in the upper right corner of the window.  You don't need to save changes if prompted.  Now we're going to run AbiWord and send the process to the background so we can still use the shell while AbiWord is open.  If we add an ampersand to the end of a command it will run it in the background so we can continue to use the shell.  Type abiword &.  Alternatively you can hit the up arrow to display the last command you typed.  The last command you typed was abiword, add the & to the end of the last command and run it.

Notice that after installing AbiWord from the shell it adds it the graphical menu so we can launch it from there instead of the shell.

You can close the shell by hitting Ctrl + D, typing exit, or hitting the x in the upper right hand corner.  Also close AbiWord by clicking the arrow in the upper right hand corner.  You don't need to save changes if prompted.

Installing from the Desktop Environment

Next we are going to install a spreadsheet program called GNumeric.  We're going to install this program using the GUI.  We will use Software Manager to do this.  Open Software Manager by clicking on the menu and choosing Software Manager.  When prompted enter your password.

When we open Software Manager we see icons that represent categories. We can browse around in this interface a discover new applications we want.

We know the name of the application we want to install so we're going to search for it using the search box in the upper right corner.  Type gnumeric in the search box and hit enter.

Double click on GNumeric, then click install.  Once the application is installed close Software Manager by clicking the x in the upper right hand corner.

GNumeric should be in the menu now.  Open GNumeric using the menu.

Once you've confirmed it works go ahead and close it using the x in the upper right corner.  You don't need to save changes if prompted.

Adding a Repository 

Next we want to install Chrome on our system, but we can't find it when we search.  This is because we don't have an application repository that contains Chrome.  Open the shell and type sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'  This command will create a file named "google.list" in the "/etc/apt/sources.list.d" directory.  The file will contain the text "deb http://dl.google.com/linux/chrome/deb stable man".  Alternatively you could have created the file manually with a text editor.  

Next we need to get the key from google so their packages will be trusted by our system.  Type in wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -  This will download the key to - which represents the standard input, we will send it to the apt-key command to add it.

We have made a change to the repositories so we have to tell the system to update the list of applications.  Type sudo apt-get update. Once this command completes you can install Chrome.  Type sudo apt-get install google-chrome-stable.

Once it's installed you will be able to find it in the menu.

Compiling Code

Next we're going to look at how we can use Linux to write our own applications.  We are going to start by installing g++, type sudo apt-get install g++


Once that's installed type nano hello.c this will open the text editor nano with a new blank file called hello.c.  Type in the text as it appears in the image.  When you're done hit Ctrl + O to save the file.  It will ask you to confirm the name, press enter.  Once the file is saved hit Ctrl + X to exit.

Next we will compile your code and run it.  Type in gcc hello.c -o hello to compile your code and ./hello to run it.  You should see the output "Hello World".

Questions

Answer the lab questions.

1 | 2 I 3 | 4