MISC: Tips & Tricks


# RANDOM LINUX TIPS & TRICKS


# Get INFO/VERSION

# Raspberry PI model / revision / serial

  1. $ cat /proc/device-tree/model
  1. $ cat /proc/cpuinfo

# SN#:

  1. $ cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2

# 10000000XXXXXXXX


  1. $ cat /proc/asound/version
  1. $ dpkg -l alsa*

# Kernel version

  1. $ uname -a

# fedora update kernel/system

  1. $ dnf -y update && dnf -y upgrade

# For example, to add the user linuxize to the sudo group you would run the following command:

  1. $ sudo usermod -a -G sudo linuxize

# Configure to boot into Raspbian Desktop

  1. $ sudo raspi-config

# use your arrow keys to navigate to Enable Boot to Desktop and press enter. Select the Desktop login option and press enter.

# Configure to boot into Raspbian Desktop (without raspi-config)

  1. $ sudo update-rc.d lightdm disable

# Raspberry testing repository

# replace buster by testing in /etc/apt/sources.list

  1. $ sudo nano /etc/apt/sources.list

# # from
# deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# # to
# deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

  1. $ sudo apt update

# check if process is locked

  1. $ ps aux | grep -i apt

# kill process (replace pid_id by the process ID number)

  1. $ sudo kill pid_id

# check if killed

  1. $ sudo kill -9 pid_id

# Disable DEBIAN 10 GUI:

  1. $ sudo systemctl set-default multi-user.target
  1. $ sudo reboot

To re-enable the GUI:

  1. $ sudo systemctl set-default graphical.target
  1. $ sudo reboot

# activate raspberry pi WIFI

  1. $ sudo raspi-config

# Select “Localisation Options” then select “change WLAN country”

# then enter root

  1. $ sudo su

# generate wpa_passphrase using your SSID and followed by typing the wifi password
# replace YOUR-SSID by the exact name of your wifi network name

  1. $ wpa_passphrase "YOUR-SSID" >> /etc/wpa_supplicant/wpa_supplicant.conf

# check if the configuration is okay

  1. $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

# should contain something like this:
# the country= must contains a 2 letters ISO 3166-1 of your country code

  1. ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  2. update_config=1
  3. country=GB
  4. # reading passphrase from stdin
  5. network={
  6. ssid="YOUR-SSID"
  7. psk=47abc8153891372573fc831a0bab0346b07cb900ada28dc52686359cc60ab9e7
  8. }

# network IP info

  1. $ ifconfig

# scan wifi network

  1. $ sudo iwlist wlan0 scan

# power OFF / ON HDMI

# hdmi OFF

  1. $ sudo /opt/vc/bin/tvservice -o

# hdmi ON

  1. $ sudo /opt/vc/bin/tvservice -p

# AMD64 Useful Cmds

# get hostname

  1. $ hostnamectl

# set hostname

  1. $ sudo hostnamectl set-hostname musiclounge
  1. $ sudo nano /etc/hosts

127.0.0.1 localhost
127.0.1.1 musiclounge

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

  1. $ sudo reboot

# Check your current Ethernet connection speed

# install ethtool utility

  1. $ sudo apt-get install ethtool

# determine the name of your ethernet interface usually eth0 or enp3s0

  1. $ ip a

# get the speed

  1. $ sudo ethtool eth0 | grep -i speed

# get current playback info useful to check if current playback is DSD native (DSD_U32_BE)

  1. $ cat /proc/asound/card*/pcm*p/sub*/hw_params

# in case you have to entry commands from the server console and not from remote PC/SSH session
# you may want to change the keyboard layout
# use the followinf cmd on debian

  1. sudo dpkg-reconfigure keyboard-configuration

TROUBLESHOOTING: Raspberry PI 3B+


# IMPORTANT FOR RASPBERRY PI OWNERS:
# It’s strongly recommended to create your audio server on Raspberry PI 4 2Go
# The raspberry pi 3 share the same controller with USB and Ethernet which is not good for an audiophile server
# do not expect to use native DSD with RPI 3 using an usb dac…


# ALL INFORMATION BELOW ARE FOR RPI 3B + ONLY, does not apply to other devices


# Apply patch one by one in this order, reboot and check before


# TS1

# APPLY IF NEEDED ONLY (sound drop/loss)

# Ethernet drops Fix (Recommended for Raspberry PI 3B+ only do not apply to RPI 4)
# identify the name of your Ethernet connection (usually eth0 or enp3s0)

  1. $ ip a

# edit rc.local to run a cmd at startup

  1. $ sudo nano /etc/rc.local

# enter this cmd below to optimize your ethernet connection
# see the Tips & Tricks section to install ethtool (sudo apt-get install ethtool) if needed
# add this line at end of rc.local

  1. $ sudo ethtool -s eth0 speed 100 duplex full

# CTRL+O to save
# CTRL+X to exit

  1. $ sudo reboot

# TS2

# APPLY IF NEEDED ONLY

# optimize perf for Raspberry PI 3B+ – cpu gouvernor (not recommended for PI4)

# check cpu governor

  1. $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# set to “performance” at startup

  1. $ sudo mv /etc/init.d/raspi-config /etc/init.d/raspi-config.bak
  1. $ sudo nano /etc/init.d/raspi-config

# copy/paste this script

#!/bin/sh
### BEGIN INIT INFO
# Provides: raspi-config
# Required-Start: udev mountkernfs $remote_fs
# Required-Stop:
# Default-Start: S 2 3 4 5
# Default-Stop:
# Short-Description: Switch to performance/ondemand cpu governor based on shift key pressed.
# Description:
### END INIT INFO
 
# . /lib/lsb/init-functions
 
case "$1" in
start)
log_daemon_msg "Checking if shift key is held down..."
SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
if [ -x /usr/sbin/thd ] && timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT"; then
printf "Yes. Switching to ondemand scaling governor."
if [ -e $SYS_CPUFREQ_GOVERNOR ]; then
echo "ondemand" > $SYS_CPUFREQ_GOVERNOR
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo 100000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
fi
log_end_msg 0
else
printf "No. Switching to performance scaling governor."
if [ -e $SYS_CPUFREQ_GOVERNOR ]; then
echo "performance" > $SYS_CPUFREQ_GOVERNOR
fi
log_end_msg 0
fi
;;
stop)
;;
restart)
;;
force-reload)
;;
*)
echo "Usage: $0 start" >&2
exit 3
;;
esac

# CTRL+O to save
# CTRL+X to exit

# set permission to exec

  1. $ sudo chmod 755 /etc/init.d/raspi-config
  1. $ sudo reboot

# type to check:

  1. $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# result must be:

# performance


# TS3

# APPLY IF NEEDED ONLY

# USB dropped frames Fix (not recommended for PI 4)

  1. $ sudo nano /etc/rc.local

# # USB fix

  1. $ sudo sed -i "s/console=serial0,115200/net.ifnames=0 dwc_otg.fiq_enable=1 dwc_otg.fiq_fsm_enable=1 dwc_otg.fiq_fsm_mask=0xF dwc_otg.nak_holdoff=1 console=serial0,115200/" /boot/cmdline.txt

# # revert value

  1. $ sudo sed -i "s/net.ifnames=0 dwc_otg.fiq_enable=1 dwc_otg.fiq_fsm_enable=1 dwc_otg.fiq_fsm_mask=0xF dwc_otg.nak_holdoff=1 //" /boot/cmdline.txt

# CTRL+O to save
# CTRL+X to exit

  1. $ sudo reboot