======================================================================================================================= ||| ||| ||||||||| ||| ||| --- --- ||||||||| ||||||||| ||||||||| ||||||||| ||||||||| ||| ||| ||| ||| ||| ||| --- --- ||| ||| ||| ||| ||| ||| ||| ||| ||| ||| ||| ||| ||| --- ||| ||| ||| ||| ||| |||||| ||||||||| ||| ||| ||| ||| ||| ||| --- --- ||| ||| ||| ||| ||| ||| ||| |||||| ||| ||| ||| ||||||||| --- --- ||| ||| ||||||||| ||| ||||||||| ||||||||| ======================================================================================================================= # T E R M I N A L ----------------------------------------------------------------------------------------------------- sudo apt update 1.download list of updated packages from the repository (do before upgrading) sudo apt upgrade 2.download and install the latest updates for the packages used sudo apt autoremove 3.removing unnecessary packages from the system after uninstall sudo apt autoclean 4.cleaning the downloaded package cache after autoremove sudo apt install -f resolve missing dependencies (if necessary) sudo apt search xxx search package xxx sudo apt install xxx install package xxx sudo dpkg -i file.deb install from the .deb file sudo dpkg -i *.deb install all .deb files in the directory (there should only be .deb files) sudo apt remove xxx uninstall packaqe xxx sudo apt remove --purge package* completely remove the package and its associated configuration files sha256sum xxx.iso check integrity of iso file with SH256 sum wget url download a file via url su - login as root usermod -aG sudo xxx add user xxx to sudo group (login as root before & reboot to make effective) groups xxx check association of user xxx in groups passwd change pass to current user apropos xxx linux command function clear clear displayed terminal contents man xxx linux command help name_package --version now the version of the package sudo run a command as administrator sudo dpkg-reconfigure tzdata change time zone sudo nano xxx open gnu nano editor to edit the xxx file sudo nano /etc/ssh/sshd_config ssh server configuration sudo reboot reboot now sudo shutdown -h now shutdown now sudo shutdown -h 20:00 shutdown at 20:00 sudo snap refresh if update problem with snap ubuntu, close snap and use this command first ... sudo snap refresh snap-store ... then use this command second ./myscript.sh run myscript.sh python3 myscript.py run myscript.py pwd show current directory cd change directory (cd /home/user/....) pkill xxx kill process xxx pkill -9 xxx force stop process xxx apt list --installed show list of installed packages with version details cat /proc/cpuinfo show cpu info cat /proc/meminfo show memory info cat /proc/version show linux version cat myfile display plain text of myfile in terminal date show date df -h show list of disk partitions free -h show memory usage history show history of commands used history -c 01.clear the history in memory > ~/.bash_history 02.empty the history file history -w 03.close the session properly and saving the empty history ip a show network info & ip logname displays machine's users lsblk show disks lscpu show cpu info lsusb show usb connections nmcli device status show internet network connection uname -a show machine name and kernel version uptime -s show last boot time sudo dmidecode show machine details (serial, bios, etc.) sudo smartctl -a /dev/x show details about disks with smartmontools (replace x with the correct disk) timedatectl status check time synchronization status sudo passwd user edit sudo pass for user sudo raspi-config start raspberry pi software configuration tool sudo rpi-eeprom-update check if the bootloader needs an update sudo apt full-upgrade to be used occasionally to keep the system completely up to date sudo rpi-update to be used as a last resort (firmware update) pictrl show info on GPIO pins pinout show pinout layout on your raspberry vcgencmd measure_temp show soc temperature vcgencmd version show firmware version on your raspberry add pass for sudo sudo nano /etc/sudoers.d/010_user-nopasswd add the ligne and save : user ALL=(ALL) PASSWD: ALL dpkg --get-selections > mypackages.txt create a text file with all installed packages sudo dpkg --set-selections < mypackages.txt to select the packages you want to restore (update before) sudo apt-get -u dselect-upgrade to install the packages # P A C K A G E S ----------------------------------------------------------------------------------------------------- AUDACIOUS audacious audio player BLUEFISH bluefish multi-platform editor BLUEMAN blueman graphical bluetooth manager CUPS cups driver manager for printers DMIDECODE dmidecode reports information about system (hardware and bios) DOCUMENT SCANNER simple-scan scanner manager FAIL2BAN fail2ban intrusion prevention software (if ssh & web servers are active) FREE CAD freecad free cad software FREE FILE SYNC freefilesync backup tool manager GALCULATOR galculator gnome calculator GIMP gimp image manipulation GNOME DISK gnome-disk-utility gnome disk tool manager GNOME TEXT EDITOR gnome-text-editor gnome text editor GPARTED gparted disk tool manager (alternative to gnome disk tool manager) GSMARTCONTROL gsmartcontrol graphical interface of smartmontools GUFW FIREWALL gufw firewall with graphical interface HARDINFO2 hardinfo system information and benchmark for linux HTOP htop tasks visual manager KICAD EDA kicad electronics design automation suite LIB FUSE 2 libfuse2 appimage file reader LIBRE OFFICE libreoffice25.2 office suite LIBREWOLF librewolf (via extrepo) custom version of firefox focused on privacy & security LUKS cryptsetup linux inified key setup is a disk encryption specification NTP ntp more accurate & more resource intensive than systemd-timesyncd PSENSOR psensor graphical sensor monitoring PSUTIL python3-psutil process and system utilities for retrieving information on system PYGAME python3-pygame python library designed for creating 2D video games PYTHON VENV python3-venv python virtual environments (source /home/greg/myenv/bin/activate) REMMINA remmina remote desktop software client SCREENFETCH screenfetch displays system information alongside the ASCII distro logo SMARTMONTOOLS smartmontools control and monitor storage systems STRESS NG stress-ng tool to load and stress a computer system THONNY thonny python editor TIMESHIFT timeshift system backups & restore TKINTER python3-tk python library for creating graphical user interfaces TOR PROJECT go to website download tar file on https://www.torproject.org/ TRANSMISSION tranmsission torrent manager VLC vlc cross-platform multimedia player # C R E A T E B O O T A B L E U S B I S O I M A G E --------------------------------------------------------------- 01.download iso image 02.identify the usb device using the lsblk command (eg: sdX for exemple below) 03.use dd to write the iso image to the usb drive : sudo dd if=/path/to/image.iso of=/dev/sdX bs=4M status=progress (replace /path/to/image.iso with the path to your iso file and /dev/sdX with the device of your usb drive) 04.sync and eject the usb drive : sudo sync && echo "Synchronization completed" # D E B I A N --------------------------------------------------------------------------------------------------------- sudo nano /etc/apt/sources.list edit if necessary to correct links for packages update with debian bookworm add # on the first line to comment it : # deb cdrom:[Debian GNU/Linux ... deb https://deb.debian.org/debian bookworm main non-free-firmware deb-src https://deb.debian.org/debian bookworm main non-free-firmware deb https://security.debian.org/debian-security bookworm-security main non-free-firmware deb-src https://security.debian.org/debian-security bookworm-security main non-free-firmware deb https://deb.debian.org/debian bookworm-updates main non-free-firmware deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware # Backports allow you to install newer versions of software made available for this release deb https://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware deb-src https://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware sudo nano /etc/default/grub add or remove "quiet splash" mode when booting debian GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" version with "quiet splash" mode GRUB_CMDLINE_LINUX_DEFAULT="" version without "quiet splash" mode sudo update-grub to do after modifying the grub file pactl set-sink-volume @DEFAULT_SINK@ +5% keyboard shortcut to setup (for pulseaudio) to increase volume pactl set-sink-volume @DEFAULT_SINK@ -5% keyboard shortcut to setup (for pulseaudio) to decrease volume tiling window managemment with xdotool sudo apt install xdotool, and then create keyboard shortcuts below : xdotool getactivewindow windowsize 50% 100% windowmove 0 0 super key + left to tile the window to the left xdotool getactivewindow windowsize 50% 100% windowmove 50% 0 super key + right to tile the window to the right xdotool getactivewindow windowsize 100% 100% windowmove 0 0 super key + up to maximize the window xdotool getactivewindow windowsize 800 600 windowmove 0 0 super key + down to restore the window # on raspberry os : 01.open the config file : nano ~/.config/openbox/lxde-pi-rc.xml 02.add block below before : xdotool getactivewindow windowsize 50% 100% windowmove 0 0 xdotool getactivewindow windowsize 50% 100% windowmove 50% 0 xdotool getactivewindow windowsize 100% 100% windowmove 0 0 xdotool getactivewindow windowsize 800 600 windowmove 0 0 03.exit and save 04.recharge openbox with : openbox --reconfigure # N T P S E R V E R -------------------------------------------------------------------------------------------------- 01.sudo apt install ntp 02.sudo systemctl start ntp 03.sudo nano /etc/ntp.conf 04.copy/past text below step 6 and then ... 05.sudo systemctl restart ntp 06.sudo systemctl status ntp # /etc/ntp.conf, configuration for ntpd # NTP servers server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst # Drift file driftfile /var/lib/ntp/ntp.drift # Restrictions restrict 127.0.0.1 restrict ::1 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap restrict default kod nomodify notrap nopeer noquery # Statistics Options statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable # S T R E S S N G ---------------------------------------------------------------------------------------------------- nproc to find the number of CPU cores cat /proc/meminfo | grep MemTotal to find the size of RAM memory available methods : sqrt: calculates square roots matrix: matrix multiplication fft: fast fourier transform calculations crc32: CRC32 calculation all: all of the above methods in parallel example with CPU 4 cores : stress-ng --cpu 4 --cpu-method all --timeout 60s --verbose --metrics-brief or with dynamic method : stress-ng --cpu $(nproc) --timeout 60s --verbose --metrics-brief example with 16GB RAM memory : stress-ng --vm 1 --vm-bytes 12G --timeout 60s --verbose --metrics-brief do not use more than 80% of the total available : 16 x 0.80 = 12GB or with dynamic method with 80% usage of total memory : stress-ng --vm 1 --vm-bytes $(awk '/MemAvailable/ {printf "%.0fK", $2 * 0.8}' /proc/meminfo) --timeout 60s --verbose --metrics-brief interruption at any time : 1.ctrl + c 2.pkill stress-ng 3.pkill -9 stress-ng # G U F W & S S H --------------------------------------------------------------------------------------------------- 01.sudo apt install gufw 02.sudo ufw enable 03.sudo ufw status verbose 04.check if Status: active & Default: deny (incoming), allow (outgoing), disabled (routed) 05.options : sudo ufw allow ssh # To maintain SSH access (port 22) sudo ufw allow 80/tcp # If you manage a web server sudo ufw allow 443/tcp # HTTPS if necessary sudo ufw disable sudo ufw reload sudo ufw app list sudo ufw allow xxx allow port/service sudo ufw deny xxx drop the connection from a specific port/service sudo ufw delete xxx delete the xxx rule sudo systemctl status ssh sudo systemctl enable ssh sudo systemctl start ssh sudo systemctl stop ssh sudo systemctl disable ssh sudo systemctl restart ssh # F A I L 2 B A N ----------------------------------------------------------------------------------------------------- 01.sudo apt install fail2ban 02.sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local 03.sudo nano /etc/fail2ban/jail.local 04.replace or add the values below, then... 05.close and save 06.sudo rm -rf /var/run/fail2ban/fail2ban.sock (sometimes the fail2ban.sock file remains stuck and prevents restarting) 07.sudo systemctl restart fail2ban 08.sudo systemctl status fail2ban 09.sudo fail2ban-client status (to check that your addresses are being ignored) [DEFAULT] ignoreip = 127.0.0.1/8 ::1 192.168.0.0/24 allowipv6 = auto bantime = 86400 # 1 day findtime = 1800 # 30 min maxretry = 3 banaction = iptables-multiport bantime.increment = true bantime.factor = 1 bantime.formula = ban.Time * (1<<(ban.Count if ban.Count<20 else 20)) * banFactor bantime.multipliers = 1 2 4 8 16 32 64 128 256 512 1024 [sshd] enabled = true port = ssh filter = sshd logpath = /var/log/auth.log (!! do not specify this parameter on raspberry os) maxretry = 3 backend = systemd [recidive] enabled = true filter = recidive logpath = /var/log/fail2ban.log bantime = 604800 # 1 week findtime = 86400 # 1 day # P A C K A G E S S A V E & R E S T O R E -------------------------------------------------------------------------- dpkg --get-selections > packages.txt save the list of packages in home/user before a major upgrade dpkg --set-selections < packages.txt restore the packages according to the previous generated file # A P P I M A G E ----------------------------------------------------------------------------------------------------- 01.install the libfuse2 package 02.create a directory /Applications & move the file inside 03.authorize its execution (right-click > Properties > Permissions > Allow execution) # E R A S E D A T A O N D I S K ------------------------------------------------------------------------------------ 01.use lsblk command to display the disks 02.identify the one to erase (in the example below we want to erase the data from sdX) 03.write random data to make the restoration very complex : sudo dd if=/dev/urandom of=/dev/sdX bs=4M status=progress 04.use a disk tool manager to erase & format disk [250419]