Updating and Installing Software on Linux
It is important to be able to update operating systems and applications. Every line of code is a potential bug, and some bugs have security vulnerabilities. Developers deploy updates that fix bugs, but sometimes people fail to install updates and leave themselves unprotected.
Learning Objectives
By the end of this exercise, you should be able to:
- describe why updating software is important,
- compare software installation and updates on Windows and Linux,
- update software on Linux, and
- install new software on Linux.
Video Walkthrough
Use this video to follow along with the steps in this lab.
Software Updates
Modern computers have hundreds of millions of lines of code that make up their applications. Each line of code is a potential bug. When developers learn about those bugs, they can fix their code and deploy the updates. Failing to update software is one of the reasons why people get breached.
Case: Eternal Blue
Eternal Blue is a cyberattack exploit developed by the U.S. National Security Agency (NSA) that targets a vulnerability in Microsoft Windows' Server Message Block (SMB) protocol. This exploit was leaked by the hacker group Shadow Brokers in 2017 and was subsequently used in several high-profile ransomware attacks, including WannaCry and NotPetya. These attacks caused widespread disruption and financial loss by encrypting data and demanding ransoms.
Microsoft patched the vulnerability on March 14, 2017, after it has been released by hackers. But, many organizations failed to install the patch. Just running Windows Update would have protected the organizations. The significance of Eternal Blue underscores the critical importance of regularly updating software. Software updates often include patches for security vulnerabilities that can be exploited by attackers. By keeping systems up-to-date, organizations and individuals can protect themselves from known threats and reduce the risk of cyberattacks.
Software Updates: Windows versus Linux
Windows Operating System Updates
Microsoft deploys updates to its operating systems via Windows Update. In older versions of Windows, users had to run Windows Update manually. In newer versions of Windows, the operating system automatically checks for updates and installs. This is why, if you use Windows, you periodically get messages telling you that updates are ready to install and your system needs to be rebooted. It can be annoying to interrupt your workflow to install updates, but history shows that if Windows does not install updates automatically, many people will neglect them. Microsoft releases updates on the second Tuesday of each month--a day many information technology employees refer to as patch Tuesday.
Microsoft Windows Software
Installing applications on Windows happens in two primary ways.
- Users go to a website, download a program that installs software, and run the software. Users have to trust each website that they use to download software.
- Users install software via the Windows Store. Microsoft was late to the game creating a central location for software installation. Developers have to jump through a few hoops to get their software on the Windows Store, so many do not publish their software there. Microsoft provides some oversight of the software on its store, so in theory, software installed via the Windows Store should be safer than downloading programs from random websites.
The Linux Way
Linux developers package their code and publish that code in official repositories. Generally, each Linux distribution has its own repository that has been vetted. The repository contains packages for both the operating system and applications. It is also possible to download applications directly from websites, but the preferred method is to use the Linux distribution's official repository.
Update Linux
Linux distributions differ in their package management tools. This section will introduce the Advanced Package Tool (apt) that works with Debian-based systems, such as Ubuntu and Kali Linux. Other distributions might use different package managers, but the same concepts apply.
- Log into your Linux terminal.
- Run the following command to update the software repository. The
sudocommand tells Linux to run this command with administrative privileges.
sudo apt update
Important
The apt update command does not update any software. It merely updates the list of packages available to install.
- Run the following command to install the latest software and update the operating system.
sudo apt upgrade
- You will be shown a summary of updates. Likely, many megabytes of software will need to be downloaded and installed. Answer
yesthat you want to proceed with the upgrade. - Depending on the packages that need updating, the update might ask you to confirm settings. Because there are potentially hundreds of applications that could be updated, it is impossible here to give you the right choice to make for every potential update. Use your best judgment if prompted to make decisions.
At this point, your Linux operating system should be up-to-date.
Install New Software on Linux
- Your software repository is already up-to-date. You should update your repository every time you install software using
apt update. - The
nmaptool is used for network mapping. It is commonly used by information technology administrators. Try running it.
nmap
- You will get a message that
nmapcould not be found. Your Linux server comes with limited software installed by default. Helpfully, Linux tells you how to install it. You will use theaptmethod to installnmap.
Command 'nmap' not found, but can be installed with:
sudo snap install nmap # version 7.95, or
sudo apt install nmap # version 7.94+git20230807.3be01efb1+dfsg-2
See 'snap info nmap' for additional versions.
- Run the following command to install the
nmapprogram that scans networks. Confirm the installation when prompted.
sudo apt install nmap
- Test that the software was installed correctly by running
nmapin the terminal.
nmap
- You will see some
nmapdocumentation. Just runningnmapwithout any additional parameters will not perform any network scans. - Install some time-wasting fun with the following command. This installs multiple packages at one time--
bsdgames,cowsay, andnsnake.
sudo apt install bsdgames nsnake cowsay
- Run the following command to see the package documentation for
bsdgames.
apt show bsdgames
Description: collection of classic textual unix games
This is a collection of some of the text-based games and amusements that
have been enjoyed for decades on unix systems.
.
It includes these programs: adventure, arithmetic, atc, backgammon,
battlestar, caesar, canfield, cribbage, dab, go-fish, gomoku, hack, hangman,
pom, primes, robots, sail, snake, tetris, trek, worm, wtf, wump
- For example, you can now run the following games.
nsnake
tetris-bsd
snake
- You can also use the class (and powerful)
cowsayprogram.
cowsay Update your system
- This produces a very beautiful cow with your text in a speech bubble.
____________________
< Update your system >
--------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
At this point, your operating system is up-to-date and you some new applications on your system.
Challenge
- Search online for useful command-line programs in Linux. Test to see if they are installed on your Linux virtual machine. Install them if they need to be installed.
Reflection
- Why is updating your system important?
- Do you prefer the Microsoft way or the Linux way?
Key Terms
- Software Updates: The process of installing new versions or patches of software to improve functionality, fix bugs, enhance security, or add new features. Software updates can be applied to operating systems, applications, and firmware, ensuring that the software remains up-to-date and secure.
- Software Repository: A centralized storage location where software packages are stored and maintained. Repositories provide a convenient way to distribute and manage software, allowing users to easily install, update, and remove packages using package management tools. Examples include the Debian repository for Debian-based systems and the EPEL repository for Red Hat-based systems.