Install gfortran on Ubuntu
| Update apt | |
| Install gfortran | |
| Verify with gfortran --version | |
| Version notes |
Update apt
Start with a refresh of the package index so apt sees the latest package lists.
Run the update before every fresh install on a system that has not been updated for a while.
sudo apt update
Install gfortran
Install the compiler package from the standard Ubuntu repositories.
sudo apt install gfortran
Accept the install prompt when asked. The package pulls in the matching compiler libraries automatically.
Verify with gfortran --version
Confirm that the compiler answers from the command line, then compile and run a small hello program.
gfortran --version
GNU Fortran 13.2.0
gfortran -Wall -Wextra hello.f90 -o hello
./hello
Hello, Fortran
If the version line prints, the install is done. If the hello run prints the greeting, the full compile and run loop works.
Version notes
Each Ubuntu release ships one default gfortran version, usually a good match for this course.
Version 9 and newer cover everything used in the first lessons. Stay with the default package unless a lesson asks for a newer standard feature by name.
Next: Install gfortran on Rocky Linux
Article author: Arthur Isaev