Linux

How to fix Ubuntu PHP error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Problem:

When loading your wordpress page, you see the following message:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Solution:

Install the php[VERSION]-mysql package for the PHP version that is running wordpress.

For example:

sudo apt -y install php8.1-mysql

 

Posted by Uli Köhler in Linux

bash cat EOF to file minimal example

This is an example of using a Here document (Heredoc) in bash to write an inline string to a file.

cat <<EOF >/etc/dhcp/dhcpd.conf
authoritative;
default-lease-time 86400;
max-lease-time 86400;

subnet 192.168.99.0 netmask 255.255.255.0 {
  range 192.168.99.100 192.168.99.150;
  option routers 192.168.99.1;
  option domain-name-servers 192.168.99.1;
  option domain-name "local";
}
EOF

 

Posted by Uli Köhler in Linux

How to fix apt error: NO_PUBKEY A2F683C52980AECF

Problem:

When running apt update, you see the following error message:

Err:13 https://download.virtualbox.org/virtualbox/debian jammy InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A2F683C52980AECF

Solution:

This error occurs due to the VirtualBox repo using the outdated (as of April 2022) apt-key method of importing keys.

You can import the key by just installing the tailscale repo again (these commands are based on the commands from the VirtualBox Linux downloads page):

wget -qO- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

and then running

apt update

again.

 

Posted by Uli Köhler in Linux

How to fix apt error: NO_PUBKEY 458CA832957F5868

Problem:

When running apt update, you see the following error message:

Err:27 https://pkgs.tailscale.com/stable/ubuntu jammy InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 458CA832957F5868

 

Solution:

This error occurs due to the Tailscale repo using the outdated (as of April 2022) apt-key method of importing keys.

You can import the key by just installing the tailscale repo again (these commands are listed on the official tailscale installation page):

curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/jammy.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list

and then running

apt update

again.

 

Posted by Uli Köhler in Linux

How to generate JSON with random password with pwgen and bash

This script will generate a random password stored in a JSON file:

echo "{\"secret\": \"$(pwgen 30 1)\"}" > secret.json

Example output

{"secret": "thie2uv6Ro3cah2oodohx2vai5Ahka"}

 

Posted by Uli Köhler in Linux

How to view software RAID status on Linux

You can simply view /proc/mdstat:

cat /proc/mdstat

Example output

Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10] 
md2 : active raid5 sdb3[4] sdd3[0] sda3[2] sdc3[1]
      2111434752 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_]
      [===>.................]  recovery = 16.2% (114244316/703811584) finish=48.8min speed=201053K/sec
      bitmap: 2/6 pages [8KB], 65536KB chunk

md1 : active raid1 sdb2[3] sda2[2] sdd2[0] sdc2[1]
      1046528 blocks super 1.2 [4/4] [UUUU]
      
md3 : active raid5 sdb4[4] sda4[2] sdd4[0] sdc4[1]
      44661594624 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_]
        resync=DELAYED
      bitmap: 2/111 pages [8KB], 65536KB chunk

md0 : active raid1 sda1[2] sdb1[3] sdd1[0] sdc1[1]
      33520640 blocks super 1.2 [4/4] [UUUU]
      
unused devices: <none>

 

Posted by Uli Köhler in Linux

How to fix apt error: NO_PUBKEY 1F3045A5DF7587C3

Problem:

When running apt update, you see the following error message:

Err:14 https://repo.skype.com/deb stable InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1F3045A5DF7587C3

Solution:

This error occurs due to the Skype repo using the outdated (as of April 2022) apt-key method of importing keys.

You can import the key using the following commands:

wget -qO- https://repo.skype.com/data/SKYPE-GPG-KEY | gpg --dearmor | sudo tee /usr/share/keyrings/skype-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/skype-archive-keyring.gpg] https://repo.skype.com/deb stable main" > /etc/apt/sources.list.d/skype-stable.list

and then running

apt update

again.

 

Posted by Uli Köhler in Linux

How to fix apt error: NO_PUBKEY C5E224500C1289C0

Problem:

When running apt update, you see the following error message:

Err:2 https://linux.teamviewer.com/deb stable InRelease                                                                                                                                
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C5E224500C1289C0

Solution:

This error occurs due to the teamviewer repo using the outdated (as of April 2022) apt-key method of importing keys.

You can import the key using the following commands:

wget -q https://download.teamviewer.com/download/linux/signature/TeamViewer2017.asc -O- | gpg --dearmor | sudo tee /usr/share/keyrings/teamviewer-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/teamviewer-archive-keyring.gpg] https://linux.teamviewer.com/deb stable main" > /etc/apt/sources.list.d/teamviewer.list

and then running

apt update

again.

 

Posted by Uli Köhler in Linux

How to fix VFS: cifs_mount failed w/return code = -22

Problem:

When trying to mount a CIFS/SMB share, you see the following error log in dmesg:

[  139.680974] CIFS: Attempting to mount \\10.10.10.10\test
[  139.686714] CIFS: VFS: cifs_mount failed w/return code = -22

Solution:

This is a currently a bug in Samba or the Kernel but you can easily work around it by adding vers=2.0to the mount options, either in /etc/fstab or if using mount manually, by using the -o vers=2.0 option. This forces Samba to use SMB version 2.0 which does not have the bug.

