Linux

Linux group membership change appears to be ignored

If changes to group memberships appear to be ignored on a recent Linux system, even after logging out and then in, the likely reason is that the time between log out and log in was too short, and the user service did not terminate and restart. A system reboot will sort the problem, but could be seen as a bit of an overkill.

Much better is simply to wait longer before logging in again giving sufficient time for the user service to terminate, or explicitly restart the user service. Restarting the user service can in fact be used to log a user out:

sudo systemctl restart user@<uid>.service

Replace <uid> with your actual user ID.

Mount NextCloud folders

Linux:

sudo apt install davfs2
sudo usermod -aG davfs2 <username>
newgr davfs2
mkdir ~/cloud
mkdir ~/.davfs2
sudo cp /etc/davfs2/secrets ~/.davfs2/secrets
sudo chown <username>:<group> ~/.davfs2/secrets
chmod 600 ~/.davfs2/secrets
nano ~/.davfs2/secrets
/home/<username>/cloud <cloud_user> <cloud_password>
nano ~/.davfs2/davfs2.conf
use_locks       0
sudo nano /etc/fstab
#
# davfs mounts
#
https://<cloud_url>/remote.php/dav/files/<cloud_user> /home/<username>/cloud davfs   user,rw,_netdev,noauto,nofail       0 0
sudo systemctl daemon-reload

Windows:

TBC

Android:

Install the official NextCloud Android client.

Links:

Colour less pipes

By default less will display colour escape codes directly and will not interpret them. Some programs will only output colour when running in a colour capable terminal; by default a linux pipe is not considered colour capable. We have to tell them explicitly to generate and process colour escape sequences:

ls --color=always | less -R

For further details see askubuntu link.

Make your own QR codes

Install the tools:

sudo apt install qrencode zbar-tools

Create the source:

nano text_for_QR_code.txt
MECARD:N:Dr AN Other;TEL:+441234123456;EMAIL:AN Other <ANOther@other.org>;NOTE:Director;ADR:123 Other Street, London, A1N 2OT, United Kingdom;URL:https://other.org;

Generate the corresponding QR codes:

qrencode -t PNG -r text_for_QR_code.txt -l H -o QR.png
convert QR_2023.png QR_2023.jpg
qrencode -t ASCII -r text_for_QR_code.txt -l H -o QR_2023.txt
cat QR_2023.txt | sed 's/#/█/g' > QR_2023_utf8.txt

Useful links:

Disable snap and switch from snap to deb packages for Firefox in Ubuntu 22.04

Disable snapd

Remove Firefox (and other) snap packages:

snap list
snap remove firefox

Stop snapd service:

systemctl stop snapd.service
systemctl stop snapd.socket
systemctl stop snapd.seeded.service
systemctl disable snapd.service
systemctl disable snapd.socket
systemctl disable snapd.seeded.service

Remove snap related packages and directories:

apt autoremove --purge snapd chromium-browser* chromium-browser-l10n* gnome-software-plugin-snap* liblzo2-2* snapd* squashfs-tools*
rm -rf /var/cache/snapd
rm -rf /root/snap/
rm -rf /snap /var/snap /var/lib/snap

Install non-snap version of Firefox

Disable snap version

nano /etc/apt/preferences.d/mozilla-firefox
Package: firefox*
Pin: release o=Ubuntu*
Pin-Priority: -1
add-apt-repository ppa:mozillateam/ppa
apt update
apt install firefox
How to Install Latest Firefox as classic Deb in Ubuntu 22.04 | UbuntuHandbook
https://ubuntuhandbook.org/index.php/2022/04/install-firefox-deb-ubuntu-22-04/

How to Install Firefox as a .Deb on Ubuntu 22.04 (Not a Snap) - OMG! Ubuntu!
https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04

Change X11 window title

A typical use case is when an editor is setting its window title to the full long path name such that the actual important part, the file name, falls off the edge on the right and becomes invisible. Unfortunately the X11 window title is normally set internally by the application and its format is hard coded. A solution is to monitor the editor window title and modify it if its becomes too long.

Continue reading Change X11 window title

Repartition a new USB drive

I want to use my new USB drive exclusively with Linux, so I decided to wipe the factory default partitions and create a new ext4 filesystem on the drive. The drive uses 4096 byte physical sectors and we have to make sure that the new partition is correctly aligned. For some background information on partition alignment, see this link.

Check that we are wiping the correct drive

sudo parted /dev/sdb unit s print free

Note the details in case you want to restore the original partitioning scheme. Information on the factory default can also be found here.

Continue reading Repartition a new USB drive

Atril (evince, document viewer) default directory for Save As

For the XFCE desktop environment Atril is the default PDF viewer and I also use it to open any PDF files from Firefox. It is a great lightweight document viewer which does what I need most of the time. One exception is when after opening a PDF file from Firefox I decide to keep the file and select File Save As. Atril insists on saving the file in $HOME/Documents, which is practically never the directory I want to use…

Continue reading Atril (evince, document viewer) default directory for Save As

Disable annoying XFCE automatic maximise window feature

In XFCE when you move a window around and it gets close to the top edge of the screen it suddenly jumps to maximised size – this is never what I want and so I find this feature really annoying.

The setting where this feature can be turned off is hidden in a somewhat counter intuitive location:

Yes, the setting is called ‘Accessibility – Automatically tile …’!

Recovery of scanned PDF corrupted by email transfer

Occasionally when my scanner is emailing me a PDF it gets corrupted along the way. Most of the time the individual scanned images in the PDF are either perfectly valid or at least can viewed, even though the PDF viewer refuses to open the corrupt PDF file.

The bash script below will extract the images and then combine them again into a valid new PDF file.

Continue reading Recovery of scanned PDF corrupted by email transfer

Certwatch SSL certificate expiry warning

If you have just received an e-mail similar to the one below, read on.

From: root@your.domain.org To: sysadmin@your.domain.org Subject: The certificate for server.your.domain.org will expire in 13 days Date: yesterday (BST) ################# SSL Certificate Warning ################ Certificate for hostname ‘sws.hlan.laczik.org’, in file (or by nickname): /etc/pki/tls/certs/localhost.crt The certificate needs to be renewed; this can be done using the ‘genkey’ program. Browsers will not be able to correctly connect to this web site using SSL until the certificate is renewed. ########################################################## Generated by certwatch(1)
Continue reading Certwatch SSL certificate expiry warning