Introduction
This lab will introduce you to the basics of software installation on Ubuntu Linux systems. You'll learn how to use package management tools like apt and dpkg to install, update, and remove software packages. This knowledge is essential for managing software on Linux systems effectively.
Update the Package List
Before installing new software, it's crucial to update the package list. This ensures you have the latest information about available packages and their versions.
Open a terminal. You should be in the
/home/labex/projectdirectory by default. If not, don't worry - the commands we'll use work from any directory.Run the following command to update the package list:
sudo apt updateLet's break this down:
sudo: This gives you temporary administrative (superuser) privileges.apt: This is the package management command we're using.update: This tellsaptto update the package list.
You might be prompted to enter your password. Type it in and press Enter. Note that the password won't be visible as you type - this is a security feature, not a malfunction.
You'll see a lot of text scrolling by. This is normal! The system is checking various repositories (online software sources) for updates.
When it's done, you'll see a message like "Reading package lists... Done". This means the update was successful.
Install a Package Using apt
Now that we've updated our package list, let's install a package using the apt command.
We'll install the
w3mpackage, which is a text-based web browser. Run the following command:sudo apt install w3m -yHere's what this command does:
sudo: Again, we need superuser privileges to install software.apt install: This tellsaptwe want to install a package.w3m: This is the name of the package we want to install.-y: This flag automatically answers "yes" to any prompts during the installation process.
You'll see output showing the progress of the installation. Don't worry if you see messages about additional packages being installed - these are dependencies that
w3mneeds to function.Once the installation is finished, you can verify that
w3mis installed by running:w3m -versionThis should display the version information for w3m. If you see this, congratulations! You've successfully installed a package.
Search for Packages
Sometimes you might not know the exact name of the package you want to install. In such cases, you can search for packages using apt-cache search.
Let's search for packages related to "text editor". Run the following command:
apt-cache search "text editor"This command searches the package descriptions for the words "text" and "editor".
This will display a list of packages that match the search term. Each line will show a package name followed by a brief description.
You might see a lot of results. Don't worry, this is normal! Linux has many text editors available. For example, you might see something like:
nano - small, friendly text editor inspired by Pico vim - Vi IMproved - enhanced vi editorIf you want to narrow down your search, you can use grep. For example, to find only GUI text editors:
apt-cache search "text editor" | grep -i guiThe
| grep -i guipart filters the results to only show lines containing "gui" (case-insensitive).
Remove a Package
If you no longer need a package, you can remove it using apt remove.
Let's remove the
w3mpackage we installed earlier. Run the following command:sudo apt remove w3m -yThis command will remove the
w3mpackage, but it will leave its configuration files intact.If you want to remove the configuration files as well, you can use
apt purgeinstead:sudo apt purge w3m -yBe careful with
purge- it completely removes all traces of the package, including configuration files that you might want to keep if you plan to reinstall the package later.After removing the package, it's a good idea to clean up any leftover dependencies that are no longer needed:
sudo apt autoremove -yThis command removes packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
Install a Package Using a .deb File
In this step, we'll install the tree package using a .deb file. This process demonstrates how to install software that might not be available through the standard package repositories.
First, let's remove any existing installations of
tree:cd /home/labex/project sudo apt remove tree -y sudo apt autoremove -yThis ensures we're starting from a clean state.
Now, let's download the
.debfile fortree:Tips: Free users can not have access to the internet.
tree_2.0.2-1_amd64.debis already available in the/home/labex/projectdirectory. You can skip this step.wget http://archive.ubuntu.com/ubuntu/pool/universe/t/tree/tree_2.0.2-1_amd64.debThis command downloads the
.debfile to your current directory.Before we install, let's check the package information:
dpkg -I tree_2.0.2-1_amd64.debThis will show you details about the package, including its dependencies.
Now, let's install the package using
dpkg:sudo dpkg -i tree_2.0.2-1_amd64.debIf there are no dependency issues, this should install the package successfully.
If you see any error messages about unmet dependencies, you can resolve them using:
sudo apt -f installThis command will install any missing dependencies.
Verify the installation:
tree --versionThis should display the version information for tree.
To see the
treecommand in action, let's create a simple directory structure and use tree to display it:mkdir -p test/dir1/subdir test/dir2 touch test/file1.txt test/dir1/file2.txt test/dir2/file3.txt tree testYou should see a tree-like structure of the directories and files you just created.
If you want to see more options for the
treecommand, you can view its manual page:man treePress 'q' to exit the manual page.
This process demonstrates how to install a package from a .deb file, handle potential dependency issues, and verify the installation. The tree command is a useful tool for visualizing directory structures in the terminal.
Summary
In this lab, you've learned the basics of software installation on Ubuntu Linux. You've used apt to update the package list, install and remove packages, and search for packages. You've also learned how to use dpkg to install a .deb package file directly.
Here's a quick recap of the main commands we've learned:
sudo apt update: Update the package listsudo apt install <package>: Install a packageapt-cache search <term>: Search for packagessudo apt remove <package>: Remove a packagesudo apt purge <package>: Remove a package and its configuration filessudo apt autoremove: Remove unnecessary dependenciessudo dpkg -i <file.deb>: Install a .deb file
These skills will be essential as you continue to work with Linux systems, allowing you to manage software effectively. Remember, while we used simple packages like w3m and htop for this lab, the same principles apply to installing more complex software. Always make sure to keep your system updated and be cautious when installing packages from unknown sources.