Posted by Uli Köhler in Linux, Networking

How to find files with filename starting with a space on the command line

This simple bash script will recursively find files in the current directory which start with a space.

find . -name " *"

 

Posted by Uli Köhler in Linux

How to move all VCard files to other directory based on file content, ignoring the filename

This command will identify all VCard files in a directory by file content (not by file extensin recursively using the file command (looking for text/vcard MIME types) and move those to a different directory.

mkdir -p ../VCards && find . -type f -exec sh -c '
    case $( file -bi "$1" ) in (text/vcard*) exit 0; esac
    exit 1' sh {} \; -exec mv -v --backup=numbered {} ../VCards \;

Based on this StackExchange post. Also see How to move all images to other directory based on file content, ignoring the filename and How to move all videos to other directory based on file content, ignoring the filename and How to move all OOXML (Word .docx/Excel .xlsx) files to other directory based on file content, ignoring the filename

Posted by Uli Köhler in Linux

How to move all PDF files to other directory based on file content, ignoring the filename

This command will identify all PDF files in a directory by file content (not by file extensin recursively using the file command (looking for application/pdf MIME types) and move those to a different directory.

mkdir -p ../PDF && find . -type f -exec sh -c '
    case $( file -bi "$1" ) in (application/pdf*) exit 0; esac
    exit 1' sh {} \; -exec mv -v --backup=numbered {} ../PDF \;

Based on this StackExchange post. Also see How to move all images to other directory based on file content, ignoring the filename and How to move all videos to other directory based on file content, ignoring the filename and How to move all OOXML (Word .docx/Excel .xlsx) files to other directory based on file content, ignoring the filename

Posted by Uli Köhler in Linux

How to use xterm and picocom for serial VT52 emulation

First open xterm in VT52 mode:

xterm -ti vt52 -tn vt52

Inside the xterm terminal window, open picocom to access the serial port.

picocom -b 115200 /dev/ttyACM0

While the serial port access will be handled by picocom, the terminal emulation (i.e. escape code interpretation) will be handled by xterm.

Posted by Uli Köhler in Linux

How to set zsh as standard shell in Ubuntu

Install zsh

sudo apt install zsh

Add zsh to list of valid shells

sudo vim /etc/shells

Add to the list

/usr/bin/zsh

Set zsh as default shell

chsh -s /usr/bin/zsh

Double check

$ echo $SHELL

Now you might want to check out https://ohmyz.sh/#install to install a nice theme.

Posted by Joshua Simon in Linux

How to fix /dev/ttyUSB0 or /dev/ttyACM0 permission error

Problem:

When trying to connect to a USB device, you see an error like

[Errno 13] Permission denied: '/dev/ttyUSB0'

and the USB connection can’t be established.

Solution:

On Debian & Ubuntu, the /dev/ttyUSBx and /dev/ttyACMx devices are owned by the dialout group. Therefore, the solution is to add your user to the dialout group:

sudo usermod -a -G dialout $USER

After that, you need to logout completely and login again (if in doubt, reboot your computer)!

While you can sometimes quickly solve this issue by running whatever command you want to use as root using sudo, this is not a recommended solution since it will allow the program you’re calling full access to the entire computer – not just access restricted to the USB device. Therefore, this approach poses a significant security risk and additionally, some programs don’t work properly when called using sudo.

Posted by Uli Köhler in Embedded, Linux

How to install ESP32 esptool / esptool.py on Ubuntu

The recommended way is to install the current version using pip since the version installed using apt might be out of date:

sudo pip install esptool

After that, you can use esptool.py – note that you need to call it as esptool.py, not just as esptool!

In case you are missing pip , install python3-dev using apt:

sudo apt -y install python3-pip

 

Posted by Uli Köhler in ESP8266/ESP32, Linux, Python

How to permanently enable IPv4 forwarding in Alpine Linux

This simple command will permanently enable IPv4 forwarding on Alpine Linux. Run this as root:

echo net.ipv4.ip_forward=1 | tee -a /etc/sysctl.conf && sysctl -p

 

Posted by Uli Köhler in Alpine Linux, Networking

How to install tailscale in Alpine Linux

My recommendation is to just use the community repository:

echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories
apk add -U tailscale

Now you need to add tailscaled to the autostart list and then start the service so you can use it right now:

rc-update add tailscale
/etc/init.d/tailscale start

 

Posted by Uli Köhler in Alpine Linux

How to install usermod in Alpine Linux

Problem:

When trying to use usermod in Alpine Linux, you see the following error message:

-ash: usermod: not found

Solution:

Install usermod and related tools by adding the community repositories and using

echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories
apk add -U shadow

 

Posted by Uli Köhler in Alpine Linux

How to install gcsfuse on Ubuntu in 15 seconds

export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install gcsfuse

If that doesn’t work (such as for Ubuntu 21.10 impish at the time of writing this post), use the following method:

curl -L -O https://github.com/GoogleCloudPlatform/gcsfuse/releases/download/v0.39.2/gcsfuse_0.39.2_amd64.deb
sudo dpkg --install gcsfuse_0.39.2_amd64.deb
rm gcsfuse_0.39.2_amd64.deb

 

 

This is a summary from the official docs.

Posted by Uli Köhler in Cloud, Linux