Other (Apt, Tmux, Grep) - MirgDenis/scripts GitHub Wiki
Welcome to the scripts wiki!
Here will be some runbooks, guides and other personal stuff.
Edit your ~/.tmux.conf and add lines:
set-window-option -g xterm-keys on
In case if you are using PuTTY add one more line
set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"
cat <config_path> | grep -v '^$\|^#'
-v - select non-matching lines
^$ - remove empty lines
\| - logical and
^# - remove anything which starts with #
wget -qO - <key_url> | sudo apt-key add -
echo "deb <repo_url> bionic main" > /etc/apt/sources.list.d/<repo_name>.list
{
echo 'Package: *'
echo 'Pin: release o=<release_name>'
echo 'Pin-Priority: 999'
} > /etc/apt/preferences.d/<repo_name>
In case of Dockerfile you can use ADD to download repo key inside container and avoid installing extra packages for downloading repo key.
Run golang container with security options
docker run -it --rm --security-opt=seccomp:unconfined golang bash
Get delve
go get github.com/derekparker/delve/cmd/dlv
Get application for debugging, and start debugging with following command
dlv debug <path to main (optional if you are in folder with it)> -- <parameters, flags etc.>
Install packages
apt update
apt install libvirt-bin qemu-efi qemu-system-aarch64 virtinst
Download cloud image and generate cloud-init iso. Then use following virt-install command to run VM.
virt-install --name=test --machine=virt --arch=aarch64 --memory=2048 --vcpu=2 \
--boot cdrom,hd --network=default,model=virtio --noautoconsole \
--disk path=/var/lib/libvirt/images/test,format=raw,device=disk,bus=virtio,cache=none --cdrom=/var/lib/libvirt/images/test-config
To delete this VM you need to delete nvram vars for UEFI.
virsh undefine test
rm /var/lib/libvirt/qemu/nvram/test_VARS.fd
virsh destroy test
apt update
apt install genisoimage
Create directory, and put there meta-data and user-data. Substtitute ... with your values. NOTE: you can use meta-data for network configuration.
mkdir cloud-init
cat << EOF >> ./cloud-init/user-data
#cloud-config
password: ...
chpasswd: { expire: False }
ssh_authorized_keys:
- ssh-rsa ...
EOF
cat << EOF >> ./cloud-init/meta-data
instance-id: ...
hostname: ...
local-hostname: ...
EOF
Generate ISO
mkisofs -o "/var/lib/libvirt/images/test-config" -V cidata -r -J --quiet ./cloud-init/meta-data
How to search in ldap with host, port, username, password and pagination
ldapsearch -x -D <username> -w <password> -H <protocol://host:port> -E pr=2147483647/noprompt -b <DN to search>
In case if indentation in Vim via Putty is broken (typically experienced during pasting text), you need to add following line to ~/.vimrc
if &term =~ "screen"
let &t_BE = "\e[?2004h"
let &t_BD = "\e[?2004l"
exec "set t_PS=\e[200~"
exec "set t_PE=\e[201~"
endif