Kirsle.net logo Kirsle.net

Linux Phones

Updated: Oct 11, 2021

This is a collection of notes about running GNU/Linux operating systems on smartphones, specifically the Pine64 Pinephone but also probably applicable to the Purism Librem 5 and similar devices.

The focus of this page is on standard GNU/Linux distros such as postmarketOS, Debian/Phosh, Fedora and so on. Ubuntu Touch UBports is a different kind of creature altogether and many notes on this page may not apply there.

Table of Contents:

See Also

Listings of potential mobile-friendly Linux apps:

Web Browsers

Firefox

See also Firefox on postmarketOS Wiki

Firefox is another decent web browser for mobile Linux. With a few about:config tweaks you can enable better touch controls. Some parts of Firefox UI is not very mobile friendly and you probably only want to open one tab per window, as the tab bar doesn't fit on screen very well when you have 2+ tabs open.

To set the necessary about:config tweaks, easiest is to use your prefs.js. From the postmarketOS wiki:

Go in your profile directory (.mozilla/firefox/xxxxxxxx.default/) then exec:

echo 'user_pref("dom.w3c.touch_events.enabled", true);' >> prefs.js
echo 'user_pref("browser.gesture.pinch.in", "cmd_fullZoomReduce");' >> prefs.js
echo 'user_pref("browser.gesture.pinch.out", "cmd_fullZoomEnlarge");' >> prefs.js
echo 'user_pref("general.useragent.site_specific_overrides", false );' >> prefs.js
echo 'user_pref("general.useragent.override", "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Safari/537.361");' >> prefs.js

And restart the browser.

GNOME Web (Epiphany)

Most Phosh distros seem to ship the GNOME Web browser. Early on this browser performed well but in recent years it has always been laggy and clunky and likely lacks hardware acceleration. However, it does have good built-in support to install web apps to your home screen.

Installed web apps run in a mode where the URL bar is replaced by just a title bar and seems to have a sandboxed profile (no cookie sharing with the normal GNOME Web sessions).

User-Agent String

You may want to customize the User Agent to look like mobile Firefox so that sites like mobile.twitter.com will give a more modern front-end UI instead of one that looks themed after Android 2.x

Run this command to set the User-Agent to appear like Firefox:

gsettings set org.gnome.Epiphany.web:/org/gnome/epiphany/web/ user-agent "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Safari/537.361"

Chromium

