Category: Computers

Terminator Workspace-in-a-box

This is related to Tmux workspace-in-a-box in my general effort to be productive with a bunch of linux terminals open at once

Preamble bitching nonsense

When things are all the same color, I work slower, if I get any work done at all. I noticed this in college taking a course in structural design. It was the kind of class that took up a three ring binder. Of course it wasn’t all notes, it had at least a hundred pages of the American Institute of Steel Construction. In that monster of a notebook I could not find a goddamn thing! That is, until I got a bunch of different colored pens, highlighters, flags, etc.


Same thing with computers, I stare at a bunch of black terminals and its just all runs together I can’t do shit. In fact, it even seems like every game now has the same stupid fucking flat black and white menus. Certainly true for Halo Infinite, MechWarrior 5, and HBS Battletech.

replace this with a new one
screenshot of halo settings menu
replace this with a new one
screenshot of mechwarrior 5 settings menu
replace this with a new one
screen shot of battletech settings menu

Identify which is which, I dare you.

Terminator

No, not ahhhhnold. Not even grizled, gray haired ahhhhnold. I can’t say terminator is the best gui terminal emulator, but I use it because I can easily make it different colors. It also has a nice human readable config file, as god intended. You don’t have to edit it by hand, but for some reason the gui is slow when I edit the colors and I don’t care to find out why.

screenshot of basic black terminator window showing profile selection and my custom profiles

I try to use the same color terminal for the same remote host when I am working on a bunch of them at the same time. Here are some examples:

WWW

There is not much for the blue - www profile the config file ~/.config/terminator/config really just the background color.

[profiles]
  [[blue - www]]
    background_color = "#001654"
    background_darkness = 0.8
    cursor_color = "#ffffff"
    font = Monospace 10
    foreground_color = "#ffffff"
    show_titlebar = False
    scrollbar_position = hidden
    use_system_font = False
screenshot of terminator, dark blue for www

Nextcloud

Despite my proclivities for dark computer screens, I need more color choices so here is a light blue one. I had to change the color palette since the color schemes that come with terminator don’t work on light backgrounds. It is by no means complete, maybe I will actually come back and update this later accordingly.

[[lt blue - sky]]
background_color = "#62a0ea"
cursor_color = "#aaaaaa"
font = Monospace 10
foreground_color = "#000000"
show_titlebar = False
scrollbar_position = hidden
palette = "#000000:#aa0000:#00aa00:#aa5500:#0000aa:#aa00aa:#005b5b:#aaaaaa:#555555:#ff5555:#55ff55:#ffff55:#5555ff:#ff55ff:#55ffff:#ffffff"
use_system_font = False
screenshot of terminator, light blue for nextcloud

Tmux Workspace-in-a-Box

The idea here is when I work on a system, I want to open tmux and have it automatically open all the windows I always open. This will save me manually doing all that, and give me consistency of what window is where so I can build muscle memory and quit flapping around looking for the right window.

For reasons beyond my comprehension, instead of just issuing the usual tmux, you actually need to tmux attach. I guess that is a good thing regardless, as if the main tmux session is already open I would just want to reconnect.

Anyway, here are some tmux.conf examples:

WWW

Here is an apache web server, called www.

mr@www:~$ cat .tmux.conf 
new -s www -c	/etc/apache2		#create new session for www
rename-window	/etc/apache2/		#rename first window
new-window -c	/var/log/apache2/	#make a second window
rename-window	/var/log/apache2/	#rename second window
new-window -c	/var/www/rushworx.net/	
rename-window	rushworx.net

mr@www:~$ tmux attach

screenshot of dark blue terminator terminal for www

shows tmux with three windows /etc/apache2/, /var/log/apache2/, and /var/www/rushworx.net/

Nextcloud

A nextcloud server

mr@nextcloud:~$ cat .tmux.conf 
new -s nextcloud -c /home/nextcloud_data #create new session for nextcloud
rename-window   /home/nextcloud_data/   #rename first window
new-window -c   /var/log/               #make a second window
rename-window   /var/log/               #rename second window
new-window -c   /home/mr/
rename-window   /home/mr/
  
screenshot of light blue terminator window for nextcloud

shows tmux with three windows for /home/nextcloud_data/, /var/log, and /home/mr

Sources

This github gist helped me figure out some of the odd tmux config usage
https://gist.github.com/Muzietto/325344c2b1b3b723985a85800cafef4f

, , ,
[Top]

PHP file upload limit

the venerable php hammer. 

a hammer with two claws
the php hammer

For some reason the defaults in php will remain tiny forever and ever, amen. So you always gotta do this if you want to upload a pic or clip larger than the default upload_max_filesize of 2MB:

root@www:~# cat /etc/php/8.2/fpm/php.ini  |egrep "upload_max|post_max"
post_max_size = 400M
upload_max_filesize = 200M
root@www:~# systemctl restart php8.2-fpm.service

, ,
[Top]

Mitigate Denial of Service on Apache with mod_evasive

The original Apache logo
The original Apache logo

Mitigating attacks within the web server itself appears tidy and convenient but there are limits to what can be accomplished without incurring excessive load in the process. Let’s set up mod_evasive for that purpose however it can also be integrated with firewalls and routers.

apt-get install apache2-utils
apt-get install libapache2-mod-evasive

Check that the module is loaded:

