<<TableOfContents(2)>>

= kali =
Linux distribution debian based focused on security.
 * https://docs.kali.org/introduction/what-is-kali-linux

== Build bootable USB live ==
 * Get https://archive-4.kali.org/kali-images/kali-2019.2/kali-linux-light-2019.2-amd64.iso
{{{#!highlight sh
# output /var/log/messages when pen was attached
# Jul  6 18:17:12 nb200 kernel: [10389.761660] scsi 4:0:0:0: Direct-Access     Philips  USB Flash Drive  PMAP PQ: 0 ANSI: 4
# Jul  6 18:17:14 nb200 kernel: [10391.687146] sd 4:0:0:0: [sdb] 15133248 512-byte logical blocks: (7.75 GB/7.22 GiB)
# Jul  6 18:17:14 nb200 kernel: [10391.687845] sd 4:0:0:0: [sdb] Write Protect is off
# Jul  6 18:17:14 nb200 kernel: [10391.715891]  sdb: sdb1
# Jul  6 18:17:14 nb200 kernel: [10391.722619] sd 4:0:0:0: [sdb] Attached SCSI removable disk

dd if=kali-linux-light-2019.2-amd64.iso of=/dev/sdb bs=512k

# 1902+1 records in
# 1902+1 records out
# 997208064 bytes (997 MB, 951 MiB) copied, 259.342 s, 3.8 MB/s
}}}

== Deprecated networking commands ==
 * ifconfig -> ip a , ip address 
 * netstat -at -n -> ss -at -n
 * route -> ip r , ip route

== Make USB live persistent ==
  * Insert pen 
  * fdisk -l
{{{#!highlight sh
end=7gb
read start _ < <(du -bcm kali-linux-light-2019.2-amd64.iso | tail -1); echo $start
parted /dev/sdb mkpart primary $start $end

#Warning: You requested a partition from 952MB to 7000MB (sectors
#1859375..13671875).
#The closest location we can manage is 997MB to 7000MB (sectors
#1947072..13671875).
#Is this still acceptable to you?
#Yes/No? Yes                                                               
#Warning: The resulting partition is not properly aligned for best performance.
#Ignore/Cancel? Ignore                                                     
#Information: You may need to update /etc/fstab.

#create an ext3 file system 
mkfs.ext3 -L persistence /dev/sdb3
e2label /dev/sdb3 persistence
# create the configuration file to enable persistence
mkdir -p /mnt/my_usb
mount /dev/sdb3 /mnt/my_usb
echo "/ union" > /mnt/my_usb/persistence.conf
umount /dev/sdb3
}}}
 * Boot using Esc/F9 in HP laptop (legacy)
 * Choose Live USB persistence option
 * Run set xkbmap pt to have portuguese keyboard
 * Applications, settings, keyboard,layout, pt layout
 * adduser your_user
 * change root password with passwd 

== Connect WiFi ==
=== connectBitarus.sh ===
{{{#!highlight sh 
#!/bin/sh
pkill dhclient
pkill wpa_supplicant
rm /var/run/wpa_supplicant/wlan0
wpa_supplicant -d -c vodafone.conf -i wlan0 -B
sleep 5
ip link set dev wlan0 down
sleep 2
ip link set dev wlan0 up
sleep 2
dhclient -r wlan0
dhclient -4 -v wlan0
}}}

=== /etc/dhcp/dhclient.conf ===
{{{#!highlight sh
send host-name = gethostname();
send dhcp-client-identifier = hardware;
request subnet-mask, broadcast-address, time-offset, routers,
	domain-name, domain-name-servers, domain-search, host-name,
	dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
	netbios-name-servers, netbios-scope, interface-mtu,
	ntp-servers;

timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
}}}

=== wpa_supplicant.conf, vodafone.conf ===
{{{#!highlight sh
ap_scan=1
ctrl_interface=/var/run/wpa_supplicant
network={
  ssid="your_ssid"
  scan_ssid=1
  proto=RSN WPA
  key_mgmt=WPA-PSK
  pairwise=CCMP TKIP
  group=CCMP TKIP
  psk="your pass phrase"
}
}}}

== Enable sound with alsa ==
{{{#!highlight sh
apt-get purge pulseaudio pulseaudio-utils xfce4-pulseaudio-plugin  pavumeter pavucontrol
apt-get install alsa-tools alsa-tools-gui alsa-utils alsa-oss alsamixergui libalsaplayer0
alsamixer # m key mutes or unmutes a channel like master
}}}

=== Adjust default card ===
{{{#!highlight sh
aplay -l # list sound cards
}}}
/etc/asound.conf
{{{
defaults.pcm.card 1
defaults.ctl.card 1
}}}

{{{#!highlight sh
aplay  /usr/share/sqlmap/extra/beep/beep.wav
}}}

== Set timezone ==
{{{#!highlight bash
timedatectl set-timezone Europe/Lisbon
}}}

In the XFCE clock select Properties with the right mouse button and set the timezone to Europe/Lisbon.

== gcc ==

=== test.c ===
{{{#!highlight c
#include <stdio.h>

int main(int argc, char** argv){
  printf("Hello world");
  return 0;
}
}}}

=== Compile and execute ===
{{{#!highlight sh
gcc-8 test.c -o test
./test 
# Hello world
}}}

== Xfce battery plugin ==
Applications, settings, power manager, show system tray icon.
{{{#!highlight sh
apt install xfce4-battery-plugin
}}}

Panel, right mouse button, add new items, Power manager plugin 

== mousepad text editor ==
{{{#!highlight sh
apt install mousepad
}}}

== Install openjdk 12 ==
{{{#!highlight sh
#188 MB size
cd ~
wget https://download.java.net/java/GA/jdk12.0.1/69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz
tar xvzf openjdk-12.0.1_linux-x64_bin.tar.gz 
jdk-12.0.1/bin/java -version
# extracted has 321MB
}}}

== dhcpclient issues ==
{{{#!highlight sh
nmap --script broadcast-dhcp-discover -e wlan0
apt install tcpdump dhcpdump htop
iwlist scan
iwlist wlp3s0 scanning
sudo wpa_cli status
}}}
 * select mode b/g and channel 11


== Links gcc compiler ==
{{{#!highlight bash
ln -s /usr/bin/gcc-8 /usr/bin/gcc
ln -s /usr/bin/gcc-8 /usr/bin/cc
}}}

== docker.io and kubernetes ==
{{{#!highlight sh
apt install docker.io
systemctl status docker.service
docker ps
/sbin/usermod -a <user> -G docker
apt install curl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl
chmod 755 kubectl 
mv  kubectl /usr/local/bin/ 
kubectl version
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64   && chmod +x minikube
mv minikube /usr/local/bin/
minikube  version
minikube start --vm-driver=none
}}}

{{{
😄  minikube v1.2.0 on linux (amd64)
💿  Downloading Minikube ISO ...
🔥  Creating none VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
🐳  Configuring environment for Kubernetes v1.15.0 on Docker 18.09.1
💾  Downloading kubeadm v1.15.0
💾  Downloading kubelet v1.15.0
🚜  Pulling images ...

}}}