Linux Cockpit Terminal screen illegible

If the Terminal screen on a server’s Cockpit page is illegible, you’ll need to set the site permissions from your client web browser.

Go to the site at http://x.x.x.x:9090, login, click the Terminal option.

Click the lock icon in the address bar.

Click on Connection Not Secure.

Click on More Information.

Click on the Permissions icon.

Under “Extract Canvas Data”, unselect “Use Default” and select “Allow”.

Refresh the page. You may have to change the font size.

Backup Nextcloud

sudo su -
cd /var/www/html/nextcloud/

turn maintenance mode on

sudo -u www-data php occ maintenance:mode --on

run backups

tar -cvpzf /mnt/athena_backups/nextcloud_backup/nextcloud-$(date +"%Y-%m-%d").tar.gz -C /var/www/html/nextcloud/ .

turn maintenance mode off

cd /var/www/html/nextcloud/
sudo -u www-data php occ maintenance:mode --off
OR:
cd /var/www/html/nextcloud/config/
sed -i s/"'maintenance' => true"/"'maintenance' => false"/ config.php

Remove invalid files by inode

This is for when you find files with invalid names that regular ‘rm’ won’t touch, eg.:

387090 drwx------ 3 root root 4.0K Aug 4 17:14 ''$'\033''[?25h'$'\033''[?7h'/

First you need to get the inode, using:

ls -il

this will show the inode at the left.

To remove the file, use the ‘find’ command. First we’ll see what ‘find’ can see:

find . -inum (inode number from before)

You should see just your invalid file. Remove it with:

find . -inum (inode number from before)  -exec rm -rf {} \;

Installing an M.2 HAT+ on a Raspberry Pi 5

Setup a Raspberry Pi 5 system with standard SD card configuration. Use the Raspberry Pi Imager to configure the Pi.

update the raspi:

sudo apt update && sudo apt full-upgrade

and also update the firmware:

sudo rpi-eeprom-update -a

Shut down the Raspberry Pi.

Install and connect the Raspberry Pi Active Cooler.

The M.2 HAT+ should come with at least four short screws and four long screws, along with four threaded standoffs. Attach the standoffs to the Pi so that they are on top of the Pi.

Add the GPIO extender to the Pi’s GPIO pins. Push down on either end, or with a small screwdriver, to get the extender securely attached.

Open the PI’s PCIe connector using your fingernails. Connect the HAT+ ribbon cable to the PCIe connector, and close the connector.

Align the HAT+’s GPIO over the GPIO connector and push down evenly.

Use the short screws to connect the HAT+ to the standoffs.

Install the Raspberry Pi into its case.

Boot the Raspberry Pi using the SD card as your boot device.

Use the Raspberry Pi Imager to install the Raspberry Pi software to the NVME drive.

Run from a command prompt:

sudo raspi-config

Under Advanced Options, go to Boot Order, then choose NVMe/USB boot.

Exit raspi-config, then shutdown. Remove the SD card, and boot the Pi.

conky config for raspberry pi

conky.config ={
— CONKY SETTINGS

background = false,
update_interval = 1,
total_run_times = 0,

cpu_avg_samples = 2,
net_avg_samples = 2,

override_utf8_locale = true,

double_buffer = true,
no_buffers = true,

text_buffer_size = 32768,

— CONKY: WINDOW SPECIFICATIONS
own_window = true,
own_window_argb_value = 192,
own_window_argb_visual = true,
own_window_class = ‘conky-semi’,
own_window_colour = ‘#0b0d18’,
own_window_hints = ‘undecorated,below,sticky,skip_taskbar,skip_pager’,
— own_window_transparent = true,
own_window_transparent = true,
own_window_type = ‘normal’,
— own_window_type = ‘desktop’,
double_buffer = true,

border_inner_margin = 6,
border_width = 5,

minimum_height = 1000,

minimum_width = 280,
maximum_width = 280,

alignment = ‘top_right’,
gap_x = -1910,
gap_y = 40,

— GRAPHICS SETTINGS
draw_shades = false,
draw_outline = true,
draw_borders = false,
draw_graph_borders = true,
— draw_graph_borders = false,

— TEXT SETTINGS
use_xft = true,
font = ‘Montserrat Regular:size=10’,
xftalpha = 0.2,

uppercase = false,

— Pad percentages to this many decimals (0 = no padding)
pad_percents = 2,

— COLOUR SETTINGS
default_color = ‘AAAAAA’,
default_shade_color = ‘333333’,
— default_outline_color = ‘111111’,
default_outline_color = ‘010101’,
color1 = ‘999999’,
color2 = ‘CCCCCC’,
color3 = ‘EEEEEE’,
color4 = ‘444444’,
color5 = ‘555555’,
color6 = ‘666666’,
color7 = ‘3b71a1’,
};

