Tag: Debian

How to increase the size of the partition and file system after increasing the physical size of the disk

Disk partition size and file system size

In Linux, a disk can be used entirely by one partition or be divided into several partitions (similar to volumes in Windows).

Usually, at the stage of installing the operating system, disk partitioning is done: disk partitions are created, and then these partitions are formatted into one or another file system. In this case, the size of the file system corresponds to the size of the partition (or the entire disk, if there is only one partition). That is, the sizes of file systems are equal to the sizes of partitions.

But there may be situations when the size of the file system no longer matches the size of the partition on which it is located. Examples of such situations:

  • you increased the disk size of your virtual private server (VPS)
  • you replaced your computer's hard drive and transferred the root file system using the dd utility (or other utilities that support creating and writing clones of entire disks and partitions) to a new disk

In both cases described, the Linux operating system will only be able to use the size that the file system originally had.

For clarity, let's understand the terms:

Disk size – the entire size of a physical or virtual disk. It can be used by the operating system in whole or in part within the created partitions and file systems.

Partition size – the space that a particular partition occupies. When cloning partitions with dd to a disk of a larger partition, the layout of the previous disk is preserved. That is, the operating system can even use a new disk only within the limits of the old disk layout.

Filesystem size – similar to partition size, the OS can only use a partition up to the size of the filesystem, even if the filesystem is moved to a new disk of a larger partition.

If you still do not fully understand the difference between “partition size” and “file system size”, then you need to know that, from a practical point of view, when increasing the disk size, you need to run two commands:

  • partition increase command
  • file system increase command

Note: For some hosting providers, the file system size increases automatically after switching to a plan with a larger disk size. For example, with Digitalocean, it is enough to select a larger disk and wait for the changes to be applied. And with Ihor hosting, after increasing the size of the server disk (can be done only through the support service), you need to increase the size of the partitions and the file system yourself.

How to increase the partition size and file system size on the server

This article will show you how to increase the partition and file system size on a computer without a graphical user interface, without rebooting the computer, without unmounting the file system, and without having to boot into Live OS. That is, you can use the shown method on servers. But nothing prevents you from using the commands from this article also on your home computer, for example, when cloning the OS to a new disk.

In this article, I am expanding the ext4 file system. The described commands should definitely work for ext2/ext3/ext4 filesystems.

I'm following the steps on Arch Linux, but the commands shown should work for any OS. Only the file system type matters. That is, if you want to increase the size of ext2 / ext3 / ext4, then this instruction should work regardless of the Linux distribution.

Utilities for increasing the size of partitions and the file system.

We need the resize2fs utility. This utility is included in the e2fsprogs package and is most likely installed in your distribution by default, since it usually refers to core packages, that is, programs necessary for the normal functioning of the Linux OS.

We also need the growpart utility, which is included in the cloud-utils package.

  • On Debian and Ubuntu derivatives, to install this package, run the commands:
sudo apt update
sudo apt install cloud-utils
  • On Arch Linux and derivatives of this distribution, to install the cloud-utils package, run the command:
pacman -S cloud-utils

Backing up the partition table

Just in case something goes wrong, back up your drive's partition table:

sfdisk -d /dev/vdX > partition_bak.dmp

Save the partition_bak.dmp file to a safe location other than the drive you backed up the partition table, because if data loss occurs, this file will also become inaccessible.

How to check partition size and file system size

Let's look at the size of the file system with the following command

df -h

Sample output:

Filesystem      Size  Used Avail Use% Mounted on
dev             2.0G     0  2.0G   0% /dev
run             2.0G  552K  2.0G   1% /run
/dev/vda2        30G   28G     0 100% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           2.0G   27M  1.9G   2% /tmp
/dev/vda1       193M  103M   80M  57% /boot
tmpfs           393M     0  393M   0% /run/user/0

From this output it follows that the size of the file system on the /dev/vda2 partition is 30G and there is no free space on it.

Let's see the sizes of disks and partitions:

fdisk -l

Sample output:

Disk /dev/vda: 35 GiB, 37580963840 bytes, 73400320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4b23ea92

Device     Boot  Start      End  Sectors  Size Id Type
/dev/vda1  *      2048   411647   409600  200M 83 Linux
/dev/vda2       411648 62914559 62502912 29.8G 83 Linux

It follows from these information that the size of the /dev/vda disk is 35 GB, and the size of the partitions present on it is 30 GB. The fact is that I hosting provider increased the size of the disk at my request. But the OS can still only use the old disk size.

How to increase the size of a Linux partition on the command line without Live System and unmounting the file system

To increase the partition to the maximum (taking into account free disk space), use the following command:

growpart /dev/DISK NUMBER

In this command:

  • /dev/DISK – disk device name
  • NUMBER – the number of the partition you want to enlarge

I want to enlarge the /dev/vda2 partition, so in my case:

  • /dev/DISK is “/dev/vda
  • NUMBER is “2

