this post was submitted on 16 Dec 2023
10 points (100.0% liked)

linux4noobs

2638 readers
3 users here now

linux4noobs


Noob Friendly, Expert Enabling

Whether you're a seasoned pro or the noobiest of noobs, you've found the right place for Linux support and information. With a dedication to supporting free and open source software, this community aims to ensure Linux fits your needs and works for you. From troubleshooting to tutorials, practical tips, news and more, all aspects of Linux are warmly welcomed. Join a community of like-minded enthusiasts and professionals driving Linux's ongoing evolution.


Seeking Support?

Community Rules

founded 2 years ago
MODERATORS
 

I've written a small bash script to help with updating various packages/dependencies on my machine (Pop!_OS) but it doesn't seem to be working correctly for flatpak. If I run flatpak update in the terminal it will show that I have updates, but when running the script there aren't any updates.

The Script:

#!/bin/bash

# Update package list
sudo apt update -y

# Upgrade the packages and dependencies
sudo apt upgrade -y

# Remove unnecessary packages and dependencies
sudo apt autoremove -y

# Clean package cache
sudo apt clean -y

# Update Flatpak
sudo flatpak update -y

# Update firmware
sudo fwupdmgr update -y

echo "All updates and upgrades have completed sucessfully!"

EDIT: Running flatpak update -y without sudo fixes the issue.

top 5 comments
sorted by: hot top controversial new old
[–] mcmodknower@programming.dev 5 points 2 years ago (1 children)

Do you run flatpak update with or without sudo in your terminal?

[–] governorkeagan@lemdro.id 4 points 2 years ago* (last edited 2 years ago) (2 children)

Without.

EDIT: Just tested sudo flatpak update and it returned the same results as the script (duh!). Thanks for the help!

[–] AceSLS@ani.social 4 points 2 years ago* (last edited 2 years ago) (1 children)

There's something valueable to learn here. Seems like flatpak installs packages per user, meaning when you do

$sudo flatpak update

it runs as the root user, which probably doesn't have any packages installed.

Kind of a weird concept if you used Windows for a long time before switching to linux, where running as admin still used the same user account just with elevated privileges iirc

Edit: According to flathub running flatpak as root installs packages systemwide, otherwise they're installed on a per user basis. You should still keep the multi user thing I mentioned in your mind if you're used to windows

[–] governorkeagan@lemdro.id 3 points 2 years ago

I didn’t think of it like that but it makes total sense!

[–] mcmodknower@programming.dev 3 points 2 years ago

Then you should do the same in the script. Remove the sudo in front of flatpak update -y.