conky.text = [[

${alignc}${font Arial:size=20}${color #0040FF}Raspberry Pi OS ${color #0040FF}
${alignc}${color #0040FF}Hostname: ${color #0040FF}${nodename}
${color6}${hr 2}${color}
${alignc}${color1}${font Montserrat Bold:size=20}${time %H:%M:%S}${font}${color}${alignc}
${voffset -9}
${alignc}${font Montserrat Light:size=10}${time %A %d %B %Y}${font}${alignc}
${color6}${hr 2}${color}
${voffset -6}
${font Arial:bold:size=9}${color #00AAFF}System ${color #0000AA}${hr 2}

${color #00AAFF}${font Montserrat Light:size=9}Hostname:${alignr}$font${color #505050}$nodename
${color #00AAFF}${font Montserrat Light:size=9}Uptime:${alignr}$font${color #505050}$uptime_short
${color #00AAFF}${font Montserrat Light:size=9}Kernel:${alignr}$font${color #505050}$kernel ${voffset 5}
${color #00AAFF}${font Montserrat Light:size=9}Distro:${alignr}$font${color #505050}${exec lsb_release -a 2>/dev/null | grep -i description | cut -s -f2}
${color #00AAFF}${font Montserrat Light:size=9}Frequency:${alignr}$font${color #505050}${freq_g cpu0}Ghz
${color #00AAFF}${font Montserrat Light:size=9}Uptime:${alignr}$font${color #505050}${uptime}
${font Arial:bold:size=9}${color #00AAFF}CPU ${color #0000AA}${hr 2}
${voffset -15}
${font Montserrat Light:size=9}${color1}CPU TEMP:${color}${font} ${font :size=10}${alignr}${hwmon 1 temp 1}°${color4}C${color}${voffset 5}
${voffset -15}
$font${color #505050}CPU1 ${color #AAAAAA}${cpu cpu1}%${color #505050} ${cpubar cpu1}
CPU2 ${color #AAAAAA}${cpu cpu2}%${color #505050} ${cpubar cpu2}
CPU3 ${color #AAAAAA}${cpu cpu3}%${color #505050} ${cpubar cpu3}
CPU4 ${color #AAAAAA}${cpu cpu4}%${color #505050} ${cpubar cpu4}
${voffset -8}
${font Arial:bold:size=9}${color #00AAFF}Network ${color #0000AA}${hr 2}
${voffset -15}
${font Montserrat Light:size=10}${color1}IP ADDRESS:${color}${font} ${alignr}${addr eth0}
${voffset 5}${font Montserrat Light:size=10}${font}Download ${alignr}${downspeedf eth0}k/s (${totaldown eth0})
${color3}${downspeedgraph eth0 50,280 ADFF2F 32CD32 -t}
${font Montserrat Light:size=10}${font}Upload ${alignr}${upspeedf eth0}k/s (${totalup eth0})
${color3}${upspeedgraph eth0 50,280 FF0000 8B0000 -t}
${font Arial:bold:size=9}${color #00AAFF}HDD ${color #0000AA}${hr 2}
${color1}Used: ${color3}${fs_used /}${color1}${goto 175}Free:${goto 225}${color3}${fs_free /}
${color2}${fs_bar /}
${font Montserrat Light:size=8}${color1}DISK I/O:${color}${font} ${alignr}$diskio
${voffset 2}${font Montserrat Light:size=8}${color1}READ: ${color}${font} ${goto 80}${color4}${diskiograph_read 15,210 ADFF2F 32CD32 750}${color}
${voffset 2}${font Montserrat Light:size=8}${color1}WRITE:${color}${font} ${goto 80}${color4}${diskiograph_write 15,210 FF0000 8B0000 750}${color}
${font Arial:bold:size=9}${color #00AAFF}Memory ${color #0000AA}${hr 2}
$font${color DimGray}RAM $alignc $mem / $memmax $alignr ${color 188f18}$memperc%
${color 188f18}$membar${voffset 1}
${font Arial:bold:size=9}${color #00AAFF}Processes ${color #0000AA}${hr 2}
${voffset -15}
${font :size=10}${font Montserrat Light:size=8}${color1}TOTAL:${color}${font} ${alignr}${processes}
${voffset -10}
${font Montserrat Light:size=9}${color1}APP NAME: ${goto 160}MEMORY: ${goto 245}CPU: ${color}${font}
${voffset -16}
${font Montserrat Light:size=9}${color1}${top_mem name 1} ${color}${font} ${goto 160}${top mem 1} % ${goto 235}${top cpu 1} %
${font Montserrat Light:size=9}${color1}${top_mem name 2} ${color}${font} ${goto 160}${top mem 2} % ${goto 235}${top cpu 2} %
${font Montserrat Light:size=9}${color1}${top_mem name 3} ${color}${font} ${goto 160}${top mem 3} % ${goto 235}${top cpu 3} %
${font Montserrat Light:size=9}${color1}${top_mem name 4} ${color}${font} ${goto 160}${top mem 4} % ${goto 235}${top cpu 4} %
${font Montserrat Light:size=9}${color1}${top_mem name 5} ${color}${font} ${goto 160}${top mem 5} % ${goto 235}${top cpu 5} %

]];

Weird folder names in Raspberry Pi file list

raspi occasionally creates weird folders under /root with incomprehensible names:

drwx------ 3 root root 4.0K Jul 7 2022 ''$'\033''[?25h'$'\033''[?7h'/ 

You can’t easily delete the folder with rm -rf.

First, you need to find the inode to the folder:

# ls -ihalF
total 80K
15     drwx------ 11 root root 4.0K Apr 18 10:42 ./
2      drwxr-xr-x 18 root root 4.0K Jul 21 08:34 ../
524545 drwx------ 3 root root 4.0K Jul 7 2022 ''$'\033''[?25h'$'\033''[?7h'/

So in this case the inode is 524545

Use ‘find’ to get rid of it:

find . -maxdepth 1 -type d -inum 524545 -exec rm -rf {} \;

Folder is now deleted

Raspberry Pi top Panel freezes or slows

Some of the widgets/plugins in the Raspi’s top Panel cause system instability. You’ll have to try to get a terminal to open, or else try to ssh in.

You can delete the user’s lxpanel config file, then reboot. This will recreate the default Panel, which you can now break again…

sudo rm -r ~/.config/lxpanel

From here you can either restart the X session with:

startx

or else reboot:

sudo reboot

A new default Panel will be generated.

Raspberry Pi changes Wi-Fi MAC address on boot

This is a new security feature in Network Manager.

Disable the MAC address randomization by creating the file

/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf

with the content:

[connection]
wifi.mac-address-randomization=1

[device]
wifi.scan-rand-mac-address=no

or:

mv /etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf /etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf.bak

echo "[connection]" >/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf

echo "wifi.mac-address-randomization=1" >>/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf

echo -e "\n[device]" >>/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf

echo "wifi.scan-rand-mac-address=no\n" >>/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf

Afterwards you may need to update your device’s MAC in your DHCP server.

Then reboot.

conkyrc for raspberry pi

background yes
use_xft yes
xftfont 123:size=8
xftalpha 0.1
update_interval 0.5
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 250 5
maximum_width 400
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color gray
default_shade_color red
default_outline_color green
alignment top_right
gap_x 10
gap_y 10
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale no
use_spacer right

TEXT

${font Arial:size=20}${color Tan1}Raspberry Pi OS
${color orange}Hostname: ${color}${nodename}

${voffset -90}
${color DimGray}
${font}
${font Arial:bold:size=10}${color Tan1}SYSTEM ${color DarkSlateGray} ${hr 2}
$font${color DimGray}$sysname $kernel $alignr $machine
Frequency $alignr${freq_g cpu0}Ghz
Uptime $alignr${uptime}
File System $alignr${fs_type}

${font Arial:bold:size=10}${color Tan1}CPU ${color DarkSlateGray}${hr 2}
$font${color DimGray}Temp: $alignr ${exec /opt/vc/bin/vcgencmd measure_temp | cut -c6-9} C
$font${color DimGray}CPU1 ${cpu cpu1}% ${cpubar cpu1}
CPU2 ${cpu cpu2}% ${cpubar cpu2}
CPU3 ${cpu cpu3}% ${cpubar cpu3}
CPU4 ${cpu cpu4}% ${cpubar cpu4}
${cpugraph DimGray DarkSlateGray} $color

${font Arial:bold:size=10}${color Tan1}MEMORY ${color DarkSlateGray}${hr 2}
$font${color DimGray}MEM $alignc $mem / $memmax $alignr $memperc%
$membar
$font${color DimGray}SWAP $alignc $swap / $swapmax $alignr $swapperc%
$swapbar

${font Arial:bold:size=10}${color Tan1}HDD ${color DarkSlateGray}${hr 2}
$font${color DimGray}/home $alignc ${fs_used /home} / ${fs_size /home} $alignr ${fs_free_perc /home}%
${fs_bar /home}

${font Arial:bold:size=10}${color Tan1}TOP PROCESSES ${color DarkSlateGray}${hr 2}
${color DimGray}$font${top_mem name 2}${alignr}${top mem 2} %
$font${top_mem name 3}${alignr}${top mem 3} %
$font${top_mem name 4}${alignr}${top mem 4} %
$font${top_mem name 5}${alignr}${top mem 5} %

${font Arial:bold:size=10}${color Tan2}NETWORK ${color DarkSlateGray}${hr 2}
$font${color DimGray}IP on eth0 $alignr ${addr eth0}

Down $alignr ${downspeed eth0} kb/s
Up $alignr ${upspeed eth0} kb/s

Downloaded: $alignr ${totaldown eth0}
Uploaded: $alignr ${totalup eth0}