I have tried Chromium as well as Ungoogled Chromium both from Flathub. They both work well -- scrolling web pages is buttery smooth like on Android (it's seriously the best web experience on Pinephone so far), but on the down side, text is rendered a little blurry due to some Wayland stuff that Chromium has been working on; I once found some flags you can enable to get better rendering but when I tried this, it made the browser unstable to use.

You can install uBlock Origin from the Chrome Web Store. But having any extension installed begins to cramp the user interface: the Chromium tab bar mostly fits on the mobile screen in portrait mode but with the added 'puzzle piece' icon for extensions this ends up pushing the main hamburger menu nearly off the screen. But with a combination of rotating into landscape mode you can work around this to a degree.

A huge plus that Chromium has is that you can install web apps as home screen icons and these open in full screen windows.

Productivity Apps

Nextcloud

I use Nextcloud as a self-hosted replacement for many Google services (see my Degoogle page).

GNOME Online Accounts already has built-in support to use Nextcloud and syncs your Contacts and Calendar with the respective GNOME apps. You can also browse your Nextcloud filesystem using the File Browser (Nautilus) app.

The desktop app for Linux is probably not mobile friendly but it has a command-line program called nextcloudcmd which may be usable to set up a traditional sync to local filesystem. I haven't tested it yet.

KeePass

I use the KeePass password manager and so need to find a good app for this that I can use from my smartphone.

I found a couple of good options now:

  • GNOME Password Safe is a mobile-optimized KeePass client that does everything I need except it doesn't support 2FA TOTP code generation.
  • KeePassXC is the app I use on desktops and it works on Pinephone via the scale-to-fit option in Phosh. The UI is a little tiny but it's entirely workable and I've been able to get my 2FA TOTP codes out of this app.

Very early on I found some luck with KeeWeb which had a decent enough mobile interface in the form of a web application. I installed it as a plugin on my Nextcloud server. For best security you might install it directly onto the localhost of your phone, e.g. with nginx and access it at http://localhost. Otherwise self-host it on a web server you control.

Security

At time of writing, GNU/Linux distros don't have a security model as good as what's available on Android. Linux security mainly boils down to filesystem-level access controls, but there's very little in the way to prevent two user-space apps from messing with each other's data.

Like on a desktop Linux system, common sense applies, don't install random dodgy software from unknown sources, don't wget | bash to run unknown scripts without reading them first and verify what they're doing, etc.

On distros running Phosh your user password is required to be a numeric PIN code that you unlock the screen with. These sorts of passwords are very weak and you may want to disable sudo access to your account and instead set a very strong root user password. The limiting factor is the Phosh lock screen which has only a numeric interface; if Phosh later supports alphanumeric passwords you would be able to set a better password. I've seen some people run GNOME Shell on their phone and its lock screen may support alphanumeric passwords but I haven't tried.

Some misc tips relevant to Linux on smartphones:

  • Use full disk encryption if available. Currently only postmarketOS and Mobian have installer images that can set this up for you.The idea being if your phone is lost or stolen you don't wanna make it easy for somebody to access the filesystem and steal secrets from Firefox's cookies or saved password store etc.
  • Use the GNOME Keyring or similar whenever possible. You can use any complex password you want for this, the stronger the better.
  • If your password is a numeric PIN code, disable sudo access to your account and either create a secondary sudoer user or configure a root password. Use strong passwords either way.
  • If your phone listens on an SSH server, set up SSH key-based authentication and disable login using password. Especially if your password is a numeric PIN code! Also disable root login over SSH.
  • If you generate SSH client keys on your phone, password protect those! In case your phone is lost/stolen it will buy you time to remove the phone's SSH keys from your servers' authorized_keys files.

Screenshots and Recordings

This is generally applicable to all Pinephone GNU/Linux distributions (Mobian, postmarketOS, etc.) that use Wayland as the compositor (most/all of them) and especially works with the Phosh shell (haven't tested others).

For screenshots: grim; for screen recording: wf-recorder

Screenshots (can be done over SSH):

# The command by itself auto creates a png in your home folder.
grim

# Specify a filename
grim filename.png

# Delay 10 seconds before taking the screenshot to get something other
# than your terminal window
sleep 10; grim

Screen recording:

# Record a video.
wf-recorder --filename output.mp4

# Record including audio from eg. microphone.
wf-recorder --audio --filename output.mp4

Default Software by OS

Just some notes on what each GNU/Linux distro comes with out of box and some notes. Note: pmOS and Fedora lists are likely outdated, I have long since stabilized on Mobian.

  • postmarketOS/Phosh:

    • Phone, SMS
    • GNOME Web
    • Cheese photo booth
    • Extensions (GNOME)
    • Settings
    • GNOME Software (not mobile friendly)
    • King's Cross (terminal emulator)
  • Fedora

    • Phone, SMS
    • GNOME Web
    • GNOME Contacts
    • Evolution mail client (not mobile friendly)
    • GNOME Software (not mobile friendly)
  • Mobian/Phosh (Oct 5 2020)

    • Phone, SMS
    • GNOME Web
    • Archive Manager
    • Authenticator
    • Calculator
    • Calendar
    • Clocks
    • Contacts
    • Document Viewer
    • Files
    • Firefox ESR
    • Flashlight
    • Fractal (matrix.org client)
    • Geary (mail client, mobile-friendly patches)
    • Image Viewer
    • King's Cross (terminal emulator)
    • Lollypop (offline music player)
    • GNOME Maps
    • Megapixels (camera app; front and back camera working)
    • Powersupply (battery statistics)
    • Settings
    • Software (GNOME Software)
    • Sound Recorder
    • Telegram
    • Text Editor (gedit)
    • To Do
    • Usage (CPU graph)

GNU Coreutils on postmarketOS

postmarketOS is based on Alpine Linux which is a very minimalist distro and ships with Busybox by default, meaning standard CLI tools like grep, less and du are Busybox versions and not the standard GNU coreutils found on most Linux distros.

So some CLI options to these programs aren't supported in Busybox, like grep --exclude or du --max-depth or less -r and several of my bash shell aliases relied on these options.

To install GNU versions (see also How to get regular stuff working from Alpine Linux wiki):

apk add coreutils grep less