Linux

Over the wire linux commands training online

Crontab less then one minute

VPN

Kali linux can’t mount cd-rom

Install VNC server
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04

Miscellaneous commands

  • ls -lha Shows also the hidden files

Edit Grub bootloader

  • To see/edit the build up of the boot menu > nano /boot/grub/grub.cfg
  • To see/edit the boot parameters > nano /etc/default/grub
    • the first point of the menu = 0
  • Update grub > update-grub

List traffic to a specific port

Install tcpdump
Show all traffic to this device
sudo tcpdump -ni eth0 port 1883
Show all traffic to this device except traffic from itself and exclude overhead signals
sudo tcpdump -ni eth0 port 1883′ and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0) and src not 192.168.x.x’
Show only traffic to this device from public addresses
sudo tcpdump -ni eth0 port 1883′ and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0) and src net not 192.168.x.x/24′

DD command to image disks

Used webpage

  • Tested with USB disks!!!
  • List all disks > lsblk
  • Add 2nd disk
  • List all disks > lsblk and check for a new device
  • Disk to disk > sudo dd if=/dev/sda of=/dev/sdb status=progress
  • Disk to a diskimage > sudo dd if=/dev/sdb of=/home/ntbua/disk.img status=progress
  • Insert the new disk and check with lsblk
  • diskimage to a disk > sudo dd if=/home/ntbua/disk.img of=/dev/sdb status=progress
  • CD to ISO > sudo dd if=/dev/cdrom of=tgsservice.iso bs=2048 status=progress
  • ISO to disk > sudo dd if=/home/ntbua/disk.iso of=/dev/sdb status=progress
  • Wipe a disk > sudo dd if=/dev/urandom bs=1M of=/dev/sd…. status=progress
  • Copy disk over a network
    • dd if=/dev/sda bs=5M conv=fsync status=progress | gzip -c -9 | ssh user@DestinationIP 'gzip -d | dd of=/dev/sda bs=5M'
  • Write Raspbian Image
    • Insert SD card into the reader and attach it to the computer
    • Run lsblk to find actual actual device name.
      Something like /dev/sdc1 as SD as card device.
    • Unmount /dev/sdc1 if mounted automatically
      df
      mount
      sudo umount /media/somename/
      sudo umount /dev/sdc1
    • Use the dd command:
      sudo dd if=2021-01-11-raspios-buster-armhf-lite.img of=/dev/sdc bs=4M conv=fsync status=progress
    • Remove the card and insert into your Raspberry PI.

S.M.A.R.T. SMART info

From the following webpage
sudo smartctl -a /dev/sda

Script for reading USB devices

for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
    (
        syspath="${sysdevpath%/dev}"
        devname="$(udevadm info -q name -p $syspath)"
        [[ "$devname" == "bus/"* ]] && exit
        eval "$(udevadm info -q property --export -p $syspath)"
        [[ -z "$ID_SERIAL" ]] && exit
        echo "/dev/$devname - $ID_SERIAL"
    )
done

PSCP Copy windows to Linux

To windows
> pscp pi@MQTT01:/home/pi/ca.crt c:\temp
To Linux
> pscp c:\temp\ca.crt pi@MQTT02:/home/pi/

SCAN for devices Linux

SCAN for devices
for i in {1..254};do (ping -c1 -i1 192.168.1.$i) &>/dev/null && echo -e " *\n[+] Device at:\t$i" || echo -n "." ;done
SCAN for open ports
for i in {8990..9010};do (echo </dev/tcp/192.168.1.253/$i) &>/dev/null && echo -e " *\n[+] Open port at:\t$i" || echo -n "." ;done

SCAN for devices Windows

In windows 11
del c:\temp\ipaddress.txt & FOR /L %i IN (1,1,254) DO ping -w 10 -n 1 192.168.166.%i | findstr -m "TTL" >>c:\temp\ipaddress.txt

del c:\temp\ipaddress.txt & FOR /L %i IN (1,1,254) DO ping -w 10 -n 1 192.168.2.%i | findstr -m “bytes=32” >> c:\temp\ipaddress.txt

SETSERIAL