Table of Contents
Linux
Preferences
Titlebar-Icons
gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
Terminal-Width
stty rows 50 cols 150
if linebreak does not work this can help in ~/.bashrc:
shopt -s checkwinsize #if [ $(tty) == '/dev/ttyS0' ]; then # trap resize DEBUG #fi #resize-befehl in xterm export PROMPT_COMMAND="resize &>/dev/null ; $PROMPT_COMMAND"
ppp ifup-script
Script in /etc/ppp/ip-up.d must not have extension Quelle
example: ppp-default-route in separate routing-Table:
PPP_LOCAL=$4 PPP_REMOTE=$5 PPP_IFACE=$1 ip route flush table telekom ip route add $PPP_REMOTE/32 dev $PPP_IFACE src $PPP_LOCAL table telekom ip route add default dev $PPP_IFACE table telekom ip route show table telekom exit 0
apt-get
force ipv4
apt-get -o Acquire::ForceIPv4=true update
permanent (as root):
echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv4
only required packages
APT::Install-Recommends “false”; APT::Install-Suggests “false”;
basic x-server
apt-get install --no-install-recommends xserver-xorg xinit openbox policykit-1 xterm xfonts-base
simple Mailserver
as Relay-Server (sending Mails over external Mailserver) for System-purposes (infos, backup,…)
https://linuxundich.de/gnu-linux/system-mails-ohne-einen-mail-server-mit-ssmtp-verschicken/
screen
http://fractio.nl/2008/09/29/setting-session-name-in-screen/
screen -S Sessionname command
wget
-P download in dir
wget <file.ext> -P /path/to/folder
-O download as file
wget <file.ext> -O /path/to/folder/file.ext
processinfo
ps -o pid,args -C tcpdump
ls
full timestamps:
ls -l --time-style="+%Y-%m-%d %H:%M"
deactivate colors:
ls -l --color=none
bashrc / alias
alias cp="rsync -av --partial --progress" alias pynano="nano -ET4" alias catconf='find . -type f -exec grep -Iq . {} \; -printf "\n\n%p:\n" -exec cat {} \;'
nano
Jump to line: Ctrl+Shift+- (Ctrl+_)
Replace: Alt+R
settings
sudo nano /etc/nanorc
Cursorposition
## Constantly display the cursor position in the status bar. Note that ## this overrides "quickblank". set constantshow #temporär strg+C,
linenumbers
## Display line numbers to the left of the text. set linenumbers # alt+# to disable temporarily
TAB-width
#/etc/nanorc set tabsize 4 #temporary setting it (e.g. for Patches) nano -T 8 datei
storage check
#filesystem: sudo fsck -f /dev/sdb1 #check for bad sectors sudo badblocks -nsv /dev/sdb
http://www.das-werkstatt.com/forum/werkstatt/viewtopic.php?t=2346
NTP
apt-get install ntp #nano /etc/ntp.conf # need restart after change service ntp status #show state of servers ntpq -p
manual update:
service ntp stop ntpdate ptbtime1.ptb.de service ntp start
set time
#timedatectl --help timedatectl set-timezone CET #timezone (CET/CEST) date -s "2020-10-29 19:14" #time hwclock -w #set RTC if there is any, else time will be wrong after next reboot
update-alternatives
sudo apt-get install gcc-8-arm-linux-gnueabihf sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-8 50 sudo update-alternatives --config arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc --version
#to create update-alternatives in a loop you can use this for i in $(ls /usr/bin/arm-linux-gnueabihf-gcc-{9..12});do sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc $i 50;done
other example
sudo update-alternatives --install /usr/bin/calc calc /usr/bin/gnome-calculator 10
renaming
File test will be renamed into test.bak (same directory)
mv /home/frank/test{,.bak}
gunzip
on-the-fly decompress and write to disk
gunzip -c bpi-r3_sdmmc_bullseye.img.gz | sudo dd bs=1M status=progress conv=notrunc,fsync of=/dev/sdX
tar
tar -xzf file.tar.gz --strip-components 1 -C DESTINATION
sed
extract text between patterns:
example (extract frequencies from iw command):
iw list | sed -n '/Frequencies/,/Band\|Supported commands/{/Band\|Supported commands/!p;}'
irssi
config
Server+nick:
irssi -n NICK #start irssi with nickname
/network add -nick NICK -autosendcmd "/msg nickserv IDENTIFY *******" fn /server add -auto -ssl -network fn chat.freenode.net 7070 #ports 6697, 7000 and 7070 for SSL-encrypted connections.
/SET nick xxx /SET alternate_nick xxx /nick alternatenick /msg NickServ IDENTIFY mainnick password /msg NickServ GROUP
https://freenode.net/kb/answer/registration
/alias nick_recover msg NickServ GHOST $0 $1; wait 2000; msg NickServ RELEASE $0 $1; wait 2000; nick $0; wait 2000; msg NickServ IDENTIFY $1 /network modify -autosendcmd "/nick_recover NICK PASSWORD" fn /SET server_reconnect_time 300
switch windows
/window 1-x #1=server-window
Ctrl+P (previous)/ctrl+N (next)
/win list #shows open windows in the Server-Status (1)
Away mode
/away grund #start awaymode (Nachrichten shown in Server-window #1) /away #stop away mode
udev
same serial-adapter with Symlink based on USB-Ports (behind Hub)
https://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters
udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
/etc/udev/rules.d/11-ttyusb.rules:
#r2 (first port) roothub-port.hubport # KERNELS=="1-3.1:1.0" # KERNELS=="1-3.1" #r64 (second port=3) # KERNELS=="1-3.3:1.0" # KERNELS=="1-3.3" KERNEL=="ttyUSB*", KERNELS=="*-*.1*", SYMLINK+="ttyUSB_R2" KERNEL=="ttyUSB*", KERNELS=="*-*.3*", SYMLINK+="ttyUSB_R64"
my current config splitting by serial
#ch340 KERNELS=="1-3.3" no serial SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="tty_r2pro" #cp2102 KERNELS=="1-3.2" SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="010CB6FA", SYMLINK+="tty_r3" #cp2104 KERNELS=="1-3.1" SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001", SYMLINK+="tty_r2"
this udev rules i use for ftdi 4xuart adapter (FT4232H Quad RS232-HS)
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ftdi_r2" SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ftdi_r64" SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ENV{ID_USB_INTERFACE_NUM}=="02", SYMLINK+="ftdi_r3" SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ENV{ID_USB_INTERFACE_NUM}=="03", SYMLINK+="ftdi_r4"
easier way to get the main-properties of a device
udevadm info /dev/sdb1
sshd
qnap (entware)
nano /opt/etc/ssh/sshd_config #ggf. optionen anpassen (hostkey ecdsa/ed.../...) ps | grep ssh kill PID #PID= pid von /opt/sbin/sshd /opt/sbin/sshd -E /tmp/sshd.log -o LogLevel=DEBUG3 tail -f /tmp/sshd.log #bei Fehler "Bad ownership": chmod go-w ~/;chmod 700 ~/.ssh;chmod 600 ~/.ssh/authorized_keys #wenn fertig /opt/etc/init.d/S40sshd restart
kernel kernelconfig (/proc/config.gz)
# modprobe configs # zcat /proc/config.gz | grep -i hwmon CONFIG_HWMON=y # CONFIG_HWMON_DEBUG_CHIP is not set # CONFIG_SENSORS_IIO_HWMON is not set CONFIG_THERMAL_HWMON=y
mv-alternative
rsync -avh --progress --remove-source-files source target/ #delete empty directories (not done by rsync) find source/ -type d -empty -delete
other
force fsck
in kernel-cmdline:
fsck.mode=force
smartctl / hdparm
smartctl -t short /dev/sdb smartctl -a /dev/sdb | grep -A1 "Self-test execution status" #Beispielausgabe: Self-test execution status: ( 249) Self-test routine in progress... 90% of test remaining. #oder: Self-test execution status: ( 121) The previous self-test completed having the read element of the test failed. #warten bis fertig und bei Fehler: smartctl -a /dev/sdb | grep '^#' Beispielausgabe mit Fehler (long): # 1 Extended offline Completed: read failure 90% 267 1709921 #sektor und angrenzende in Schleife versuchen neu zu schreiben for i in {1709920..1709930};do hdparm --yes-i-know-what-i-am-doing --repair-sector $i /dev/sdb;sleep 1;done
iostat
apt install sysstat
Ausgabe:
$ iostat -m -p /dev/sdb Linux 5.15.0-56-generic (frank-G5) 29.12.2022 _x86_64_ (12 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 2,19 0,01 0,74 2,58 0,00 94,48 Device tps MB_read/s MB_wrtn/s MB_dscd/s MB_read MB_wrtn MB_dscd sdb 5,80 0,00 0,67 0,00 3 9123 0 sdb1 0,01 0,00 0,00 0,00 2 0 0
rc.local
VNC-Server
based on https://www.scivision.dev/vncserver-setup-on-ubuntu/
apt install tightvncserver openbox apt install lxterminal firefox-esr --no-install-recommends
~/.vnc/xstartup
#!/bin/sh xrdb $HOME/.Xresources xsetroot -solid grey unset SESSION_MANAGER exec openbox-session &
~/startVNC.sh
#!/bin/sh vncserver :1 -geometry 1024x768 -depth 8
do not forget to set execute rights
chmod +x ~/startVNC.sh ~/.vnc/xstartup
i setart the script with rc.local (see above), but a init-script is also possible
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04-de
locales
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Solution:
if not yet done, generate locales
locale-gen de_DE.UTF-8
add this to /etc/environment:
LC_ALL=de_DE.UTF-8 LANG=de_DE.UTF-8
maybe again
dpkg-reconfigure locales
now error should be fixed
locale -a
Solution using /etc/default/locale was not working for me
LVM
https://wiki.debian.org/LVM#Create_a_PV
prepared initrd
apt install initramfs-tools kernelversion=$(uname -r) echo $kernelversion zcat /proc/config.gz > /boot/config-$kernelversion less /boot/config-$kernelversion update-initramfs -k $kernelversion -c
root@bpi-r3-mini:~# apt install lvm2 root@bpi-r3-mini:~# fdisk /dev/nvme0n1 #changed type of partition 3 to lvm root@bpi-r3-mini:~# pvcreate /dev/nvme0n1p3 root@bpi-r3-mini:~# vgcreate vg-nvme /dev/nvme0n1p3 Volume group "vg-nvme" successfully created root@bpi-r3-mini:~# vgdisplay --- Volume group --- VG Name vg-nvme System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 80.74 GiB PE Size 4.00 MiB Total PE 20670 Alloc PE / Size 0 / 0 Free PE / Size 20670 / 80.74 GiB VG UUID w22Wdx-Fhch-YNsA-roWh-Zq81-qv0R-d5fnvw root@bpi-r3-mini:~# lvcreate -n var -L 10g vg-nvme Logical volume "var" created. root@bpi-r3-mini:~# mkfs -t ext4 /dev/vg-nvme/var root@bpi-r3-mini:~# mount /dev/mapper/vg--nvme-var /var_lvm [ 5279.856899] EXT4-fs (dm-0): mounted filesystem 520d434d-fdfc-48f3-823d-77e602 7e84e7 r/w with ordered data mode. Quota mode: disabled. root@bpi-r3-mini:~#