How to Install GNU Octave in Ubuntu 22.04 LTS

This article describes how to install GNU Octave, an interpreted high-level language intended mainly for numerical computations. It provides facilities for numerical solution of linear and nonlinear problems and for performing other numerical experiments. It also provides extensive graphics capabilities for visualizing and manipulating data. Octave is normally used through the interactive command line interface, but can also be used to write non-interactive programs. Octave's language is very similar to Matlab's, so most programs are easily portable.

We have run the commands and procedures mentioned in this article on an Ubuntu 22.04 LTS system.

Install GNU Octave 4.2 through Ubuntu Software Manager

Installation

For a person who does not want to open the Command Line much, installing software present in the Ubuntu repository through the UI is very simple. On your Ubuntu desktop Activities toolbar, click the Ubuntu Software icon.

Ubuntu Software Center

In the following view, click on the search icon and enter GNU Octave in the search bar. The search results will display GNU Octave as follows:

Search for GNU Octave in software list

This is the package maintained by Ubuntu in the Universe repository. However, this might not be the latest version of Octave. If you want to install the latest version of this software, please view the last section of this article.

From the Software Manager, click on the GNU Octave entry to open the following view:

Install the software

Click the Install button to begin the installation process. The following authentication dialog will display for you to provide your authentication details as only an authorized user can install software on Ubuntu.

Authenticate yourself as admin user

Enter your password and click the Authenticate button. After that, the installation process will begin, displaying a progress bar as follows:

Installing GNU Octave

GNU Octave will then be installed on your system and you will get the following message after a successful installation:

Software installed successfully

Through the above dialog, you can choose to directly launch GNU Octave and even Remove it immediately for whatever reason.

Launch GNU Octave

You can launch GNU Octave through the UI any time you want by entering relevant keywords in the Ubuntu Dash or access it directly from the Applications list.

Search for the software on Dash

When you launch Octave for the first time, the following dialog will open:

GNU Octave first start wizard

This dialog gives you the information that Octave will create a configuration file, in the current user’s home directory in the .config (hidden) folder.

Please click Next to create the configuration file that is required by Octave to function. The following dialog will open:

Get community news

Through this dialog, you can configure if you want Octave to keep connecting to the official Octave website and provide you with Community News that includes current news and information. You can choose to uncheck this item and check for community news through the Help menu of the Octave GUI, only when you wish to. Click Next.

Wizard finished

This is just information about how to access Octave support and documentation. Please click Finish, after which you are ready to use Octave.

GNU Octave is running

Install the Latest version of Octave

As mentioned above, the official Ubuntu repository does not include the latest version of Octave as of now. You can check which version of Octave you have by clicking the About Octave option from the Help menu in GNU Octave GUI.

Get the latest version of GNU Octave

The official Octave website lists Octave 7.2 as the latest release. If you want to get that version, follow these steps:

Open your Ubuntu command line, the Terminal, either through the system Dash or the Ctrl+Alt+T shortcut. For now, no PPA repository contains the latest and stable version of Octave, therefore we will use the Flatpak utility to install Octave from the Flathub repository.

Please enter the following command in order to install Flatpak if it is already not installed on your system:

$ sudo apt-get install flatpak

Install flatpak

The system will ask you for the password of sudo as only authorized users can install, remove and configure software on Ubuntu. The system will prompt you with a Y/n to confirm the beginning of the installation procedure. Enter Y and then hit Enter. The installation process will begin and might take some time depending on your Internet speed. Flatpak then will be installed on your system.

The next step is to add the Flathub repository that contains the latest Octave package, through the following command:

$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

The following dialog will ask you to provide authentication details for sudo:

Add Flatpak repository

Please provide the password and the Flathub repository will be added to your system.

Finally, enter the following command in order to install the latest version of Octave:

$ flatpak install flathub org.octave.Octave

Install latest Octave version with Flatpak

Enter Y to start the installation procedure. The Octave package is around 1.3 GB in size and might take long depending on your Internet speed.

Launch

In order to launch this package rather than the traditional GNU Octave package, run the following command in your Terminal:

$ flatpak run org.octave.Octave

Remove

If you want to remove the GNU Octave package installed through Flatpak, you can use the following command:

$ flatpak uninstall org.octave.Octave

You can then uninstall flatpak, if you need to, through the following command:

$ sudo apt-get remove flatpak

Hopefully, when the Ubuntu official PPA updates with the latest Octave version, the installation procedure will become much more simple. Till then, this article is here for your help!