Category: linuxupdate

Our Linux specific news, guides, and reviews.

  • PHP Warning:  Module “mysqli” is already loaded in Unknown on line 0

    PHP Warning: Module “mysqli” is already loaded in Unknown on line 0

    I recently encountered this error on a new server, and it turned out it was a result of a mismatch between the PHP version selected within Plesk and the PHP version in the CloudLinux PHP Selector.

    To resolve this, ensure that the correct PHP version is selected under both by heading to the PHP:

    Screenshot of the Plesk portal with the Dashboard tab selected, and a cursor hovering over Dev Tools > PHP showing version 8.2.22

    And then ensure the PHP version you need is selected from the drop-down list. If not, pick it from the list and then scroll to the bottom of the page and click Apply.

    Plesk PHP version selector. Set to 8.2.22

    Then, go back to the domain admin page in Plesk, and click PHP Selector from the sidebar on the right (you may need to press the small arrow button to expand).

    Plesk sidebar with options like Backup & Restore, Databases, Scheduled Tasks, WordPress, Action Log, PHP Selector, Resource Usage, and Imunify360

    Finally, pick a matching version from the dropdown list (red arrow) and click Apply (orange arrow). This should now resolve the error.

    PHP Selector with a red arrow pointing at the PHP version, and an orange arrow pointing at the Apply button.

     

  • How To: Set up an MTProto/MTProxy Telegram Proxy Server

    How To: Set up an MTProto/MTProxy Telegram Proxy Server

    Please note this guide now uses a fork of the official MTProxy software. The official version is unmaintained (no updates in 5 years), and there is a bug from 2019 that remains unfixed and makes using MTProxy on newer Ubuntu releases difficult. The fork used is the most popular on GitHub and is still free/open source.

    This post is being written because I set up an MTProto server for a friend in Russia who is concerned Telegram may be blocked soon after the country has decided to block uncensored western sites such as the BBC, Twitter, and Facebook and he is concerned Telegram may be next, but it is a good solution for bypassing blocking on a more local level. MTProto runs on any port you want, but using port 443 will disguise the outgoing connection to your server as ordinary HTTPS traffic – we will use port 443 in our guide.

    You will need:

    • A VPS/VM, low spec is OK (ours has 1GB of RAM and a single core 2GHz processor, I think far less would be fine and is running Ubuntu 22.04, but any distro should be fine). Ours is with IONOS (https://ionos.co.uk – not sponsored).
    • A domain if you wish to have a hostname for your server, you can just use the IP address of your server instead.
    • This guide also includes aspects copied from Telegram’s MTProxy GitHub, but their guide wasn’t quite right so I have amended aspects of it here. Their GitHub repo is here: https://github.com/TelegramMessenger/MTProxy
    • This guide now uses the fork: https://github.com/GetPageSpeed/MTProxy

    This guide assumes your server is already configured and up to date, and that you don’t have any other services listening on the port you intend to use. It is OK to have multiple things on the server, I have a VPN server running on mine too on different ports.

    1. Ensure you have the requisite dependencies installed to build MTProxy from source:

    On Ubuntu/Debian:

    apt install git curl build-essential libssl-dev zlib1g-dev

    On RHEL and RHEL derivatives (CentOS/Alma Linux/Rocky Linux etc):

    yum install openssl-devel zlib-devel
    yum groupinstall "Development Tools"
    2. Then clone the repo, and build:
    git clone https://github.com/GetPageSpeed/MTProxy
    cd MTProxy
    make && cd objs/bin

    Find your current directory using pwd (stands for print working directory) and make a note of it, you will need it later on:

    pwd

    The output for pwd for me is: /root/MTProxy/objs/bin

    3. Configure MTProxy

    Now you’ll need to obtain a secret from Telegram which is used to connect to Telegram’s servers:

    curl -s https://core.telegram.org/getProxySecret -o proxy-secret

    Now obtain the current Telegram configuration, Telegram’s GitHub says to update daily so we’ll set up a cron to do that later.

    curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf

    Next, generate a 16 character secret that you’ll use to authenticate users with your proxy server:

    head -c 16 /dev/urandom | xxd -ps

    Test the configuration by running MTProxy from the CLI.

    ./mtproto-proxy -u nobody -p 8888 -H 443 -S <secret> --aes-pwd proxy-secret proxy-multi.conf -M 1

    From Telegram’s GitHub:

    … where:
    nobody is the username. mtproto-proxy calls setuid() to drop privilegies.
    443 is the port, used by clients to connect to the proxy.
    8888 is the local port. You can use it to get statistics from mtproto-proxy. Like wget localhost:8888/stats. You can only get this stat via loopback.
    <secret> is the secret generated at step 3. Also you can set multiple secrets: -S <secret1> -S <secret2>.
    proxy-secret and proxy-multi.conf are obtained at steps 1 and 2.
    1 is the number of workers. You can increase the number of workers, if you have a powerful server.

    4. Test the server

    Then connect to the server to test by typing this into a web browser and allowing it to open in Telegram:

    https://t.me//proxy?server=SERVER_NAME&port=PORT&secret=SECRET

    E.g:

    https://t.me//proxy?server=example.server.com&port=443&secret=94e5233dd994526b3ad95adf0ec79648

    For bypassing censorship, I would suggest appending the secret (e.g; dd94e5233dd994526b3ad95adf0ec79648) with dd to use Telegram’s random padding mode (“Due to some ISPs detecting MTProxy by packet sizes, random padding is added to packets if such mode is enabled.”).

    If it works, press CTRL+C to terminate, and now we can get to creating a service to keep this running permanently:

    5. Create a service

    Next we will copy MTProxy into /opt (the default directory for unbundled packages), you will need the directory you made a note of in step 2.

    mkdir /opt/mtproxy
    cp /root/MTProxy/objs/bin/* /opt/mtproxy/

    Create systemd service file:

    nano /etc/systemd/system/mtproxy.service

    Edit this basic service (especially paths and params):

    [Unit]
    Description=MTProxy
    After=network.target
    
    [Service]
    Type=simple
    WorkingDirectory=/opt/mtproxy
    ExecStart=/opt/mtproxy/mtproto-proxy -u nobody -p 8888 -H 443 -S <SECRET> --aes-pwd proxy-secret proxy-multi.conf -M 1
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target

    Reload daemons:

    systemctl daemon-reload

    Test fresh MTProxy service:

    systemctl restart mtproxy.service
    # Check status, it should be active
    systemctl status mtproxy.service

    Enable it, to autostart service after reboot:

    systemctl enable mtproxy.service
    6. Automate fetching Telegram configuration and restarting the service

    The last step is to automate fetching Telegram configuration (mentioned in step 3).

    nano /opt/mtproxy/proxy-multi.sh

    Paste in the following:

    #!/bin/bash
    # Script to fetch proxy-multi.conf
    cd /opt/mtproxy
    curl https://core.telegram.org/getProxyConfig > proxy-multi.conf
    systemctl restart mtproxy.service

    Then add the cronjob (it will run at midnight every day):

    Open your crontab file in the interactive editor (on Ubuntu it allows you to pick an editor, but some distros will make you use VI/VIM):

    crontab -e

    Then paste the following line into the file:

    0 0 * * * /bin/bash /opt/mtproxy/proxy-multi.sh

    Now you’re done!

  • How To: Stop GNOME auto-printer discovery on Fedora/Ubuntu/Mint

    How To: Stop GNOME auto-printer discovery on Fedora/Ubuntu/Mint

    Note: April 8th 2022. This may no longer work. It worked at the time of writing, but my printers keep coming up again now.

    Modern GNOME based distros automatically discover and install printers on your network and there’s no easy way to disable this. In the past disabling cups-browsed was enough, but we also now need to disable Avahi discovery (Avahi is a zero-configuration discovery client).

    Firstly edit the avahi-daemon.conf file to essentially disable networking for the service. Disabling the service with systemd results in a long delay when opening a printing dialog, so disabling networking is a clever way to essentially disable Avahi without any negative effects.

    sudo nano /etc/avahi/avahi-daemon.conf
    

    Was:

    ...
    use-ipv4=yes
    use-ipv6=yes
    ...

    Change to:

    ...
    use-ipv4=no
    use-ipv6=no
    ...

     

    Then restart the avahi-daemon service:

    sudo systemctl restart avahi-daemon

    Lastly, you’ll still need to disable printer discovery in cups-browsed.conf too as we did in the past. You can do this with:

    sudo nano /etc/cups/cups-browsed.conf

    Find the BrowseProtocols line (ctrl+w will bring up search in Nano), and then uncomment the line (remove the # at the beginning of it) and save the changes.

    BrowseProtocols none

    From

    To:

    Then disable cups-browsed:

    sudo systemctl disable cups-browsed
    sudo systemctl stop cups-browsed
  • Enable Secure DNS on Brave/Chromium Browsers on Fedora

    Enable Secure DNS on Brave/Chromium Browsers on Fedora

    Chrome Fedora showing No Policies being applied

    Out of the box Fedora applies organisation management to Chromium based browsers, and while heading to chrome://policy doesn’t show any policies even being applied (the only one has Error as its status), browsers such as Brave will prevent you from enabling Secure DNS as long as organisation management policies are enabled showing the message “This setting is disabled on managed browsers”:

    This is an easy fix – you just need to remove the Fedora Chromium Config package with the command below:

    sudo dnf remove fedora-chromium-config

    Quit your browser and re-launch, and it should now be possible to secure Secure DNS and any messages about your browser being managed should be gone.

    Secure DNS Working

  • How To: Disable Intel Turbo Boost on Linux using systemd + intel_pstate

    How To: Disable Intel Turbo Boost on Linux using systemd + intel_pstate

    My laptop has issues with coil whine, resulting in me needing to disable Intel Turbo Boost. I usually use a GNOME Extension like CPU Power Manager but at the time of writing that extension isn’t compatible with GNOME 40, and isn’t much use for non-GNOME users.

    Firstly elevate to sudo with sudo -i, then:

    nano /etc/systemd/system/disable-intel-turboboost.service

    Paste in the following:

    [Unit]
    Description=Disable Intel Turbo Boost using pstate driver 
    [Service]
    ExecStart=/bin/sh -c "/usr/bin/echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo"
    ExecStop=/bin/sh -c "/usr/bin/echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo"
    RemainAfterExit=yes
    [Install]
    WantedBy=sysinit.target

    Next reload the systemd management configuration, enable and then start the new service, then lastly check the service is running. Enabling the service will start it automatically on a reboot, thus keeping Turbo Boost switched off all the time. If you only want to use it occasionally, skip the enable step and just start/stop the service as/when needed.

    systemctl daemon-reload
    systemctl enable disable-intel-turboboost
    systemctl start disable-intel-turboboost
    systemctl status disable-intel-turboboost

    The last command should give you:

    [root@amethyst ~]# systemctl status disable-intel-turboboost
    ● disable-intel-turboboost.service - Disable Intel Turbo Boost using pstate driver
    Loaded: loaded (/etc/systemd/system/disable-intel-turboboost.service; enabled; vendor preset: disabled)
    Active: active (exited) since Tue 2021-05-04 20:58:57 BST; 10s ago
    Process: 22392 ExecStart=/bin/sh -c /usr/bin/echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo (code=exited, status>
    Main PID: 22392 (code=exited, status=0/SUCCESS)
    CPU: 7ms
    
    May 04 20:58:57 amethyst systemd[1]: Started Disable Intel Turbo Boost using pstate driver.

    On my laptop it was immediately obvious Turbo Boost was turned off because the coil whine stopped instantly, but to check your current clock speed you can run:

    lscpu | grep "CPU MHz"
    CPU MHz: 1800.019

    To re-enable Turbo Boost permanently:

    sudo systemctl disable disable-intel-turboboost

    To re-enable Turbo Boost when needed (start service to disable Turbo Boostagain):

    sudo systemctl stop disable-intel-turboboost
  • How To: Timeshift on Fedora 34 with BTRFS

    How To: Timeshift on Fedora 34 with BTRFS

    Timeshift works fine on Fedora, but with a little bit of tweaking.

    Elevate to sudo with sudo -i, then install Timeshift with:

    dnf install timeshift -y

    Next find the name of the partition you want to use Timeshift on by running lsblk. On my laptop (ThinkPad X390) it is under nvme0n1 -> nvme0n1p3 > luks-xxxx… – copy the luks-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx string to your clipboard (it’s luks+ the UUID of your drive).

    lsblk output

    Next we’ll need to change the mount point of the luks volume (replace luks-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with the UUID of the partition you found in the step above):

    mkdir /btrfs_timeshift
    mount -o subvolid=5 /dev/mapper/luks-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /btrfs_timeshift

    Then move your root and home directories:

    mv /btrfs_timeshift/root /btrfs_timeshift/@
    mv /btrfs_timeshift/home /btrfs_timeshift/@home

    Next up edit your /etc/fstab file to replace subvol=root with subvol=@ and subvol=home with subvol=@home

    nano /etc/fstab

    /etc/fstab with changes made

    Next update grub’s configuration and reboot:

    grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
    reboot

    Now you can log back in, open Timeshift, and run through the setup guide.

    Select Snapshot Type: pick BTRFS, click Next
    Select Snapshot Location: pick your partition, click Next
    Select Snapshot Levels: up to you
    User Home Directories: I ticked Include @home subvolume in backups, left Enable BTRFS qgroups ticked and then clicked Finish.

    Credit: this was based on an excellent guide here: https://mutschler.eu/linux/install-guides/fedora-btrfs/

  • Hands-on with WSLg, the official WSL GUI

    Hands-on with WSLg, the official WSL GUI

    Microsoft announced on Wednesday that WSLg, the Microsoft-developed WSL GUI, is finally available for Windows Insiders in the Dev Channel after teasing it previously. This brings official support for Linux GUI apps to run alongside Windows ones, potentially ending the need for some people to dual-boot Windows and Linux.

    What works?

    • Clipboard copy/paste ✅
    • Sound ✅
    • Pinning Linux GUI apps to taskbar and start menu ✅
    • OpenGL Acceleration ✅
    • Windows folder access ✅
    Searching for a Linux app from the Windows Start Menu

    While there are other options available if you want to run Linux GUI apps in Windows, you could use a normal hypervisor like VMWare Workstation, or use WSL + tools like GWSL or X410 but both have their downsides. Hypervisors give you a full Linux instance, but VMWare Workstation does not support running Linux applications alongside Windows ones (Unity mode is only for Windows guests). GWSL and X410 are built to use WSL to allow side-by-side Windows/Linux apps, but they don’t support Wayland and have no built-in support for sound and poor support for scaling resulting in blurry windows or oversized windows for those using fractional scaling on their host machines.

    GNOME Text Editor alongside Notepad.exe

    Microsoft’s WSLg fixes all of those things by using RDP instead of a typical X11 server like the alternatives, and then the Weston compositor with  XWayland to allow X11 and Wayland applications and PulseAudio for sound. Microsoft says they have experience with per-window RDP with App-V and they’re doing something similar here.

    What doesn’t?

    • Drag-and-drop ❌
    • Aero snap/window pinning ❌

    WSLg is understandably a little rough around the edges, Aero Snap (pinning windows to the sides/corners of your display) doesn’t work yet but Microsoft is already aware and planning on adding support soon, and some software like GNOME Terminal and a few other apps won’t open yet but that I’ve not troubleshooted that issue so it could be specific to my machine and not WSLg itself. Otherwise, most things work and I’m very happy with it.

    For those interested in trying this out: once you have Windows 10 build 21362 or higher installed, there are instructions + links to drivers to enable OpenGL acceleration support available here: https://github.com/microsoft/wslg. For those that can wait, Microsoft should be including WSLg with the “next release of Windows 10” (hopefully meaning 21H1, due by June).

  • How to sync an iPod with Linux

    How to sync an iPod with Linux

    Apple might not make iPods any more, but there’s something of an iPod revival going on at the moment. I dug out my old iPod mini with 4GB spinning tiny very small hard disk the size of a CF card. You’ll need to make sure Rhythmbox is installed (comes with Ubuntu and Fedora, may come with other distributions).

    If your iPod is formatted for a Mac, you will need to restore the iPod to factory settings using iTunes on a Windows computer. It’s not ideal, but you could use a virtual machine. This blog post started out as being a guide for using Mac/HFS+ formatted iPods, but I just can’t get it to work.

    Start by opening Rhythmbox and importing your music into your library. First copy your music into the Music folder, and then click the Import button in Rhythmbox. If you already have music on your iPod, you click and drag it out from the iPod and into your library!

    Manual Sync:

    To manually sync music, simply drag the music you want to sync to the iPod and wait for it to copy. Eject when syncing is done.

    Automatic Sync:

    To automatically sync music, click on the iPod on the left hand side and then select Properties. Then go to the Sync tab and pick the artists/playlists/whatever you want to automatically sync.

    Then click Sync, and once done click Eject.

     

  • Top 5 GNOME Themes: November 2020

    Top 5 GNOME Themes: November 2020

    This month we’ve picked some of the best looking GNOME/GTK3 themes available from Pling. Almost every theme we’ve picked has dark/light variants and some have coloured variants too. We’ve used the Papirus icon pack available here.

    Venta X Dark

    Screenshot:

    Download URL: https://www.pling.com/p/1396612

    Ant

    Screenshot:

    Download URL: https://www.pling.com/p/1099856/

    Orchis

    Screenshot:

    Download URL: https://www.pling.com/p/1357889/

    Materials Original

    Screenshot:

    Download URL: https://www.pling.com/p/1427006/

    Sweet

    Screenshot:

    Download URL: https://www.pling.com/p/1253385/

  • How To: APFS write support for Fedora

    How To: APFS write support for Fedora

    Note: This guide is based on the guide made by the developer available at https://github.com/sgan81/apfs-fuse, but that guide is for Ubuntu.

    Download dependencies:

    sudo dnf install fuse fuse-devel libicu-devel bzip2 bzip2-devel cmake clang git zlib-devel

    Clone from Github:

    git clone https://github.com/sgan81/apfs-fuse.git
    cd apfs-fuse
    git submodule init
    git submodule update

    Then build:

    mkdir build
    cd build
    cmake ..

    If you have a 64 bit computer and don’t want to use the 32-bit version of FUSE run the command below:

    ccmake .

    Use the arrow keys to move the cursor down to the USE_FUSE3 item, and press the Enter key to change the option from ON to OFF, then press the c key to configure, and finally press the g key to generate.

    Finally run make to build the software.

    make

    To mount a drive, use

    apfs-fuse /dev/<device> <mount-directory>

    To mount a drive as root (to allow other users to access it):

    apfs-fuse -o uid=<uid>,gid=<gid>,allow_other /dev/<device> <mount-path>

    For more flags, see the guide from the developer here: https://github.com/sgan81/apfs-fuse