nc -l -u 9999 -k -c 'xargs -n1 echo'
adb shell pm list packages
adb shell pm path com.example.someapp
adb pull /data/app/com.example.someapp-2.apk
nmap -sn 10.0.1.0/24
udevadm control --reload-rules
KERNEL=="sd?1", SUBSYSTEMS=="usb", DRIVERS=="usb-storage", ACTION=="add", RUN+="/woswasi.sh"
udevadm info -a /dev/sdb1
:set noautoindent
:set paste
rpm -q --provides openpgm-5.2.122-2.el6.x86_64
journalctl -u <unit-name>
journalctl --no-pager | less
tcpdump -i eth0 -c1 -s0 -vvv ether dst host 01:80:c2:00:00:02
kexec -l /boot/vmlinuz-$(uname -r) \
--initrd=/boot/initramfs-$(uname -r).img \
--reuse-cmdline
kexec -e
tcpdump -i eth0 -v -s 0 -c 1 'ether[20:2] == 0x2000'
localectl set-keymap --no-convert keymap us
#!/bin/bash
#file: /etc/NetworkManger/dispatcher.d/30-autovpn.sh
vpn_name='myvpn'
if ping -c 1 www.google.at >/dev/null 2>&1; then
if ! nmcli connection show --active | grep "^${vpn_name}.*" >/dev/null 2>&1; then
nmcli connection up ${vpn_name}
fi
fi
nmcli connection modify vpn +ipv4.routes 140.82.118.3/32
nmcli connection modify vpn +ipv4.routes 140.82.118.4/32
chrome://net-internals/#proxy -> Proxy -> Re-apply settings
pstree -sp $$
rpm2cpio myrpmfile.rpm | cpio -idmv
git branch -d dev
git push --delete origin dev
[ -z "${test}" ] && echo 'not zero length'
git diff branch-a..branch-b -- <file_to_diff>
\copy (SELECT * FROM persons) to '/tmp/persons_client.csv' with csv
filepath = 'file.txt'
with open(filepath) as f:
for cnt, line in enumerate(f):
print("Line {}: {}".format(cnt, line))
yumdownloader --destdir . --resolve varnish.x86_64
#default value
$ echo ${not_set_var:-default_value}
default_value
#default value + set var
$ echo ${not_set_var:=default_value}
default_value
$ echo $not_set_var
default_value
#error on if unset
$ echo ${not_set_var:?var is not set}
-bash: not_set_var: var is not set
#alternate value
$ x=9999
$ echo ${x:+1}
1
#substring
$ x='abcdefg'
$ echo ${x:1}
bcdefg
$ echo ${x:1:3}
bcd
#array
$ x=(a b c d)
$ echo ${x[*]} # values
a b c d
$ echo ${!x[*]} # indexes
0 1 2 3
$ echo ${#array[*]} #size
4
#variable lenth
$ x='a234'
$ echo ${#x}
4
#remove prefix pattern
$ x='P1234_99'
$ echo ${x#P*_}
99
#remove suffix pattern
$ x='nix_1asdf.txt'
$ echo ${x%_*.txt}
nix
#substitute
$ x='nix_1asdf.txt'
$ echo ${x/nix/qwert}
qwert_1asdf.txt
$ echo ${x/1*/qwert}
nix_qwert
#modify case
$ x=st0nE
$ echo ${x^}
St0nE
$ echo ${x^^}
ST0NE
$ echo ${x,}
st0nE
$ echo ${x,,}
st0ne
#arithmetic
$ x=1
$ echo $((${x}+2))
3
lsns
grep -i vmswap /proc/*/status | sort -n -k2
journalctl --disk-usage
journalctl --vacuum-size=10M
# send multicast
echo "from: $(hostname)" | socat STDIO UDP4-DATAGRAM:239.255.200.192:4131,ip-multicast-ttl=8
# receive multicast
socat UDP4-RECVFROM:4131,ip-add-membership=239.255.200.192:$(ip route get 8.8.8.8 | head -n1 | awk '{print $7}'),fork,reuseaddr -
# get methods
curl -X POST http://10.0.1.218/sony/system -H "X-Auth-PSK: 1234" -d '{"id": 20, "method": "getMethodTypes", "version": "1.0", "params": [""]}'
curl -X POST http://10.0.1.218/sony/appControl -H "X-Auth-PSK: 1234" -d '{"id": 20, "method": "getMethodTypes", "version": "1.0", "params": [""]}'
# power off
curl -X POST http://10.0.1.218/sony/system -H "X-Auth-PSK: 1234" -d '{"id": 20, "method": "setPowerStatus", "version": "1.0", "params": [{"status": false}]}'
# power on
curl -X POST http://10.0.1.218/sony/system -H "X-Auth-PSK: 1234" -d '{"id": 20, "method": "setPowerStatus", "version": "1.0", "params": [{"status": true}]}'
# start netflix
curl -X POST http://10.0.1.218/sony/appControl -H "X-Auth-PSK: 1234" -d '{"id": 20, "method": "setActiveApp", "version": "1.0", "params": [{"uri": "com.sony.dtv.com.netflix.ninja.com.netflix.ninja.MainActivity"}]}'
check out https://github.com/neurobin/shc
check out https://github.com/danrabinowitz/sshrc
# delete all interface on linux machine
# add bond interface
nmcli connection add type bond con-name bond ifname bond mode 802.3ad ipv4.addresses 10.0.1.106/24 ipv4.gateway 10.0.1.1 ipv4.dns 10.0.1.1 bond.options mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer2+3 ipv4.method manual
# add slave interfaces
nmcli connection add type bond-slave ifname enp0s20f0u6 con-name <slave-ineterface-1> master bond
nmcli connection add type bond-slave ifname enp0s20f0u6 con-name <slave-ineterface-2> master bond
# cisco config
conf t
interface GigabitEthernet1/0/11
channel-protocol lacp
channel-group 6 mode active
exit
interface GigabitEthernet1/0/12
channel-protocol lacp
channel-group 6 mode active
exit
interface Port-channel6
description port-channel 6 desc
switchport access vlan 37
switchport mode access
spanning-tree portfast
spanning-tree link-type point-to-point
exit