Notes...

Python 3 http.server

Quickly sharing files via web browser

$ python -m http.server
$ python -m http.server 1234
$ python -m http.server 1234 --bind 127.0.0.1

Knocking Ports, to open SSH session (Port Knocking was setup with iptables)

#!/bin/bash
HOST=$1
shift
for ARG in "$@"
do
nmap -Pn --host_timeout 15 --max-retries 0 -p $ARG $HOST
done

Usage:

$ sh knock.sh 172.16.0.81 8881 7777 9991

Warrior of The Net

https://www.youtube.com/watch?v=PBWhzz_Gn10

Upgrading Linux Kernel on Gentoo

$ ssh -l fahmi 172.16.0.66
$ tmux new -s upgrade
# eselect kernel list
# eselect kernel set 3 (set to the newest kernel, in my case linux-4.1.4-hardened is on the 3rd list)
# cp /boot/config-3.18.9-hardened /usr/src/linux/.config
# cd /usr/src/linux
# make olddefconfig
# uname -a
Linux gentoo 3.18.9-hardened #1 SMP Tue Aug 18 13:01:38 WIB 2015 x86_64 Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz GenuineIntel GNU/Linux
# make -j3
# make modules_install
# make install
# genkernel --install initramfs
# cd /boot
# mkdir ~/oldkernel
# mv config-3.18.9-hardened initramfs-genkernel-x86_64-3.18.9-hardened vmlinuz-3.18.9-hardened kernel-genkernel-x86_64-3.18.9-hardened ~/oldkernel/
# grub2-mkconfig -o /boot/grub/grub.cfg
# reboot

$ ssh -l fahmi 172.16.0.66
$ su -
# cd /usr/src/linux
# rm -r linux-3.18.9-hardened/ linux-4.0.8-hardened/
# rm /boot/System.map-3.18.9-hardened /boot/System.map-genkernel-x86_64-3.18.9-hardened
# rm -r /lib/modules/3.18.9-hardened/

https://wiki.gentoo.org/wiki/Kernel/Removal

https://wiki.gentoo.org/wiki/Kernel/Upgrade

Find and Remove Files (linux)

basic syntax :

find dir-name criteria action

remove files such as *.mdx or *.ts :

find /dir/to/search -name "file name criteria" -exec rm -rf {} \;

or

find /dir/to/search/ -type f -name "FILE-TO-FIND-Regex" -exec rm -rf {} \;
  1. -name "FILE-TO-FIND" : file pattern
  2. -exec rm -rf {} \; : delete all that matches
  3. -type f : matches files only
  4. -type d : matches directories only

on newer version of find, you could use -delete option:

find /dir/to/search/ -type f -name "FILES-TO-FIND" -delete

references:

Linux / Unix: Find And Remove Files With One Command On Fly