The command itself takes the following form:

growpart /dev/vda 2

But before executing it, it is recommended to run your command with the -N option. This option will cause the command to show what changes it will make, but the changes themselves will not be performed.

So let's run the command:

growpart -N /dev/vda 2

Sample output:

CHANGE: partition=2 start=411648 old: size=62502912 end=62914559 new: size=72988639 end=73400286
# === old sfdisk -d ===
label: dos
label-id: 0x4b23ea92
device: /dev/vda
unit: sectors
sector-size: 512

/dev/vda1 : start=        2048, size=      409600, type=83, bootable
/dev/vda2 : start=      411648, size=    62502912, type=83
# === new sfdisk -d ===
label: dos
label-id: 0x4b23ea92
device: /dev/vda
unit: sectors
sector-size: 512

/dev/vda1 : start=        2048, size=      409600, type=83, bootable
/dev/vda2 : start=      411648, size=    72988639, type=83

“# === old sfdisk -d ===” shows that the /dev/vda2 partition has 62502912 sectors (to get the disk size, multiply the number of sectors by the size of one sector, for example, 62502912*512/1024/1024/1024 = 29.80 GB).

# === new sfdisk -d ===” shows the size of the /dev/vda2 partition after running the command. This size is 72988639 sectors (i.e. 72988639*512/1024/1024/1024 = 34.80 GB).

Since in my case the disk is 100% used, and the partition resizing operation is very serious, before actually moving on to the changes, I freed up some disk space. How to do this, see the articles:

If everything is correct, now we run a command that will actually resize the selected partition, increasing it to the maximum possible in accordance with the available free space on the disk (remember to substitute your disk value and partition number):

growpart /dev/vda 2

Sample output:

CHANGED: partition=2 start=411648 old: size=62502912 end=62914559 new: size=72988639 end=73400286

Check the partition and file system sizes:

df -h

fdisk -l

Pay attention to the line:

/dev/vda2        30G   28G  285M  99% /

The file system size is still around 30 gigabytes. Its usage dropped from 100% to 99% just because I freed up disk space.

Also note the following line:

/dev/vda2       411648 73400286 72988639 34.8G 83 Linux

That is, the size of the /dev/vda2 partition has really increased.

How to increase the size of a Linux filesystem on the command line without Live System and unmounting the filesystem

The command to increase the file system to the maximum size in accordance with the free space on the partition is as follows:

resize2fs /dev/DEVICE

In this command, /dev/DEVICE is the name of the disk device.

In my case, the name of the partition I want to enlarge is /dev/vda2, then the command is:

resize2fs /dev/vda2

Sample output:

resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/vda2 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/vda2 is now 9123579 (4k) blocks long.

The output says that the filesystem on /dev/vda2 is mounted on / (the root filesystem), so “on-line resizing” is required. The command completed successfully.

Check the partition and file system sizes:

df -h

fdisk -l

Pay attention to the line:

/dev/vda2        35G   28G  5.0G  85% /

The filesystem on /dev/vda2 is now 35G in size and only 28G is occupied. That is the file system is really increased.

Regarding the partition size we increased in the previous step

/dev/vda2       411648 73400286 72988639 34.8G 83 Linux

nothing has changed for it.

How to update the GRUB bootloader on Debian and derivative distributions (Kali Linux, Ubuntu, Linux Mint)

The GRUB operating system loader is installed and updated on Linux like any other software package. But the peculiarity of the bootloader is that even after updating the package, the actual working files of the bootloader, which are located on the partition mounted along the /boot/grub/ path, are not automatically updated.

That is, when new versions of GRUB are released, the package in your OS is updated automatically.

But the bootloader itself, which is installed on a separate disk partition and mounted along the /boot/grub/ path, is not updated.

To start using the new features that are added in new versions of GRUB, you need to manually update the bootloader.

When to update the GRUB bootloader in /boot/grub/

The signal that a new version of GRUB has been released is something like the following messages:

Setting up grub-common (2.06-8+kali1) ...
...........
Setting up grub2-common (2.06-8+kali1) ...
...........
Setting up grub-pc-bin (2.06-8+kali1) …

Another sign that the GRUB package has been updated is a request to update the default GRUB configuration file.

In order to use the new features introduced in this GRUB update, it is recommended to install it in MBR or UEFI. Due to potential configuration incompatibilities, it is recommended that you perform both installation and configuration creation.

That is, if you see this message, then you need to update the bootloader in /boot/grub/.

How to check if GRUB is being used on the operating system

On Arch Linux and derivative distributions, the GRUB package can be installed but is not used because the bootloader is systemd-boot.

To verify that GRUB is the bootloader, run the following command:

ls -l /boot/grub/grub.cfg

If the /boot/grub/grub.cfg file is found, then GRUB is being used, if the grub.cfg file is not found, then GRUB is not used and does not need to be updated. That is, you do not need to follow the steps shown in this article!

