Cannot load Zend OPcache – it was already loaded

Started getting the following error while running ./validate.php for LibreNMS

Cannot load Zend OPcache - it was already loaded

Looks like the problem arises out of PHP trying to load two ini files for OPcache. Was trying to enable OPcache for LibreNMS so I created an opcache.ini file and put the settings in it. I missed the default 10-opcache.ini file.

Moving all the settings into the 10-opcache.ini file and deleting the created opcache.ini file resolved the issue for me.

https://unix.stackexchange.com/questions/253448/php-7-install-throws-cannot-load-zend-opcache-it-was-already-loaded-error/253484

Configure UFW Firewall on Ubuntu

UFW Firewall Status

Below are some simple commands around working with UFW. UFW is included in Ubuntu. However it may need to be enable.

Show status

sudo ufw status

Disable UFW Service

sudo systemctl stop ufw && sudo systemctl disable ufw

Stop UFW Service

sudo systemctl stop ufw

Start UFW service

sudo systemctl stop ufw

Enable UFW

sudo ufw enable

Allow SSH

sudo ufw allow 22/tcp

Show status

sudo ufw status numbered

Example output

sudo ufw status numbered
Status: active
To            Action   From 
--            ------   ----
[1] 3478/udp  ALLOW IN  Anywhere
[2] 5514/udp  ALLOW IN  Anywhere
[3] 8080/tcp  ALLOW IN  Anywhere
[4] 8443/tcp  ALLOW IN  Anywhere
[5] 8880/tcp  ALLOW IN  Anywhere
[6] 8843/tcp  ALLOW IN  Anywhere
[7] 6789/tcp  ALLOW IN  Anywhere
[8] 27117/tcp ALLOW IN  Anywhere
[9] 22/tcp    ALLOW IN  Anywhere

Delete rule

You need to know the number of the rule you want to delete. Replace number with the number of the rule from the status command

sudo ufw delete number

Reset rules

sudo ufw reset

Allow access to port from specific IP address

Example command allows access to SSH (port 22) from the 172.16.0.0/12 ip range.

sudo ufw allow proto tcp from 172.16.0.0/12 to any port 22

One note: It appears that you need to run the rule with every IP range you want to allow.

Allow access to port from all private IP ranges (RFC 1918)

If we wanted to allow SSH (port 22) from all local IP addresses, we would need to run the following three commands.

sudo ufw allow proto tcp from 10.0.0.0/8 to any port 22
sudo ufw allow proto tcp from 172.16.0.0/12 to any port 22
sudo ufw allow proto tcp from 192.168.0.0/16 to any port 22

The following link has more information regarding UFW firewall and subnets.
https://www.cyberciti.biz/faq/ufw-allow-incoming-ssh-connections-from-a-specific-ip-address-subnet-on-ubuntu-debian/

Mount disk by UUID in Linux

Find UUID

blkid

Example output

/dev/xvdb1: UUID="42fbe9a1-eea1-34bc-439d-19a0b48e7df1" TYPE="xfs"

Mount drive using the UUID

[root@host ~]# mount -U 42fbe9a1-eea1-34bc-439d-19a0b48e7df1 /mnt

Add to fstab to automatically mount on system boot up

vi /etc/fstab

Add the following, swap out the UUID for your devices UUID

UUID="42fbe9a1-eea1-34bc-439d-19a0b48e7df1" /backup xfs defaults 0 0

Save and exit. Now when the system reboots it should automatically mount the drive. You should also be able to call “mount -a” to automatically mount everything in fstab.

Linux Screen – Create, Connect, Disconnect, Terminate Sessions

Screen is a handy tool that can help you run scripts on servers remotely without having to worry about the session getting terminated. It seems to operate kinda like a virtual console.

Create Screen Session

Create a new session with a specified name

screen -S SessionName

Example output below. Create session named testsession and print screen sessions.

[bob@localhost imapsync]$ screen -S testsession
[bob@localhost imapsync]$ screen -ls
There are screens on:
3313.testsession (Attached)
1 Sockets in /var/run/screen/S-bob.
[bob@localhost imapsync]$

Disconnect from Screen Session

You can disconnect from a screen session by hitting ctrl + a and then ctrl +d

“ctrl + a” then “ctrl + d”

List Screen Sessions

You can list the screen sessions with

screen -ls

Example

[bob@localhost imapsync]$ screen -ls
There are screens on:
3212.testsession (Detached)
2556.xap (Detached)

2 Sockets in /var/run/screen/S-bob.
[bob@localhost imapsync]$

Connect to screen Session

You can reconnect to a screen session with

screen -r testsession 

Terminate Screen Session

To terminate a screen session, connect to that session and then on a clear line hit ctrl + d

Same way as if you were closing a remote ssh connection.

Firefox performance improvements for Linux

Bunch of tweaks and enhancements are on the arch wiki

https://wiki.archlinux.org/index.php/Firefox/Tweaks

Two specific ones that can help with performance are enabling OMTC and WebRender

https://wiki.archlinux.org/index.php/Firefox/Tweaks#Enable_OpenGL_Off-Main-Thread_Compositing_(OMTC)

Open up Firefox and about:config

Search for “layers.acceleration.force-enabled”

Enable layers.acceleration.force-enabled

Search for “gfx.webrender.all” and set to true

Enable gfx.webrender.all

Restart Firefox.

Reset NextCloud admin password – Snap package

The regular command to reset the password for a NextCloud user does not work when NextCloud is installed from a snap package.

$ sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin
Could not open input file: /var/www/nextcloud/occ

The reason is that NextCloud is located in “/snap/nextcloud”

Unfortunately the occ file is not located in /snap/nextcloud/current/

However, you can run the nextcloud.occ command directly without specifying the path. Change admin to your user.

sudo nextcloud.occ user:resetpassword admin

Type in the new password twice and login.

Alienware fan control in Linux notes

Helpful links

https://wiki.archlinux.org/index.php/Fan_Speed_Control#Dell_laptops
https://bbs.archlinux.org/viewtopic.php?id=248106
https://www.reddit.com/r/Dell/comments/9pdgid/configuring_the_xps_to_play_nice_with_linux

You can use the following commands to “initilize” the fans so the fancontrol can read them.

 sudo modprobe dell-smm-hwmon ignore_dmi=1
sudo sensors-detect

After that is done you should be able to setup a fancontrol config with

sudo pwmconfig

After it is set up you can launch fancontrol to control the fans

sudo fancontrol

If you want to tweak the setting, modify the fancontrol config under

/etc/fancontrol

or run pwmconfig again and replace config.

Sounds like you should be able to add the following to “etc/modprobe.d/dell.conf” to get it to run on boot.

options dell-smm-hwmon ignore_dmi=1