[#]: subject: "Install and Use Flatpak on Ubuntu" [#]: via: "https://itsfoss.com/flatpak-ubuntu/" [#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" [#]: collector: "lkxed" [#]: translator: " " [#]: reviewer: " " [#]: publisher: " " [#]: url: " " Install and Use Flatpak on Ubuntu ====== The Linux world has three 'universal' packaging formats that allow running on 'any' Linux distribution; Snap, Flatpak and AppImage. Ubuntu comes baked-in with Snap but most distributions and developers avoid it because of its close source nature. They prefer [Fedora's Flatpak packaging system][1]. As an Ubuntu user, you are not restricted to Snap. You also can use Flatpak on your Ubuntu system. In this tutorial, I'll discuss the following: - Enabling Flatpak support on Ubuntu - Using Flatpak commands to manage packages - Getting packages from Flathub - Add Flatpak packages to Software Center Sounds exciting? Let's see them one by one. ### Installing Flatpak on Ubuntu You can easily install Flatpak using the following command: ``` sudo apt install flatpak ``` For **_Ubuntu 18.04 or older versions_**, use PPA: ``` sudo add-apt-repository ppa:flatpak/stable sudo apt update sudo apt install flatpak ``` #### Add Flathub repo You have installed Flatpak support in your Ubuntu system. However, if you try to install a Flatpak package, you'll get '[No remote refs found' error][2]. That's because there are no Flatpak repositories added and hence Flatpak doesn't even know from where it should get the applications. Flatpak has a centralized repository called Flathub. A number of Flatpak applications can be found and downloaded from here. You should add the Flathub repo to access those applications. ``` flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo ``` ![Install Flatpak in latest versions of Ubuntu and then add Flathub repo][3] Once Flatpak is installed and configured, **restart your system**. Otherwise, installed Flatpak apps won't be visible on your system menu. Still, you can always run a flatpak app by running: ``` flatpak run ``` ### Common Flatpak Commands Now that you have Flatpak packaging support installed, it's time to learn some of the most common Flatpak commands needed for package management. #### Search for a Package Either use Flathub website or use the following command, if you know the application name: ``` flatpak search ``` ![Search for a package using Flatpak Search command][4] 🚧 Except for searching a flatpak package, on other instances, the refers to the proper Flatpak package name, like`com.raggesilver.BlackBox`(Application ID in the above screenshot). You may also use the last word`Blackbox`of the Application ID. #### Install a Flatpak package Here's the syntax for installing a Flatpak package: ``` flatpak install ``` Since almost all the times you'll be getting applications from Flathub, the remote repository will be `flathub`: ``` flatpak install flathub ``` ![Install a package after searching for its name][5] In some rare cases, you may install Flatpak packages from the developer's repository directly instead of Flathub. In that case, you use a syntax like this: ``` flatpak install --from https://flathub.org/repo/appstream/com.spotify.Client.flatpakref ``` #### Install a package from flatpakref This is optional and rare too. But sometime, you will get a `.flatpakref` file for an application. This is **NOT an offline installation**. The .flatpakref has the necessary details about where to get the packages. To install from such a file, open a terminal and run: ``` flatpak install ``` ![Install a Flatpak package from Flatpakref file][6] #### Run a Flatpak application from the terminal Again, something you won't be doing it often. Mostly, you'll search for the installing application in the system menu and run the application from there. However, you can also run them from the terminal using: ``` flatpak run ``` #### List installed Flatpak packages Want to see which Flatpak applications are installed on your system? List them like this: ``` flatpak list ``` ![List all the installed Flatpak packages on your system][7] #### Uninstall a Flatpak package You can remove an installed Flatpak package in the following manner: ``` flatpak uninstall ``` If you want to **clear the leftover packages and runtimes, that are no longer needed**, use: ``` flatpak uninstall --unused ``` ![Remove a Flatpak package and later, if there is any unused runtimes or packages, remove them][8] It may help you [save some disk space on Ubuntu][9]. ### Flatpak commands summary Here's a quick summary of the commands you learned above: UsageCommand | | Search for Packages | flatpak search | | Install a Package | flatpak install | | List Installed Package | flatpak list | | Install from flatpakref | flatpak install | | Uninstall a Package | flatpak uninstall | | Uninstall Unused runtimes and packages | flatpak uninstall --unused | ### Using Flathub to explore Flatpak packages I understand that searching for Flatpak packages through the command line is not the best experience and that's where the [Flathub website][10] comes into picture. You can browse the Flatpak application on Flathub, which provides additional details like verified publishers, total number of downloads etc. You'll also get the commands you need to use for installing the applications at the bottom of the application page. ![][11] ![][12] ### Bonus: Use Software Center with Flatpak package support You can add the Flatpak packages to the GNOME Software Center application and use it for installing packages graphically. There is a dedicated plugin to add Flatpak to GNOME Software Center. 🚧 Since Ubuntu 20.04, the default software center in Ubuntu is Snap Store and it does not support flatpak integration. So, installing the below package will result in two software centers simultaneously: one Snap and another DEB. ![When you install GNOME Software Flatpak plugin in Ubuntu, a DEB version of GNOME Software is installed. So you will have two software center application][13] ``` sudo apt install gnome-software-plugin-flatpak ``` ![Installing GNOME Software Plugin in Ubuntu][14] ### Conclusion You learned plenty of things here. You learned to enable Flatpak support in Ubuntu and manage Flatpak packages through the command line. You also learned about the integration with the Software Center. I hope you feel a bit more comfortable with Flatpaks now. Since you discovered one of the three universal packages, how about [learning about Appimages][15]? _Let me know if you have questions or if you face any issues._ -------------------------------------------------------------------------------- via: https://itsfoss.com/flatpak-ubuntu/ 作者:[Abhishek Prakash][a] 选题:[lkxed][b] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://itsfoss.com/author/abhishek/ [b]: https://github.com/lkxed/ [1]: https://itsfoss.com/what-is-flatpak/ [2]: https://itsfoss.com/no-remote-ref-found-flatpak/ [3]: https://itsfoss.com/content/images/2023/06/install-flatpak-1.svg [4]: https://itsfoss.com/content/images/2023/06/flatpak-search.svg [5]: https://itsfoss.com/content/images/2023/06/flatpak-install-package.svg [6]: https://itsfoss.com/content/images/2023/06/install-flatpak-ref.svg [7]: https://itsfoss.com/content/images/2023/06/flatpak-list.svg [8]: https://itsfoss.com/content/images/2023/06/flatpak-uninstall-package-with-removal-of-unused.svg [9]: https://itsfoss.com/free-up-space-ubuntu-linux/ [10]: https://flathub.org:443/en-GB [11]: https://itsfoss.com/content/images/2023/06/Flathub-apps-page-2.png [12]: https://itsfoss.com/content/images/2023/06/application-details-in-flathub-website-2.png [13]: https://itsfoss.com/content/images/2023/06/two-software-centers-in-Ubuntu.png [14]: https://itsfoss.com/content/images/2023/06/install-gnome-flatpak-plugin.svg [15]: https://itsfoss.com/use-appimage-linux/