root@www:~# apache2ctl -M |grep evasive
 evasive20_module (shared)

And the config file:


nano /etc/apache2/mods-enabled/evasive.conf

GNU nano 7.2                             /etc/apache2/mods-enabled/evasive.conf                                      <IfModule mod_evasive20.c>
    DOSHashTableSize    3097
    DOSPageCount        2
    DOSSiteCount        50
    DOSPageInterval     1
    DOSSiteInterval     1
    DOSBlockingPeriod   10

    #DOSEmailNotify      [email protected]
    #DOSSystemCommand    "su - someuser -c '/sbin/... %s ...'"
    DOSLogDir           "/var/log/apache2/mod_evasive"
</IfModule>

This is the default config per the github but I think it might be older than dirt so expect to change it! Also I am definitely not sending email. DOSSystemCommand is how you are going to integrate with external edge devices to block there rather than on the web server itself. I am putting my log in the debian apache dir. You could use that to hit an API at your web host to add IPs to their anti DDoS system. Or, probably could use it to hit CloudFlare’s API or similar external service.

, ,
[Top]

Quickly change sound device in Windows with SoundSwitch

I should have done this a long time ago. Swapping between speakers and headset in windows sucks ass. Somebody solved that problem with a thing called SoundSwitch that lives in your system tray and lets you do it with a press of a button or even a goddamn hot key. Sick.

https://soundswitch.aaflalo.me

screen shot of soundswitch system tray app
screen shot of soundswitch system tray app
soundswitch settings
[Top]

WordPress Caching with W3 Total Cache and memcached

There is much on this topic, this is just one solution.

W3 Total Cache is a well known performance plugin for WordPress, and it can use memcached.

memcached should already be listening on loopback, not on a public ip!, on a tcp socket:

root@www:~# netstat -lnp --tcp |head -3
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      681/memcached

Going to need the php extension to connect to the memcached server:

apt install php8.2-memcached

After which, the main things in W3TC we are looking for are object cache (php), page cache, and database cache and all three are working so we are all set.

[Top]

Apache MPM Event with PHP-FPM on Debian 12

Apache by default comes with an old crusty style of doing things which includes MPM prefork and mod_php. I am going to instead use the threaded event multi-processing module.


apachectl -M | grep 'mpm'

root@www:~#  apachectl -M | grep 'mpm'
mpm_prefork_module (shared)


root@www:~# a2query -m |grep php
php8.2 (enabled by maintainer script)

a2dismod php8.2
a2dismod mpm_prefork
a2enmod mpm_event

apt install php-fpm

Creating config file /etc/php/8.2/fpm/php.ini with new version
NOTICE: Not enabling PHP 8.2 FPM by default.
NOTICE: To enable PHP 8.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php8.2-fpm.service → /lib/systemd/system/php8.2-fpm.service.
Setting up php-fpm (2:8.2+93) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for php8.2-fpm (8.2.20-1~deb12u1) ...
NOTICE: Not enabling PHP 8.2 FPM by default.
NOTICE: To enable PHP 8.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.


apt install libapache2-mod-fcgid
Uses unix socket.
		
a2enconf php8.2-fpm		
a2enmod proxy
a2enmod proxy_fcgi

apachectl configtest
Syntax OK

systemctl restart apache2

apachectl -M | grep 'mpm'
mpm_event_module (shared)
 
[Top]

Automatically update wp cli

wp cli is a command line tool to do lots of wordpress operations..

Here is a cron job to automaticall update wp cli every hour on the hour:

0 */1 * * * wp cli update --yes

[Top]

Nvidia Control Panel Won’t Open

Had an annoying issue today. For MechWarrior Online, I use Nvidia Control Panel to span my three monitors into one virtual one. Well today I wanted to turn that off and I couldn’t open the damn thing.

Updating the driver through Geforce experience did not resolve it. I had to uninstall the driver within Device Manager and let Windows automatically get it again and that reset the displays back to default and also actually solved the inability to launch the Nvidia Control Panel.

[Top]

Persistent Server VNC

I have a home server I call a NAS but it also does some other stuff. Occasionally I find the need to do some GUI things, and I don’t want to be bothered with a physical keyboard and mouse as that’s quite inconvenient due to the physical setup. I require use of the real graphics card for this, so, using virtual desktops is not an option, so to that end I will use x11vnc since it shares existing X displays.

I suppose there is a more elegant solution to this problem but this is fine for me. I am running Debian 10, with the LXDE desktop environment. Bog standard Debian desktop install.

I’m going to make lightdm log me in my non-root user automatically:

root@nas:~# nano /etc/lightdm/lightdm.conf

Add your user under Seat:*

[Seat:*]
autologin-user= MadRush

~/.xsessionrc runs stuff as soon as you are logged in to X. It’s a perfect spot to make x11vnc start up:

MadRush@nas:~$ cat .xsessionrc 
/usr/bin/x11vnc -forever -display :0 -auth guess -rfbauth /home/MadRush/.vnc/passwd & disown

Okay so next time you log in, x11vnc will be started. And -forever means it will stay open after you disconnect. Going forward lightdm will automatically log you in, et voila, there’s your persistent x11vnc session. Restart lightdm:

root@nas:~# systemctl restart lightdm

Good to go! Now I can log in at the physical console if I want, and then pick up where I left off should I want to use VNC instead.

[Top]