How to Install and Uninstall gfortran Ubuntu 22.04

Updated: August 30, 2022

This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms supported by the gcc compiler. It uses the gcc backend to generate optimized code. In this guide, I will show you how to install gfortran on Ubuntu 22.04.

Software Requirement

  • OS: Ubuntu 22.04 is needed for gfortran to work
  • Privileges: Make sure you are able to execute sudo commands.

Prerequisites to install gfortran on Ubuntu 22.04

Install gfortran Ubuntu 22.04

gfortran is one of the popular ways on Ubuntu now so that this tutorial will show you how to install it in various ways. Choose the one that you think is easy and you can follow.

Install gfortran using APT

This is a popular method for installing any Ubuntu packages because it’s easy to follow, even if you are a newbie in Linux. Following these steps to get gfortran on your Ubuntu.

Step 1: The APT package repository cache needs to be updated before you try to install, update, or remove any packages. Update the APT database to download new packages from Ubuntu. Opening the terminal and executing the following Linux command:

sudo apt update

Step 2: Start installing the packages on Ubuntu 22.04. You can now install gfortran Ubuntu by executing this command in the terminal.

sudo apt -y install gfortran

Install gfortran using Aptitude

If you haven’t already installed Aptitude on Ubuntu, run this command to do so.

sudo apt -y install aptitude

Then, you can now install gfortran, just following these steps:

Step 1: Obtain new packages from Ubuntu by updating the APT database. Launching the terminal and entering the following Linux command:

sudo apt update

Step 2: Install the package on Ubuntu 22.04. After updating the system, you can install gfortran Ubuntu by pasting this command into the terminal and executing it.

sudo aptitude install gfortran

Uninstall gfortran on Ubuntu 22.04

Have you ever considered how challenging it might be to uninstall an application from Ubuntu? You’re wrong, anyone can easily uninstall any program, not just a gfortran.

You can uninstall gfortran Ubuntu by running this command if you installed it using APT or Aptitude.

sudo apt remove --auto-remove gfortran

If you want to uninstall gfortran and remove its data and dependencies, you can also run the following command:

sudo apt autoremove --purge gfortran

Conclusion

In this tutorial, I showed you ways to install gfortran on Ubuntu 22.04 and ways to uninstall gfortran too. If you need any help, don’t hesitate to contact me. I’m very glad to answer them.