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 raspberry pi

# 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

Manage USB Power State (Enable Auto-suspend) of DAC

On Linux (including Debian), it is possible to manage USB power states or disconnect a USB device programmatically or automatically after a period of inactivity. Here’s how you can approach this using a Topping D50 III DAC as an example:

The D50 III DAC doesn’t have a sleep mode, so the screen is always on, it could be very useful on audio server configuration to auto-suspend power after a period of inactivity.

List devices attached and identify your DAC:

lsusb
Bus 001 Device 003: ID 152a:8750 Thesycon Systemsoftware & Consulting GmbH D50 III

The device 152a:8750 (Thesycon Systemsoftware & Consulting GmbH D50 III) can be managed using the USB power management options in Linux. Below is a step-by-step guide specific to this device.

ls /sys/bus/usb/devices/
1-0:1.0 1-1:1.0 1-1:1.2 2-0:1.0 4-0:1.0 usb2 usb4
1-1 1-1:1.1 1-1:1.3 3-0:1.0 usb1 usb3
udevadm info -q path -n /dev/bus/usb/001/003
/devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1

Based on the `udevadm` output, the USB device is associated with the path `/devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1`, which maps to the `1-1` directory in `/sys/bus/usb/devices/`. Here’s how to manage power settings for this device:

Step 1: Verify Device Directory

The device directory is /sys/bus/usb/devices/1-1.

  1. Navigate to the directory to confirm it exists:
   cd /sys/bus/usb/devices/1-1
   ls

You should see files like power, idVendor, and idProduct, which indicate it’s the correct USB device.

  1. Confirm the device ID matches 152a:8750:
   cat idVendor
   cat idProduct

Ensure idVendor is 152a and idProduct is 8750.


Step 2: Enable Autosuspend

  1. Check the current power management state:
   cat power/control

If it says on, the device is not suspending.

  1. Enable autosuspend:
   echo 'auto' | sudo tee power/control
  1. Set the autosuspend delay (e.g., 60 seconds):
   echo '60000' | sudo tee power/autosuspend_delay_ms

These settings will allow the device to enter a low-power state after 60 seconds of inactivity.


Step 3: Automate with udev Rules

To make the changes persistent:

  1. Create a udev rules file:
   sudo nano /etc/udev/rules.d/99-usb-autosuspend.rules
  1. Add the following content (in the first line of the file):
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="152a", ATTR{idProduct}=="8750", ATTR{power/control}="auto", ATTR{power/autosuspend_delay_ms}="5000"

# CTRL+X to save

  1. Reload udev rules:
   sudo udevadm control --reload-rules
   sudo udevadm trigger --subsystem-match=usb

Step 4: Disable/Enable the Device Manually

  1. Disable the device:
   echo '0' | sudo tee authorized
  1. Re-enable the device:
   echo '1' | sudo tee authorized

Step 5: Test the Configuration

  1. Monitor power state:
   cat power/runtime_status

You should see suspended when the device is in a low-power state.

  1. Verify the autosuspend delay:
   cat power/autosuspend_delay_ms

Troubleshooting

  • If the device does not suspend, check if it supports USB autosuspend. Some devices might not fully adhere to the USB power management specifications.
  • Review logs for errors:
   dmesg | grep usb

TROUBLESHOOTING: GENERAL


# TS6

# if MPD doesn’t start type this to get its status

  1. $ sudo systemctl status mpd

# if the error is related to /libavcodec.so.58: undefined symbol: bcm_host_is_fkms_active
# reinstall libraspberrypi0 pkg

  1. $ sudo apt install --reinstall libraspberrypi0
  1. $ sudo reboot

# NANO return this error (on Armbian / Debian):

Unable to create directory /root/.local/share/nano/: No such file or directory It is required for saving/loading search history or cursor positions.

# check if nano cmd is available using:

  1. sudo /bin/nano .bashrc

# if nano opens the file then you simply need to create the /root/.local/share/nano/ directories
# you can confirm the issue by using:

  1. sudo ls -l /root/.local/

# UPGRADE or DOWNGRADE YOUR KERNEL


# IMPORTANT:
# All information below is for Raspberry PI platform only, does not apply to other devices


# go to
https://github.com/Hexxeh/rpi-firmware/commits/master

# get the sha1 of the kernel
# for example: 4.19.118-v7 e1050e94821a70b2e4c72b318d6c6c968552e9a2

# then to install this old kernel 4.19.118-v7+ enter:

  1. $ sudo rpi-install e1050e94821a70b2e4c72b318d6c6c968552e9a2
  1. $ sudo reboot

# install pkg ends with error:
# “Failed to start The PHP 7.3 FastCGI Process Manager”
# type the cmd below to create the missing directory:

  1. $ sudo mkdir /var/run/php