For details, see the article: How to check if a computer is using BIOS or UEFI; GRUB or systemd-boot bootloader; MBR or GPT partition table

How to update the GRUB bootloader in /boot/grub/

To update the bootloader, you need to run a command like:

grub-install --recheck /dev/DISK

Where /dev/DISK should be the name of your drive.

Drive names can be checked with the command:

fdisk -l

Example output:

Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start       End   Sectors Size Id Type
/dev/vda1  *     2048 104857566 104855519  50G 83 Linux


Disk /dev/vdb: 450 KiB, 460800 bytes, 900 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

In this case, the drive name is /dev/vda. Note that /dev/vda is not a boot partition or some other partition – it's the entire drive.

So, the command to update GRUB in /boot/grub/ in my case is the following:

grub-install --recheck /dev/vda

Example output:

Installing for i386-pc platform.
Installation finished. No error reported.

You also need to create a new configuration file with the following command:

grub-mkconfig -o /boot/grub/grub.cfg

Example output:

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.0.0-kali6-cloud-amd64
Found initrd image: /boot/initrd.img-6.0.0-kali6-cloud-amd64
Found linux image: /boot/vmlinuz-6.0.0-kali5-cloud-amd64
Found initrd image: /boot/initrd.img-6.0.0-kali5-cloud-amd64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done

GRUB bootloader update and GRUB configuration update completed successfully. The next time you boot, your operating system will use the new features that were added by the GRUB update.

Error “No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed” (SOLVED)

Debian and derivative distributions (Ubuntu, Linux Mint, Kali Linux, and many others) may experience a “FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed” error when migrating from PHP 8.1 to PHP 8.2.

Apache web server log

sudo tail /var/log/apache2/error.log

contains the following error messages:

[Sun Jan 29 03:05:45.213609 2023] [proxy:error] [pid 1313500] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed
[Sun Jan 29 03:05:45.213763 2023] [proxy_fcgi:error] [pid 1313500] [client 127.0.0.1:58950] AH01079: failed to make connection to backend: httpd-UDS
[Sun Jan 29 03:06:39.789031 2023] [proxy:error] [pid 1313496] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed
[Sun Jan 29 03:06:39.789110 2023] [proxy_fcgi:error] [pid 1313496] [client 127.0.0.1:50024] AH01079: failed to make connection to backend: httpd-UDS
[Sun Jan 29 03:06:41.336218 2023] [proxy:error] [pid 1313499] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed
[Sun Jan 29 03:06:41.336297 2023] [proxy_fcgi:error] [pid 1313499] [client 127.0.0.1:50040] AH01079: failed to make connection to backend: httpd-UDS
[Sun Jan 29 03:07:24.027400 2023] [proxy:error] [pid 1313497] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed
[Sun Jan 29 03:07:24.027445 2023] [proxy_fcgi:error] [pid 1313497] [client 127.0.0.1:44688] AH01079: failed to make connection to backend: httpd-UDS
[Sun Jan 29 03:09:55.008467 2023] [proxy:error] [pid 1504919] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed
[Sun Jan 29 03:09:55.008530 2023] [proxy_fcgi:error] [pid 1504919] [client 127.0.0.1:38382] AH01079: failed to make connection to backend: httpd-UDS

Sites and engines that use PHP, such as phpMyAdmin, give the following error:

503 Service Unavailable
Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.4.55 (Debian) Server at localhost Port 80

The essence of the problem is indicated in the web server logs – it is impossible to connect to the php8.1-fpm.sock socket. This is a fairly predictable problem when changing the PHP version, in this case from PHP 8.1 to PHP 8.2.

FPM (FastCGI Process Manager, FastCGI process manager) is an alternative implementation of PHP FastCGI with several additional features commonly used for high load sites.

To disable an outdated version of FPM, run the following commands:

sudo a2disconf php8.1-fpm
sudo systemctl restart apache2

At this point, engines and sites that don't use FPM should already be working fine.

If you are really using FPM and want to enable the new version, then run the following commands:

sudo a2enconf php8.2-fpm
sudo systemctl reload apache2
sudo systemctl restart apache2.service
sudo systemctl restart php8.2-fpm

How to install the latest version of Tor on Ubuntu

How to get the latest version of Tor on Ubuntu

The tor package is present in the Ubuntu repositories, but its version may be out of date. This is especially true for Ubuntu distributions released several years ago, even if they have long-term support (LTS).

In new versions of Tor, identified weaknesses and vulnerabilities are eliminated, as well as updating and supplementing the functionality. For this reason, you may need to install the latest version of the tor package.

Like other programs on Linux, you can compile Tor from source, and this article will show you how. Fortunately, the Tor developers maintain a binary repository for Ubuntu and Debian distributions.

In this guide, we will look at two ways to install a fresh version of Tor – from the repositories and from the source code.

