Skip to content

Instantly share code, notes, and snippets.

@creative-sensor
creative-sensor / linux.notes
Last active May 7, 2018 23:33
Linux admin cheatsheet
#!/bin/sh
# nmcli , set-ip-address ,
nmcli c modify eth0 ipv4.method static ipv4.addresses 192.168.1.15/24 ipv4.dns 8.8.8.8 ipv4.gateway 192.168.1.1 connection.autoconnect yes
nmcli con down eth0
nmcli con up eth0
# bond-rr ,
nmcli con add type bond ifname BOND_RR
@creative-sensor
creative-sensor / notes
Last active April 20, 2018 07:06
tips and tricks
# match repeated characters "(aaa)baa(bbb)cdd
echo aaabaabbbcdd | grep -E '(.)\1\1' -
# python , print-json-pretty ,
echo '{1.2:3.4}' | python -mjson.tool
#filter-file-system-call ,
strace -Tfe trace=open,read,write ./program
#follow-redirect , auto-redirect ,
curl -L example.com
set laststatus=2
set ruler
set cursorline
set hlsearch
set nowrap
set expandtab
set tabstop=4
set mouse=a
filetype plugin on
#!/bin/bash
####################### ORACLE NOTES ###################################
## Use Vim:searchIndex() to search index ##
## Ex: searchIndex list tablespace ##
########################################################################
#tablespace , tablespace-management ,
@creative-sensor
creative-sensor / ssh
Last active September 17, 2017 07:52
# Reversed ssh: acts like trojan that open backdoor behind firewall by tunneling
1/ Confined host (behind firewall) ------ ssh tunnel XYZ -----> freedom host:22
2/ Confined host (localhost:22) <----- ssh forward inside tunnel XYZ --------- freedom host (localhost:11111) <---- ssh --- User
Run this command from confined host:
ssh -R localhost:11111:localhost:22 username@freedom_host
# Green for dark background
COLOR1='\[\033[38;5;34m\]'
# Dark Pink for bright background (ROOT user)
COLOR2='\[\033[38;5;161m\]'
# Blue for bright background
COLOR3='\[\033[38;5;26m\]'
@creative-sensor
creative-sensor / ipush
Created February 21, 2017 15:59
Push file data through long ssh pipe
#!/bin/bash -x
SRC=$1
DST=$2
DEV="hostname of intermediary"
PI=$(<~/.pi)
ssh_dev="ssh -A $DEV"
ssh_dump_pi="ssh $PI 'sudo bash -c \"cat > "$DST"\"'"
@creative-sensor
creative-sensor / list.h
Created November 3, 2016 22:28
Kernel linked list for userspace
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
#include <linux/types.h>
//#include <linux/stddef.h>
//#include <linux/poison.h>
//#include <linux/const.h>
//#include <linux/kernel.h>
#include <unistd.h>
/*