Skip to content

Instantly share code, notes, and snippets.

@Prajwal-Koirala
Created July 22, 2024 16:20
Show Gist options
  • Save Prajwal-Koirala/9f4d31788fea1b5e7c00a278678b1302 to your computer and use it in GitHub Desktop.
Save Prajwal-Koirala/9f4d31788fea1b5e7c00a278678b1302 to your computer and use it in GitHub Desktop.

Updating Everything on Debian/Ubuntu Linux

One-Liner Command

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get clean -y && sudo apt-get autoremove -y && sudo apt-get autoclean -y && sudo apt-get install -f -y

Explanation of the Command

The one-liner command performs the following tasks sequentially:

  1. Update Package Lists:

    sudo apt-get update

    This command updates the local package lists to fetch the latest available versions of packages.

  2. Upgrade Installed Packages:

    sudo apt-get upgrade -y

    Upgrades all installed packages to the latest versions. The -y flag automatically answers yes to all prompts.

  3. Distribution Upgrade:

    sudo apt-get dist-upgrade -y

    Handles changing dependencies with new versions of packages and upgrades the distribution if required.

  4. Clean Up Disk Space:

    sudo apt-get clean -y

    Removes cached package files that are no longer needed.

  5. Remove Unused Packages:

    sudo apt-get autoremove -y

    Removes packages that were automatically installed as dependencies and are no longer needed.

  6. Clean Up Cache:

    sudo apt-get autoclean -y

    Removes old package files from the cache to free up disk space.

  7. Fix Broken Packages:

    sudo apt-get install -f -y

    Attempts to fix broken dependencies by installing or removing packages as necessary.

Notes

  • Security Updates: Regularly updating your system is crucial for security. Always prioritize security updates.
  • Reboot: Some updates, particularly kernel updates, may require a reboot to take effect. Check if a reboot is necessary after updating.
  • Backup: Consider backing up important data before major updates to avoid potential data loss.

Conclusion

By using the provided one-liner command or following the step-by-step guide, you can keep your Debian or Ubuntu Linux system up to date with the latest packages, security fixes, and enhancements. Regular updates ensure your system remains stable, secure, and compatible with newer software releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment