Software on Linux is installed, updated and removed through a package manager. Keeping packages current and removing software you do not need are two of the most effective security habits. Practice only on your own VM, from a snapshot.
What a package manager does
A package manager downloads software from trusted repositories (online software libraries), checks that it is signed, installs it, and tracks every file it put on the system. This makes updates and removals clean.
Debian, Ubuntu and Mint use apt. Fedora and similar systems use dnf. This lesson uses apt, which is what most CyberPatriot Linux images use.
The package sources are listed in /etc/apt/sources.list and files in /etc/apt/sources.list.d/. These should point to your distribution’s official repositories. An unfamiliar source is worth investigating.
Updating the system
Updating is two separate ideas: refresh the list of what is available, then install the newer versions.
sudo apt update # refresh package lists
sudo apt list --upgradable # see what could be upgraded
sudo apt upgrade # install updates
sudo apt full-upgrade # also allow installs/removals the update needs
The kernel and core libraries often get security fixes. After a kernel update you may need to reboot.
To make security updates happen automatically, use the unattended-upgrades package:
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
Also check the Software and Updates settings, or the file /etc/apt/apt.conf.d/20auto-upgrades, to confirm daily checks are on.
Installing and removing software
apt search firewall # find packages
apt show ufw # read about one
sudo apt install ufw # install
sudo apt remove somepackage # remove the program, keep config
sudo apt purge somepackage # remove program and config
sudo apt autoremove # clean up unused dependencies
dpkg -l # list everything installed
Why does this matter for security? Every installed program is a possible weakness. If your README says the machine does not need a game server, a file-sharing tool or a network scanner, removing it shrinks your risk. On a practice image, scan the list from dpkg -l and look for unusual names. Before removing something, ask whether another program depends on it. apt will warn you if removing a package takes others with it, so read the prompt carefully instead of pressing Enter blindly.
Also check that the packages you rely on are still the right ones: apt policy openssh-server shows the installed version and where it came from. Only add third-party repositories if the task authorizes it.
Verifying a service-related package
Services you install often start running right away. After installing or removing, check what is running (you will learn systemctl in the next lesson). The habit is: change one thing, test, then document it in your notes.
Check your understanding
1. What does sudo apt update do?
- Installs all new versions
- Refreshes the list of available packages
- Removes old packages
- Reboots the system
Answer: Refreshes the list of available packages It only updates the package lists;
apt upgradeinstalls the new versions.
2. Which command removes a program and its configuration files?
- apt remove
- apt purge
- apt search
- apt show
Answer: apt purge Purge deletes configuration files as well, while remove leaves them.
3. Why remove software the system does not need?
- It makes the screen brighter
- Each installed program can add a possible weakness
- Linux requires it
- It speeds up typing
Answer: Each installed program can add a possible weakness Fewer programs means a smaller attack surface to maintain.
4. Where are package sources configured on Debian/Ubuntu?
- /etc/apt/sources.list
- /home/sources
- /var/tmp/apt
- /dev/apt
Answer: /etc/apt/sources.list Along with files in /etc/apt/sources.list.d/.
