[Project-14: Hints-Tricks-Tips-Shorts-Memos]
Overview
Overview
Thoughts ...
Thoughts ...
Links:
- Debian Package Managers: dpkg, apt and Aptitude Explained
https://linuxhint.com/https-linuxhint-com-debian_package_managers/ - Cheat Sheet: Backing Up a Disk Remotely with ssh and dd
https://www.blackhole-networks.com/Cheatsheets/ssh_dd_backup/ - Important note: Make sure you use a good, reliable and fast SD card.
https://docs.armbian.com/User-Guide_Getting-Started/#how-to-install-to-emmc-nand-sata-nvme-usb - Everything You Wanted to know About Psexec
https://adamtheautomator.com/psexec/
Sub project: Mikrotik RB750Gr + Raspi Zero USB-OTG + PiHole
Sub project: Mikrotik RB750Gr + Raspi Zero USB-OTG + PiHole
Parts: Version 0-- Mikrotik RB750Gr hEX-- Raspberry Zero---- USB-OTG Adapter-- DietPi (or PiCore)-- PiHole
Step 1: Setup Mirotik RB750Gr router
Step 1: Setup Mirotik RB750Gr router
- reset configuration and reboot
- configure router (Quick Set)
- set password
- Mode: Router
Internet
- Address Acquisition: Automatic (because my Draytec Vigor2765 handels DSL)
Local Network
- 192.168.30.1/24
- DHCP-Server 192.168.30.100-199
- NAT
- Router Identity: RB750Gr
- check for updates and reboot - # https://indibit.de/mikrotik-dns-namensaufloesung-fqdn
- DNS: Servers 192.168.30.1 (for own local domain)
Dynamic Servers (from DHCP WAN config)
Allow Remote Request: Yes
- DHCP: Address 192.168.30.0/24
Gateway: 192.168.30.1
Netmask 24
DNS Servers 192.168.30.1
Domain family.home.arpa
- Tools/RoMON enabled
Step 2: Setup Raspberry Pi Zero with DietPi
Step 2: Setup Raspberry Pi Zero with DietPi
- prepare sd-card from another system ...
$ sudo fdisk -l
$ sudo fdisk /dev/sdX
# delete all partitions and create empty dos partition
# update kernel with disk partition changes
- download DietPi
$ wget https://dietpi.com/downloads/images/DietPi_RPi-ARMv6-Bullseye.7z
# unzip with 7zr
$ sudo apt-get install p7zip
$ sudo 7zr x DietPi_RPi-ARMv6-Bullseye.7z
# duplicate image to disk
# update kernel with disk partition changes$ sudo partprobe /dev/sdX
# remove sd-card
- start over on RPi-Zero
- connect keyboard, monitor, network, etc.
- set passords
- install, setup and config system and software
Step 3: Adapt RPi to USB-OTG RNDIS/Ethernet Gadget
Step 3: Adapt RPi to USB-OTG RNDIS/Ethernet Gadget
- connect with serial console cable to RPi
- USB-TTL adapter
/-RxD---\/---RxD------GPIO14-Pin6 \
PC USB2TTL====--TxD---/\---TxD------GPIO15-Pin8-- RPi Zero (Serial UART)
\-GND--------GND------Ground-Pin10/
- Speed 115200 8N1 - now USB-Port is free for OTG-Configurtion
- add dtoverlay settings in config.txt
dtoverlay=disable-bt
dtoverlay=dwc2
- add settings in cmdline.txt
modules-load=dwc2,g_ether
create file
$ sudo nano /etc/modprobe.d/g_ether.conf
# with the following content (a single line of text)
options g_ether idVendor=0x05ac idProduct=0x1402 iProduct=Pi0 iManufacturer=Raspberry
# NOTE: This is required for RPi to show up as LTE interface on Mikrotik!
now reboot and check the new usb0 network device
$ sudo config -a
# now create and edit
$ sudo nano /etc/network/interfaces.d/usb0
# and set new IP address
# ----------------------------------------
# Location: /etc/network/interfaces.d/usb0
#
# usb0 drop-in config
#
# USB0
allow-hotplug usb0
iface usb0 inet static
address 192.168.31.2
netmask 255.255.255.0
gateway 192.168.31.1
#
# ----------------------------------------
# reboot, verify all settings and shutdown
#
# https://forum.mikrotik.com/viewtopic.php?t=131188
Step 4: Plug RPi USB into Router USB
Step 4: Plug RPi USB into Router USB
- after plugin in, open Winbox and connect to router
- "Interface" has now a new interface lte1
to add a new IP address for lte1 goto
- IP/Addresses + (and choose lte1 interface)
RPi has 192.168.31.2 with gateway 192.168.31.1 (gateway is lte1 on Mikrotik router)
ssh into RPi is now again possible
Step 5: Install and configure PiHole
Step 5: Install and configure PiHole
- ssh dietpi@192.168.31.2
- sudo dietpi-launcher
... PiHole is part of apt (browse software) - config PiHole, etc.
Sub project: Raspi Zero NAS
Sub project: Raspi Zero NAS
Parts: Version 0-- Raspberry Zero--- USB Hub---- USB Network Adapter---- USB Memory-- Casing-- Powering
OS: tinycorelinuxhttp://tinycorelinux.net/corebook.pdf
http://tinycorelinux.net/install.html
# chose memory drive$ sudo lsblk# umount if necessary$ sudo umount ...
# prepare drive$ sudo fdisk /dev/sdx# p (print partition table)# d (delete a partition)# o (create a new empty DOS partition table# w (write changes)
# update kernel with disk partition changes$ sudo partprobe /dev/sdX
# download # 64bit# http://tinycorelinux.net/13.x/aarch64/releases/RPi/piCore64-13.1.zip# or$ sudo wget http://tinycorelinux.net/13.x/armv6/releases/RPi/piCore-13.1.0.zip$ sudo unzip piCore-13.1.0.zip
# dd to disk$ sudo dd if=piCore-13.1.0.img of=/dev/sdX bs=100M status=progress# and sync$ sudo sync
# update kernel with disk partition changes$ sudo partprobe /dev/sdX
# (re)-partition memory drive (expand 2nd partitions size)# with gparted or fdisk
$ sudo fdisk -u /dev/sdX# p (print partitions and and write down starting sector of 2nd partition)# d (for delete and then enter "2" to delete 2nd partition)# n (now re-create create new primary (p) partition# with starting sector as deleted one# choose ending sector default (all available space)# w (write changing)# and sync$ sudo sync
# again update kernel with disk partition changes$ sudo partprobe /dev/sdX
# check filesystem$ sudo e2fsck -f /dev/sdX2# and resize$ sudo resize2fs /dev/sdX2
# now disk is ready # use and reboot in new system
# after first boot run$ filetool.sh -b# to save unique SSH keys
# configure ip for 1st use (because dhcp ist not yet available)$ sudo ifconfig eth0 x.x.x.x netmask x.x.x.x
$ route add default gw x.x.x.x eth0
# add nameserver for dns to# hint: # start INSERT mode with 'i'# type text# leave mode with ESC# save with ':wq'$ vi /etc/resolf.confi~ nameserver 8.8.8.8esc:wq
$ sudo ifconfig eth0 dynamic$ sudo ifconfig up
# ok tinycore uses udhcpc :-)$ sudo udhcpc
# check with$ ping www.google.com
# NOW we can load and start the GUI$ tce-load -iw TC$ startx
http://tinycorelinux.net/12.x/armv6/releases/RPi/READMEhttp://forum.tinycorelinux.net/index.php/board,57.0.html
# https://iotbyhvm.ooo/picore-tiny-core-linux-on-raspberry-pi/# https://iotbytes.wordpress.com/configure-ssh-server-on-microcore-tiny-linux/## Install OpenSSH Package$ tce-load -wi openssh
# Create SSH Config from Template$ cd /usr/local/etc/ssh/$ sudo cp ssh_config.example ssh_config
# Start SSH Service$ sudo /usr/local/etc/init.d/openssh start
# Change the Password for default “tc” user$ passwd
# Check IP address$ ifconfig
# https://github.com/mxmxmx/terminal_tedium/wiki/piCore# # install some things we need# (the -wi flag meaning the app will be available "onboot")# # alsa# tce-load -wi alsa.tcz # more things for alsa# tce-load -wi alsa-utils.tcz# also install using tce-load -wi# git.tcz, make.tcz, gcc.tcz, compiletc.tcz, # wget.tcz, tar.tcz, acl.tcz, # wiringpi.tcz, wiringpi-dev.tcz, # libunistring.tcz # and nano.tcz (or whichever editor you prefer)## if you intend to use wifi, you'll also need # wireless_tools.tcz and wpa_supplicant.tcz## edit /mnt/sda1/config.txt
## https://iotbytes.wordpress.com/tiny-core-persistance-notes/#
...
Add new partition
# n (add a new partition)# p (primary)# 1 (partition number 1-4)# . (first sector)# +128M (... size)Add new partition
# t (type)# L (... L to list all ...)# c (W95 FAT32 LBA)# w (write changes)$ sudo sync
Format SD-Card or USB stick for BerryBoot:
(or any other Raspi-OS / same principle)Format SD-Card or USB stick for BerryBoot:
# www.berryboot.com# Source code available at: # https://github.com/maxnet/berryboot# Website: # http://www.berryterminal.com/doku.php/berryboot
# list disk$ sudo fdisk -l
$ sudo lsblk
# in case: unmount first!$ sudo umount /dev/sdx
# prepare disk
$ fdisk /dev/sdx
# check and delete all partitions
# create new partition (fat32)
# format and write fs$ sudo mkfs.vfat /dev/sdx1
# download berryboot from# https://www.berryterminal.com/doku.php/berryboot$ wget https://downloads.sourceforge.net/project/berryboot/berryboot-20210701-pi4.zip
# unzip to new formated disk$ mkdir mntpoint$ mount /dev/sdx1 mntpoint$ cd mntpoint$ sudo unzip /downloadllocation/berryboot-date-version-zip
# eject sdcard / stick and put into raspi# boot and have fun
How to ...
How to ...
... launch desktop application with root privileges?
$ apt install nautilus# launch a new terminal and enter $ sudo -i nautilus# the resulting window falls now under the sudo umbrella# any files launched and accessed have now sudo-root privileges # in this terminal until it closes# this comes in handy for transitory situations as a quick solution... launch desktop application with root privileges?
... beautify powershell
# from https://christitus.com/pretty-powershell/$ irm "https://github.com/ChrisTitusTech/powershell-profile/raw/main/setup.ps1" | iex... beautify powershell
... upload a disk over ssh
... upload a disk over ssh
- from lokal disk to remote system
# check status? -> add "&" at end of line ...dd if=/home/archive/linode.img | ssh root@192.0.2.9 "dd of=/dev/sda" &# and now execute ...sudo pkill -usr1 dd
... use OpenSSH server
... use OpenSSH server
- install server
- configure ssh service
# add / change settings accordingly# PermitRootLogin
- check server status
- start / stop /restart service
- add Service for system startup
- find IP for connection
- find username for connection
- connect to remote machine
- show kernel version
- close connection to remote machine
- copy files from and to samba share
- copy files from and to samba share
Table of contents:
Hints-Tricks-Tips-Shorts-Memos
... use Linux disks and partitions and file systems
... use Linux disks and partitions and file systems
- ... use useful commands
$ fdisk -l
$ fdisk /dev/[block-device]
$ # deactivate swap partition$ swapoff /dev/[block-device]
$ # Linux ‘Parted’ Commands to Create, Resize and Rescue Disk Partitions$ # https://www.tecmint.com/parted-command-to-create-resize-rescue-linux-disk-partitions/$ apt install parted
# Provoke a new sync of partitions$ partprobe
$ # Change partitions:$ # Open block-device$ parted /dev/[block-device]
$ # print (show) disk geometry entries(parted) print(parted) print
$ # delete (swap) partition(parted) rm 3
Alternates:Gparted
# https://tipstricks.itmatrix.eu/hard-disk-sync-without-reboot/# https://kerneltalks.com/disk-management/how-to-rescan-disk-in-linux-after-extending-vmware-disk/
- ... clone and duplicate disks and partitions
# or$ ddrescue inputFile outputFile logFile
- ... get the list of mounted file systems
- ... get the filesystem type, full path (or both)
- ... mount cifs, ntfs ...
# ntfs$ sudo mkdir /mnt/ntfs$ sudo mount -t ntfs -o ro /dev/sdxy /mnt/ntfs
# msdos$ sudo mkdir /mnt/msdos$ sudo mount -t msdos -o ro /dev/sdxy /mnt/msdos
- ... umount
... SSH X11 forwarding in PowerShell
... SSH X11 forwarding in PowerShell
- needs VcXsrv Windows X Server (or similar)
PS: $env:DISPLAY="127.0.0.1:0.0"PS: echo $env:DISPLAY
# permanently add the DISPLAY environment variable to Windows Powershell with setx commandPS: setx DISPLAY "127.0.0.1:0.0"
# Start the built-in SSH client with # -X Enables X11 forwarding# -Y Enables trusted X11 forwardingPS: ssh -X <your_user_id>@<server_address>
# now check DISPLAY environment variable$ echo $DISPLAY # should show localhost:10.0 or similar# and is automatically set by the SSH server# No need to be the same as in Windows
$ xcalck$ xclock# or whatever X app
- ... find files..
- ... speed up RDP
# SERVER-SIDE GPU ACCELERATION IN LINUX# ss it happens, both xrdp and Remmina already support GFX AVC:444 encoding out of the box (more on that later).
$
- ... install Arch Linux ARM on Rapberry 3
$ ...
- ... activate the network
- ... see OS info
- ... use TRACERT in Linux
# If you do not have trace route installed you may need to install it. # For example in Ubuntu the command to install trace route is $ sudo apt-get install traceroute
... setup BerryBoot USB media for first boot
... setup BerryBoot USB media for first boot
- grab an USB media
$ $
https://www.adamintech.com/disabling-ipv6-temporarily-in-linux/