How to install Tor from the Tor developers repositories

The Tor Project has its own Debian repository. Debian itself includes an LTS version of Tor. With it, you will not always be able to have the latest and most stable version of Tor. Therefore, it is recommended to install tor from the Tor Project repository.

This section will show you how to enable the Tor package repository on Debian-based Linux distributions.

Prerequisite: Verify the CPU architecture

The package repository offers amd64, arm64, and i386 binaries. Verify your operating system is capable of running the binary by inspecting the output of the following commend:

dpkg --print-architecture

It should output either amd64, arm64, or i386. The repository does not support other CPU architectures.

Note on Raspbian: The package repository does not offer 32-bit ARM architecture (armhf) images (yet). You should either install the version Debian offers (make sure to check out Debian backports, too, as that one has often a more up-to-date Tor package), or build Tor from source.

1. Install apt-transport-https

This step is only required for apt versions below 1.5. Support for https was added in versions of apt 1.5 and later, so currently the apt-transport-https package is kept in the repository for compatibility only and can be removed from the system without consequences.

To check the version of apt use the command

apt --version

On older distributions, you may need to install this package:

sudo apt install apt-transport-https

2. Create a new file in /etc/apt/sources.list.d/ named tor.list.

sudo gedit /etc/apt/sources.list.d/tor.list

Add the following entries:

