Remove specific mails from postfix queue with jq

In this example, all emails whose sender is a@bc.com are deleted from the queue.

postqueue -j | jq -r ‘select(.sender == “a@bc.com”) | .queue_id’ | xargs -I {} postsuper -d {}

jq must be installed ( apt install jq )

for other filtering criteria

postqueue -j | jq

You can type and see the fields in the json output.

Phalcon Php Framework 3.x Installation

Phalcon 3.x (old version) installation steps on Cyber Panel + Ubuntu 20 server

1.Install the pecl and pear plugins for the php version you want.

apt install lsphp72-pecl lsphp72-pear

 

2. Download Phalcon 3.4.5 tar file.

wget https://github.com/phalcon/cphalcon/archive/refs/tags/v3.4.5.tar.gz

tar zxvf v3.4.5.tar.gz

cd cphalcon-3.4.5/build/

./install

 

3.If all steps are successful, add the ini file

Create phalcon.ini file under /usr/local/lsws/lsphp72/etc/php/7.2/mods-available. Restart openlitespeed.

cat phalcon.ini

#extension=psr.so #Required for v4 and later.
extension=phalcon.so

 

 

Note: Similarly, you can install Phalcon v4, but it requires psr plugin. For this;

cd /usr/local/lsws/lsphp72/bin

./pecl install psr-1.1.0

 

 

Centos /Cloudlinux 7 error restarting a systemd service

Unable to register authentication agent

** (pkttyagent:478736): WARNING **: 18:16:34.777: Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject Error registering authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject (polkit-error-quark, 0)

# groupadd -g 23 nohidproc
# usermod -a -G nohidproc polkitd
# mount -o remount,rw,hidepid=2,gid=nohidproc /proc
# systemctl restart polkit

 

 

nano /etc/fstab
# comment the following line :
from : proc /proc proc defaults,hidepid=2 0 0
to : # proc /proc proc defaults,hidepid=2 0 0
# add the following line
proc /proc proc defaults,hidepid=2,gid=nohidproc 0 0

Add MX Record with Custom Priority for Plesk

/sbin/plesk bin dns -a abc.com -mx "" -mailexchanger mail.abc.com -priority 1

List access or error log files with their sizes plesk hosting servers

List all access log files;

find /var/www/vhosts/*/logs/error_log -exec ls -la {} \; | awk '{print $5 " " $9}' | sort -n

List all error log files;

find /var/www/vhosts/*/logs/access_log -exec ls -la {} \; | awk '{print $5 " " $9}' | sort -n

For access logs,there are also other access log files in that directory.For example,access_ssl_log,access_ssl_log.processed and more.So to list all files that starts with access,use wildcards like;

find /var/www/vhosts/*/logs/access* -exec ls -la {} \; | awk '{print $5 " " $9}' | sort -n

Unable to change hosting php version in php selector for Cloudlinux

In this case,problem is file permissions for php.ini file related that you want to switch php version.

Login to shell and change the group owner of related file.Sample command is for php 7.4

chgrp linksafe /opt/alt/php74/etc/php.ini

Change compression type for Plesk backups

As a new feature,Plesk picked up zstd compression method for backups.If you want to create backup files with classic method you can edit the panel.ini file in two way

1. Go to Extensions ->Install and activate panel editor extension and open the editor in my extensions section

Select the editor and add these;

[pmm]
compressionMethod = deflate

2.Login to shell.Open /usr/local/psa/admin/conf/panel.ini file with your favorite editor like nano or vi.Add theses line to the appropriate place

[pmm]
compressionMethod = deflate

Note.You may already see [pmm] section.In this case you just add compressionMethod = deflate

below the [pmm] section.

Most Used Linux Commands For File Compression

Gzip

Compress a file with gzip

$ gzip filename

Compress and keep the original file

$ gzip -c file > file.gz

Compress all files in a folder

$ gzip -r foldername

Tar.gz

$ tar -czvf filename.tar.gz directory

ZSTD Compression

Install first the package,

$ sudo apt install zstd (Debian/Ubuntu)

$ dnf install zstd (Centos,AlmaLinux,Fedora,Redhat)

Usage:

to compress a file :

zstd example.txt

Using with tar:

tar --zstd example.tar.zst example/

ZSTD Uncompression

tar --use-compress-program=unzstd -xvf archive.tar.zst

 

PwnKit Local Privilege Escalation Vulnerability polkit’s pkexec (CVE-2021-4034)

A memory corruption vulnerability (CVE-2021-4034) in PolKit, a component used in major Linux distributions and some Unix-like operating systems, can be easily exploited by local unprivileged users to gain full root privileges.

https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034

Patch for Ubuntu is Available

https://ubuntu.com/security/notices/USN-5252-1

If you don’t have any patch please remove suid bit from pxexec tool with this command

chmod 0755 /usr/bin/pkexec