1. Why learn to update your system?
Updating the system is like visiting the doctor for a check-up. If you skip updates, sooner or later you'll run into bugs, vulnerabilities, and outdated software versions that'll give you a headache. Linux users joke that it's better to update the system before bedtime than deal with a "memory leak" later.
In real life, updates are important for:
- Improved security: new versions patch vulnerabilities and make your system less prone to attacks.
- Better performance: sometimes updates include optimizations that make programs run faster.
- Access to new features: don't you want to use the latest versions of your favorite apps?
- Bug fixes: developers work hard to fix issues, and updates often include these fixes.
If you're working in a big company, outdated software becomes an even bigger issue. Some Linux vulnerabilities can be exploited for attacks. Not updating servers = leaving the front door of your business wide open for attackers.
2. Basics of working with apt-get on Debian-based distributions
What is apt-get?
apt-get is a command-line utility for interacting with the Advanced Packaging Tool (APT), a package management system used in Debian and its derivative distributions (like Ubuntu). It's your magic tool for installing, removing, updating, and managing packages.
Key apt-get Commands
1. Updating the list of available packages
It's pretty much like refreshing your social media feed — you just check what's new out there. For that, use:
sudo apt-get update
This command fetches the latest info about available package versions from the specified repositories.
2. Upgrading all installed packages
When you want your system to be fully up to date, you can use:
sudo apt-get upgrade
This command upgrades all installed packages to the latest versions.
But there's also a more "aggressive" command:
sudo apt-get dist-upgrade
It not only upgrades packages but can also add or remove dependencies if needed for the update. Use it carefully.
3. Installing a new package
Want to install your favorite text editor? Here’s an example:
sudo apt-get install vim
apt-get will handle the dependencies and download everything required to make the package work.
4. Removing a package
If you no longer want to use a program, you can remove it with:
sudo apt-get remove vim
Or, to remove all of its configuration files as well, use:
sudo apt-get purge vim
5. Cleaning up unnecessary files
To get rid of leftovers from removed packages (and free up some disk space), use:
sudo apt-get autoremove
And for clearing the cache of downloaded packages:
sudo apt-get clean
3. Basics of using yum in RedHat-based distributions
What is yum?
yum (Yellowdog Updater Modified) is a package manager for RedHat-based distributions like CentOS and Fedora. Just like apt-get, it helps manage software, check for updates, and download dependent packages.
Main yum commands
1. Checking for updates
To see what updates are available, run:
sudo yum check-update
2. Updating the system
If you're ready to update everything at once:
sudo yum update
This command updates all packages to the latest available versions.
3. Installing a new package
Like with apt-get, installing a new package is straightforward:
sudo yum install vim
4. Removing a package
To remove a package, use:
sudo yum remove vim
5. Clearing up unnecessary data
After updates or package removals, temporary files might remain. You can clean them up with the command:
sudo yum clean all
4. Comparison of apt-get and yum
| Function | apt-get |
yum |
|---|---|---|
| Used in | Debian, Ubuntu | RedHat, CentOS, Fedora |
| Check for updates | sudo apt-get update |
sudo yum check-update |
| System update | sudo apt-get upgrade |
sudo yum update |
| Install a package | sudo apt-get install |
sudo yum install |
| Remove a package | sudo apt-get remove |
sudo yum remove |
| System cleanup | sudo apt-get autoremove |
sudo yum clean all |
5. Updating the System Using apt-get and yum
Let's try updating and installing packages in practice. As an example, we'll update the system and install the text editor nano.
Updating the System on Debian/Ubuntu
Update the list of available packages:
sudo apt-get updateUpgrade installed packages:
sudo apt-get upgradeInstall
nano:sudo apt-get install nano
Updating the System on CentOS/Fedora
Check for available updates:
sudo yum check-updateUpdate the system:
sudo yum updateInstall
nano:sudo yum install nano
6. Common Errors and Features
- If you see the error "Failed to fetch," it might be caused by issues with your internet connection or repository unavailability. Check your network and try again.
Sometimes when using
apt-getoryum, you might encounter a message about "locked" processes. This happens if another process (like an automatic update) is using the package manager. Wait or terminate the process using commands like:sudo killall apt-getDon't forget to regularly use cleanup commands (
apt-get autoremoveandyum clean all) to avoid filling up space with unnecessary files.
Practical Application of Knowledge
Linux pros are often tested on their ability to handle system updates and package installations during interviews. What's more, in today's DevOps world, server updates are one of the key tasks. Imagine automating updates with scripts — you not only save time but also avoid a bunch of human errors.
Ready for the next step? Go ahead and practice all of this, and remember: Linux pros are respected for keeping their systems clean!
GO TO FULL VERSION