deb [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main
deb-src [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main

In these lines, replace <DISTRIBUTION> with your operating system code. Run

lsb_release -c

to find out the operating system code.

The following command will output only the distribution code (the command is suitable for use in scripts):

lsb_release -c | awk '{print $2}'

Note. Starting with Ubuntu Focal, 32-bit applications are no longer supported, so when using sudo apt update, you may encounter the message:

Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://deb.torproject.org/torproject.org focal InRelease' doesn't support architecture 'i386'

To get rid of this message, the entries in the /etc/apt/sources.list.d/tor.list file need to be edited to be in the following format:

   deb     [arch= signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org focal main
   deb-src [arch= signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org focal main

Replace <ARCHITECTURE> with the architecture of your system, which can be viewed with the command

dpkg --print-architecture

For example:

deb [arch=amd64 signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org impish main
deb-src [arch=amd64 signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org impish main

3. Then add the gpg key used to sign the packages by running the following command at your command prompt:

wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | sudo tee /usr/share/keyrings/tor-archive-keyring.gpg >/dev/null

4. Install tor and tor debian keyring

It is provided a Debian package to help you keep the latest version of your signing key. To install, use the following commands:

sudo apt update
sudo apt install tor deb.torproject.org-keyring

Source: https://support.torproject.org/apt/tor-deb-repo/

How to compile and install Tor from source on Ubuntu and Debian

This method differs from the previous one from a practical point of view in at least two important points:

  1. You need to keep track of new versions and update Tor yourself
  2. With this method, tor.service files are not created, that is, it will not be possible to manage the service using systemd with commands like
sudo systemctl start tor

To compile tor run the following commands:

sudo apt remove tor
sudo apt update
sudo apt install git make build-essential automake autoconf libevent-dev libssl-dev zlib1g-dev zlib1g asciidoc liblzma-dev libzstd-dev systemd libsystemd-dev pkg-config libnss3-dev
git clone https://github.com/torproject/tor
cd tor
sh autogen.sh
./configure --enable-systemd --enable-nss
make

Note that if the make command throws an error

make: *** No targets specified and no makefile found. Stop.

this means that the previous configure command failed. You need to return to its output and look in the last lines for the name of the missing package or another reason due to which the configuration failed.

After a successful compilation configuration, the installation is done like this:

sudo make install

To start Tor run the command:

tor

A sample configuration file is located at /usr/local/etc/tor/torrc.sample, you can use this as a base to configure Tor:

sudo cp /usr/local/etc/tor/torrc.sample /usr/local/etc/tor/torrc

Should I install Tor from my package manager or build from source?

If you are using Debian or Ubuntu, installing Tor from the Tor Project repository has several advantages:

  1. Your ulimit -n is set to 32768, which is enough for Tor to keep all necessary connections open.
  2. The user profile is created only for Tor, so Tor does not need to be run as root.
  3. An init script is included in the package so that Tor can be configured to start on boot. You can use systemd and systemctl to control the service
  4. Tor works with the --verify-config option, which means that before starting the service, the configuration file will be checked for correctness – this can help you solve problems if the service is not running.
  5. Tor can bind to low-level ports and then lower the privileges of its process.

See also: More Tor manuals

Do services need to be restarted when updating packages

Package configuration: whether to restart the service

During the installation of package updates and their configuration, the apt program may ask you to restart the service:

There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade. Restart services during package upgrades without asking?

This message can be confusing, especially the phrase “cause interruptions of service for the system”. In fact, the essence is quite simple – the binaries have been updated and you need to restart the services that use them so that they start using the updated versions of the files.

The name of the package that requires the service to be restarted is in the upper left corner, in the screenshot it is libc6, i.e. “GNU C Library: Shared libraries”. It contains the standard libraries that are used by nearly all programs on the system. This package includes shared versions of the standard C library and the standard math library, as well as many others.

What kind of interruptions can a service restart cause?

Examples of the consequences of restarting services:

  • at the time of restarting the web server service, sites will be unavailable to users
  • when restarting the caching proxy server, the cache stored in RAM will be deleted
  • restarting network services can lead to connection drops (but in practice this does not always happen)

That is, the possible consequences of restarting services on the home computer are insignificant – you can safely restart.

As far as restarting services on a server, for example, restarting the SSH server usually doesn't break the connection. You need to evaluate the consequences of restarting other services based on your situation.

See also:

How to Install the Latest Linux Kernels on Debian and Debian Based Distributions

Recent versions of the Linux kernel have drivers for new devices and other innovations. Unfortunately, many popular Linux distributions are in no rush to update their kernel. This tutorial will show you how easy it is, without compiling, to install any version of the Linux kernel on Debian and derived distributions, for example, Kali Linux and LMDE (Linux Mint Debian Edition). You can choose to install either a newer kernel or an older one than your distribution's repository suggests.

If you wish, you can easily remove the installed Linux kernels and return to the kernel from the repository.

Note that there are separate instructions for Ubuntu and derivatives, as the process for updating kernels is different: “How to Install the Latest Linux Kernels on Ubuntu and Linux Mint”.

Kernel update warning

It should be remembered that due to the incompatibility of the kernel with programs (first of all, with proprietary GPU drivers), you may encounter problems, including a black screen during boot.

In most cases, the problems encountered can be resolved without reinstalling the distribution. Start by going to the advanced options in the boot menu and boot with the previous version of the kernel. When the computer boots up, remove the problematic kernel.

Proprietary graphics card drivers can cause problems, as older versions may not be compatible with the latest kernels without a patch. If you have proprietary video drivers installed, then seriously consider before following the instructions below. Also get ready, look for instructions on how to solve the problem when loading the distribution into a black screen.

Owners of old distributions should be especially careful – it is strongly recommended to update the kernel only on the latest OS versions.

Another very likely problem that you may encounter if you install the latest kernel is the problem with unresolved dependencies and, as a result, the inability to use the apt package manager to update and install programs. If you are faced with a situation where, after successfully installing a new kernel, you cannot update packages using apt, then try installing older versions of the kernel that suit you, and uninstall the versions that cause dependency problems. Remember that it is impossible to remove the kernel you booted with – boot your computer with any other version of the kernel before uninstalling.

Upgrading the Kernel to the Latest Version on Debian

This section should be suitable for all variations and derivatives of Debian, for example:

  • Debian stable
  • Debian testing
  • Kali Linux
  • Linux Mint Debian Edition (LMDE)
  • MX Linux
  • other

Let's check the current kernel version:

uname -a

In order not to compile the kernel from scratch, we will use the kernels of the XanMod Kernel project.

To install the latest kernel version, just run the following commands:

echo 'deb http://deb.xanmod.org releases main' | sudo tee /etc/apt/sources.list.d/xanmod-kernel.list
wget -qO - https://dl.xanmod.org/gpg.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/xanmod-kernel.gpg add -
sudo apt update && sudo apt install linux-xanmod

After the program has exited, a computer restart is required for the changes to take effect.

Let's check the kernel version again:

uname -a

Output example:

Linux HackWare-Kali 5.13.19-xanmod1 #0~git20210919.7960459 SMP PREEMPT Sun Sep 19 13:46:36 UTC 2021 x86_64 GNU/Linux

If for some reason the GRUB menu has not been updated, then run the command:

sudo update-grub

How to choose the XanMod kernel version

In total, the following metapackages are available – the kernel version at the time of writing is indicated in square brackets:

  • linux-xanmod [5.13]
  • linux-xanmod-edge [5.14]
  • linux-xanmod-lts [5.10]
  • linux-xanmod-cacule [5.14-cacule]
  • linux-xanmod-rt [5.10-rt]

You can check the kernel version in the linux-xanmod package with the following command:

apt show linux-xanmod

As you can see, this metapackage has in its dependencies (that is, it will actually install) the linux-image-5.13.19-xanmod1 and linux-headers-5.13.19-xanmod1 packages, hence the kernel version is currently 5.13.19.

Let's check the linux-xanmod-edge kernel version:

apt show linux-xanmod-edge

The current Linux kernel version in this package is 5.14.6.

The XanMod repository contains not only kernels that can be installed using metapackages, but also many other versions, you can find them with the command:

apt search linux-image-[0-9.]+-xanmod[0-9]+

When installing the kernel of the selected version, you need to install the corresponding headers files, both packages must have the name of the form linux-image-VERSION-xanmod1 and linux-headers-VERSION-xanmod1, and the VERSION number must be the same, for example:

sudo apt install linux-image-5.12.19-xanmod1 linux-headers-5.12.19-xanmod1

How to remove XanMod core

If you installed the kernel using the linux-xanmod metapackage, you can remove this metapackage with the command:

sudo apt remove linux-xanmod

However, this will not change anything, the installed kernels will remain on the system! To remove the kernels themselves, use a command like:

sudo apt remove `sudo apt show linux-xanmod | grep Depends | sed 's/,//' | awk '{print $2,$3}'`

If you installed the kernel without using the metapackage, then remove the kernel and the headers file specifying the names of the packages and their versions, for example:

sudo apt remove linux-image-5.12.19-xanmod1 linux-headers-5.12.19-xanmod1

How to recover Linux after installing the kernel

If your computer boots with a black screen, freezes, or something doesn't work after updating the kernel, reboot and select Advanced options for your distribution from the GRUB menu:

Then select the previous kernel version and press Enter:

Regardless of the reason, you need to boot with the previous version of the kernel if you want to remove the latest kernel. This is because you cannot remove the kernel that is currently in use.

If you do not see the GRUB2 menu, press and hold the Shift key or press the Esc key repeatedly (this may vary depending on BIOS or UEFI boot and the version of Ubuntu/Linux Mint you are using) while booting GRUB. The Grub menu should appear allowing you to select a previous kernel version.

After booting the previous kernel, you can remove the faulty kernel.

To remove the XanMod kernel in Debian and derivatives run the commands:

sudo apt remove linux-xanmod
sudo apt remove `sudo apt show linux-xanmod | grep Depends | sed 's/,//' | awk '{print $2,$3}'`

If this was not done automatically, then update your GRUB settings:

sudo update-grub

How to install a web server (Apache, PHP, MySQL, phpMyAdmin) on Linux Mint, Ubuntu and Debian

If you are a webmaster, or a PHP programmer, or you just need to run a website on your computer, then you can do it using a web server. On Linux, the web server (Apache) and related components (PHP, MySQL, phpMyAdmin) are installed in just a few commands.

This tutorial will show you how to set up a web server for sites on Linux Mint, Ubuntu and Debian.

How to install Apache, PHP, MySQL, phpMyAdmin on Linux Mint, Ubuntu and Debian

We will do most of the operations in the command line - the Linux terminal.

Open a terminal and run the following two commands in it:

sudo apt update
sudo apt install apache2 default-mysql-server php phpmyadmin

Answer No to the configuration prompt with dbconfig-common:

Use the Tab key to move between items and Enter to continue.

Select “apache2”:

Use the Space key to select items, use the Tab key to move between items, and press Enter to continue.

That's all! The web server (a bunch of Apache, PHP, MySQL, phpMyAdmin) is installed and ready to work. Open the link http://localhost/ in your browser

You will see the standard Apache page:

phpMyAdmin is available at http://localhost/phpmyadmin/

To start the web server every time you turn on the computer, run the command:

sudo systemctl enable apache2
sudo systemctl enable mysql

How to change URL path of phpMyAdmin. How to enable and disable phpMyAdmin

If during the installation of phpMyAdmin you chose not to configure it for use with the Apache web server, use the command to enable phpMyAdmin:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/

Restart the web server for the changes to take effect:

sudo systemctl restart apache2

To disable phpMyAdmin use the command:

sudo rm /etc/apache2/conf-enabled/phpmyadmin.conf

Restart the web server for the changes to take effect:

sudo systemctl restart apache2

There is an important line in the /etc/phpmyadmin/apache.conf file:

Alias /phpmyadmin /usr/share/phpmyadmin

Its essence is that the URL /phpmyadmin (for example, http://localhost/phpmyadmin) begins to correspond to the /usr/share/phpmyadmin folder. That is, the phpMyAdmin files (scripts) are physically located in /usr/share/phpmyadmin, and not in the web server directory (for example, /var/www/html/).

Many automatic scanners of “hidden” files and folders of a web server and sites check the “phpmyadmin”, “pma” and other similar directories. You can hide your phpMyAdmin nicely by changing the Alias. For instance:

Alias /lkjgler94345 /usr/share/phpmyadmin

phpMyAdmin will now be available at http://localhost/lkjgler94345 - not easy to find.

phpMyAdmin setup

By default phpMyAdmin does not allow login without password. If you have not set a password for the MySQL DBMS, then you have two options to choose from:

  • set password
  • make changes to phpMyAdmin setting to allow passwordless login

It is recommended to set a password for the database. To change the password, you can use the script:

sudo mysql_secure_installation

If you want to allow logging into phpMyAdmin without a password, then open the file

sudo gedit /etc/phpmyadmin/config.inc.php

Find the second (there are two) line

// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

and uncomment it (remove the two slashes from the beginning of the line) to get:

$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

Most likely, when connecting, you will receive a surprise in the form of the error “#1698 - Access denied for user 'root'@'localhost'”. Step-by-step actions for its solution in this manual.

Where are the sites on the Apache web server?

By default, the root folder for web documents is /var/www/html. In /var/www you can create your own virtual hosts.

The /var/www/html folder and all files inside it belong to the root user.

For you to be able to modify, add, delete files in this folder, you need to use sudo. For example, with the following command, you will open a file manager to manage the contents of a folder.

sudo nemo /var/www/html

All other programs that make changes to /var/www/html must also be run with sudo.

On a local server, for ease of use, you can make yourself the owner of this folder:

sudo chown -R $USER:$USER /var/www/html

Now you and the programs launched on your behalf do not need superuser privileges to work with the contents of this directory:

nemo /var/www/html

Apache index files

If the user requests from the web server not a file, but a directory, then the server looks for files index.html, index.php, index.htm, etc. in it. If these files are in this directory, then their contents are shown. These files are called index files. If there are two or more such files in a directory at once, then one of them is shown in accordance with the set priority.

You can see which files are index files for your server and in what order their priority is arranged in the file

sudo gedit /etc/apache2/mods-enabled/dir.conf

There you will see something like:

<IfModule mod_dir.c>
    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

Typically, users want to move the PHP index file (index.php) to the first position after DirectoryIndex, so that something looks like this:

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

After making changes, save and close the file, restart the web server.

Conclusion

This tutorial showed you how to install Apache web server on your Linux Mint machine. In terms of its functionality, this server does not differ from the capabilities of hosting. You can test your sites on it, use it when learning PHP, install WordPress, etc. Moreover, this server can be made available to the local or even global network.

Chromium will no longer sync passwords - what should Linux users do?

Chrome and Chromium on Linux

Everyone knows the Google Chrome web browser. Chromium is at its core. That is, Chromium is the open source web browser that Google builds on the Chrome web browser, adding proprietary (i.e. closed) code to it.

The Chrome browser is distributed by Google itself as compiled files. The Chromium browser is available as open source. For this reason, Chrome is popular among Windows users - most Windows users install binaries compiled by the authors on their system and do not see anything strange in this.

It's a little different on Linux. Linux users also download and install compiled packages, but compilation is done by the distribution maintainers using the source code of the programs. This is in line with the spirit of Linux and its licenses. Closed source packages are placed in separate repositories (package sources for installation).

For this reason, it is Chromium that is prevalent among Linux users, and Chrome is often absent from the repositories. But until recently, browsers were almost identical, so you could use Chromium just like Chrome.

The Chrome/Chromium web browser makes extensive use of Google's APIs. These APIs include, for example, password and bookmark synchronization. But Google announced that from March 2021, some APIs will be available only in the Chrome web browser, but will be disabled in Chromium, as well as in all third-party browsers that use Chromium as their basis. Disabled APIs include password synchronization.

I don't mind third-party web browsers - just imagine that if you log into your Google account on a third-party browser, thanks to the password synchronization function, it gets access to all (!) your passwords on all (!) websites. Many untrustworthy Chromium-based web browsers have sprung up about the creators of which cannot be found and whose source code is not published (sometimes despite their assurances).

But what's really annoying is that important functions will no longer work in Chromium too. From a full-fledged alternative to Chrome, Chromium has now become a web browser with limited functions.

If you don't use password sync, then you have nothing to worry about

Despite the anger of the maintainers of some distributions and threats to stop supporting or even kick the web browser out of the repositories, apparently no one will do it. Therefore, if you do not need the function of synchronizing passwords and bookmarks, then you can safely continue using Chromium on Linux.

But what about Linux users who use Chromium and need password sync and other features? Let's consider several options.

1. Stop using the password sync feature in web browsers

Yes, the fact that all your passwords are stored by strangers is bad, to put it mildly. But it's super convenient if you have more than one device (computer, phone, tablet, second computer, more virtual computers…). But if you think about it, it's like giving the keys to your apartment to an outsider, so that when you appear, he opens and closes the door to your apartment, and you don't have to climb into your pockets for keys. Conveniently. But you have no idea what happens to your keys while you are away.

Therefore, one option is to continue using Chromium, but stop using the password sync feature.

2. Switch to Firefox

Firefox is open source and also has a password sync feature. If you want to show Google that you are not satisfied with this change, you can switch to Firefox. Just in case - if your passwords are synchronized using Firefox, then it is no better or worse than if they are stored by Google.

3. Install Chrome on Linux

In fact, installing Chrome from Google itself on Linux is trivial. So you can go the same route that most Windows users do - just install a web browser with proprietary code.

In Debian, Linux Mint, Ubuntu, Kali Linux and their derivatives, to install Google Chrome, just run the commands:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i ./google-chrome-stable_current_amd64.deb
sudo apt install -f

That's all! At the same time, during the installation of the web browser, the Google repository will be added to the list of repositories and Chrome will be updated along with the rest of the packages in the system.

In Arch Linux, Manjaro, BlackArch and their derivatives, to install Google Chrome, just run the command:

pikaur -S google-chrome

If you have not yet installed pikaur, then install it according to the instructions “Automatic installation and update of AUR packages”.

To update a web browser package, you will need to run a system update using pikaur - this command is to update both packages from the system repositories and from the AUR:

pikaur -Syu

4. Extensions for synchronization with encryption (Bitwarden)

You can install an extension like Bitwarden and continue using Chromium.

Bitwarden uses end-to-end encryption, meaning passwords are synchronized encrypted. Moreover, the source code is open even for the server, that is, you can synchronize without any third-party participants at all.

Bitwarden works with almost any device and browser you can think of: Windows, Mac, Linux; iOS and Android; Chrome, Firefox, Safari, Edge and many other niche browsers. This gives you freedom of movement, unlike browser password managers.

Conclusion

Which option did you choose or, perhaps, made some other decision?

Error “Cannot load modules/libphp7.so” (SOLVED)

Some Linux distributions have already started migrating to PHP 8. In some distributions the new version of PHP removes the old one, as a result of which the web server may stop working due to the fact that the files specified in the web server configuration are missing or renamed.

Examples of errors you may encounter:

httpd: Syntax error on line 504 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf/mods-enabled/php.conf: Cannot load modules/libphp7.so into server: /etc/httpd/modules/libphp7.so: cannot open shared object file: No such file or directory

It says the file /etc/httpd/modules/libphp7.so was not found.

Another error that says the /etc/httpd/conf/extra/php7_module.conf file was not found:

httpd: Syntax error on line 504 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /etc/httpd/conf/mods-enabled/php.conf: Could not open configuration file /etc/httpd/conf/extra/php7_module.conf: No such file or directory

On some distributions, the Apache web server service is called apache2, and on some httpd. Therefore, this guide will consider both options.

Fix “Cannot load modules/libphp7.so” when webserver service is named httpd (Arch Linux, CentOS and their derivatives)

To view the status of the service and the errors that led to its inoperability, run the command:

systemctl status httpd.service

Open the config file /etc/httpd/conf/mods-enabled/php.conf:

sudo vim /etc/httpd/conf/mods-enabled/php.conf

Find the line in it

LoadModule php7_module modules/libphp7.so

and replace it with:

LoadModule php_module modules/libphp.so

Then find the line

Include conf/extra/php7_module.conf

and replace with:

Include conf/extra/php_module.conf

Restart the web server service:

sudo systemctl restart httpd.service

and check its status:

systemctl status httpd.service

Fix “Cannot load modules/libphp7.so” when webserver service is named apache2 (Debian, Ubuntu, Linux Mint, Kali Linux and their derivatives)

To view the status of the service and the errors that led to its inoperability, run the command:

systemctl status apache2.service

Disable PHP 7.* module:

a2dismod php7.4

Maybe you have a different version of PHP, start typing “a2dismod php” and use the TAB key for autocompletion:

To enable PHP 8 use a command like (use the TAB key for auto-completion):

a2enmod php8

Restart the web server service:

sudo systemctl restart apache2.service

and check its status:

systemctl status apache2.service

How to install VirtualBox Guest Additions in Linux LMDE

LMDE is the Linux Mint Debian Edition, i.e. Linux Mint based on Debian.

VirtualBox Guest Additions are kernel modules (drivers) that are needed if you run Linux LMDE in a VirtualBox virtual machine.

Thanks to guest additions it is possible:

  • enable a shared clipboard between the real operating system and the guest OS
  • enable file drag and drop between host and guest OS
  • expand the guest OS screen to a larger size or use the guest OS in full screen mode, as well as enable display integration.

Guest Additions are not available in the standard Linux LMDE repositories (Linux Mint Debian Edition).

There are two installation options:

  • install Guest Additions from the disk that comes with VirtualBox
  • add a third-party repository

I prefer the first option, so let’s consider it.

Start by fully upgrading and rebooting the system:

sudo apt update && sudo apt full-upgrade -y
reboot

Install the dependencies needed to compile the kernel module:

sudo apt install build-essential module-assistant

Configure the system to build kernel modules:

sudo m-a prepare

Connect the disk with Guest Add-ons, for this, in the VirtualBox menu of the virtual machine, select «Devices» → «Insert Guest Additions CD image»:

Return to the system again and do type in console:

cd /media/*/VBox*
sudo sh VBoxLinuxAdditions.run

Wait for the installation to finish, pay attention that everything goes without errors.

After the installation is complete, reboot again for the changes to take effect:

reboot

In the VirtualBox menu, turn on “Shared Clipboard” and other functions that you need:

Loading...
X