# Linux # Bandwidth monitoring #### Useful console programs - bwm-ng - Bandwidth Monitor NG (Next Generation), a live bandwidth monitor for network and disk io - iftop - display bandwidth usage on an interface by host - nethogs - Net top tool grouping bandwidth per process - nload - displays the current network usage To install them all: ```shell sudo apt install bwm-ng iftop nethogs nload ``` #### Useful gui programs - [nutty](https://babluboy.github.io/nutty/) # SSH load key error in libcrypto Occasionally on Ubuntu 22.04 I've experienced the error message shown below when trying to connect to a server using an ssh key: ``` $ ssh user@server.com -i ~/.ssh/id_ed25519 Load key "id_ed25519": error in libcrypto ``` I finally realized the problem was the presence of DOS style CRLF end of line designators. Using dos2unix to convert the end of line designators resolved the issue. ``` $ dos2unix ~/.ssh/id_ed25519 ``` \#end # Useful system commands Hardware related Memory ``` # Show maximum capacity and number of RAM slots sudo dmidecode -t 16 # Show information on RAM in slots sudo dmidecode -t 17 # Shows all memory related information in the system. Slow as it polls all hardware first. sudo lshw -class memory ``` # VBAN for Linux [https://github.com/quiniouben/vban](https://github.com/quiniouben/vban) I've used Voicemeeter Banana and Potato for a long time to do advanced audio management on my various computers, including streaming audio from various computers in the house to my laptop and vice versa. VBAN for Linux allows me to incorporate some older laptops (that have trouble running Windows but no problem running Ubuntu Desktop) into my various setups. Primarily I use a second laptop to stream Youtube or Udemy videos while I'm using my primary Windows laptop. Bluetooth headset is connected to the primary laptop and all other audio sources are sinked to it. 👍 #### Configuring Ubuntu 20.04 to sink audio and use vban\_emitter to stream to a VBAN receiver ##### Preparing Pulseaudio ``` #!/bin/bash pactl load-module module-null-sink sink_name=vbanmix # use "pactl info" or "pactl list" to find the proper alsa_output interface pactl load-module module-combine-sink channels=2 slaves=vbanmix,alsa_output.pci-0000_00_1b.0.analog-stereo pactl set-default-source vbanmix.monitor ``` ##### Running vban\_emitter ``` #!/bin/bash IPADDR=10.10.10.10 UDPPORT=6980 STREAMNAME=Linux_Laptop SAMPLERATE=48000 AUDIOBACKEND=pulseaudio vban_emitter --ipaddress=$IPADDR --port=$UDPPORT --streamname=$STREAMNAME --backend=$AUDIOBACKEND --rate=$SAMPLERATE ``` #### Running on a headless system After banging my head against the wall for weeks trying to figure out how to get vban\_emitter working on a Raspberry Pi and an f80a, here's what I found. By default, Pulseaudio only works with a user logged in directly to the system. After trying to get Pulseaudio setup to run in system mode, I realized it's much easier to just leverage ALSA directly. The default ALSA configuration is set to use CARD 0. When using USB devices, these are inserted as CARD 1. In order to use this, you need to either update or create the /etc/asound.conf file with the information below: ``` # /etc/asound.conf defaults.pcm.card 1 defaults.ctl.card 1 ``` Here's the vban\_emitter command to use: ``` vban_emitter -i IP_ADDRESS -p 6789 -s STREAM_NAME -b alsa ``` -end # Wayland While trying out Ubuntu 23.04 via Ubuntu Sway Remix 23.04, I've noticed a lot of issues with blurry programs. After doing some research, I've found that this is due to applications using the X11 protocols to access the display via Xwayland instead of using the native Wayland protocols. I didn't have this issue running Ubuntu Sway Remix 22.04, so I'm very curious what has changed. I'm starting to document what I'm learning hear and adding links. ## Resources - [Running programs natively under Wayland](https://github.com/swaywm/sway/wiki/Running-programs-natively-under-wayland) - from the swaywm project - [Environment variables for Wayland hackers](https://discourse.ubuntu.com/t/environment-variables-for-wayland-hackers/12750) - Canonical forum post ## Individual applications ### Flatpak ### VS Code Adding "--enable-features=UseOzonePlatform --ozone-platform=wayland" to the code launcher fixes the issue. I updated all of the /usr/share/applications/code\*.desktop files appropriately. # Sway ## Ubuntu Sway Remix Recording changes I make to the default configuration in Ubuntu Sway Remix ### brightness control ```bash # from /etc/sway/variables # brightness control - very fine grained control set $brightness_step bash -c 'echo $(( $(light -Mr) / 100 * 1 < 100 ? 50 : $(( $(light -Mr) / 100 * 2 )) ))' set $brightness_up light -r -A $($brightness_step) && $onscreen_bar $(light -G | cut -d'.' -f1) set $brightness_down light -r -U $($brightness_step) && $onscreen_bar $(light -G | cut -d'.' -f1) ``` ### idle configuration Set $idle\_timeout to 300, $locking\_timeout to 3600, and $screen\_timeout to 600. Update the timeout $idle\_timeout action to set the idle light level to 1 instead of 10. ```bash ### Idle configuration # This will lock your screen after 300 seconds of inactivity, then turn off # your displays after another 300 seconds, and turn your screens back on when # resumed. It will also lock your screen before your computer goes to sleep. # set $lock ~/.config/swaylock/lock.sh set $idle_timeout 300 set $locking_timeout 3600 set $screen_timeout 600 set $idle swayidle -w \ timeout $idle_timeout 'light -G > /tmp/brightness && light -S 1' resume 'light -S $([ -f /tmp/brightness ] && cat /tmp/brightness || echo 100%)' \ timeout $locking_timeout $lock \ timeout $screen_timeout 'swaymsg "output * dpms off"' \ resume 'swaymsg "output * dpms on"' \ before-sleep 'playerctl pause' \ before-sleep $lock & \ lock $lock & ``` ### power alert Add the following to ~/.config/mako/config and then reload sway: ```ini [app-name="poweralertd"] invisible=1 ``` \#end # Ubuntu console-setup for setting console font By default, on a Surface laptop running Ubuntu Sway Remix, the console font is waaay too small for my aging eyes, so I set off to learn how to change it. ``` sudo dpkg-reconfigure console-setup ``` - UTF-8 - Guess optimal character set - Do not change the boot/kernel font Results in the following /etc/default/console-setup contents: ``` ACTIVE_CONSOLES="/dev/tty[1-6]" CHARMAP="UTF-8" CODESET="guess" FONTFACE="" FONTSIZE="" VIDEOMODE= ``` \#end # Ubuntu desktop launchers [Recognized desktop entry keys](https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html) #### Mikrotik The Dude The Dude runs well under Wine. Running the installer will generate all needed desktop launchers. #### Mikrotik Winbox ~/.local/share/applications/winbox.desktop ``` [Desktop Entry] Name=Winbox Path=~/bin Exec=wine-stable winbox.exe Type=Application StartupNotify=true Keywords=winbox; ``` /usr/share/applications/winbox.desktop ``` # Make sure winbox.exe has been saved to /usr/local/bin/winbox.exe [Desktop Entry] Name=Winbox #Path=/usr/local/bin Exec=wine-stable winbox.exe Type=Application StartupNotify=true Keywords=winbox; ``` \#end # ImageMagick Use [ImageMagick](https://imagemagick.org/) to create, edit, compose, and convert digital images. Resize an image, crop it, change its shades and colors, add captions, and more. ### Resizing files in a directory ```shell nice -n 19 mogrify -path . -filter Triangle -define filter:support=2 -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip *.jpg ``` \[[Source](https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/)\] \#end