Skip to content

Instantly share code, notes, and snippets.

View stephen-hannam's full-sized avatar

kostoglotov stephen-hannam

View GitHub Profile
@stephen-hannam
stephen-hannam / isolate_cpus.md
Last active June 19, 2023 21:42
Script to isolate CPU cores from the linux kernel which also generates an undo (unisolate/restore) script when executed

Isolate CPU cores

A script to Isolate Cores from the linux kernel, with an option to generate an undo script.

#!/bin/bash
# - disables the Linux realtime throttling which ensures that realtime processes cannot starve the CPUS.
# - disables the Linux watchdog timer which is used to detect and recover from software faults.
# - disables the debugging feature for catching hardware hangings.
# - sets the default CPU affinity of 0b11 (3), which means that only CPU 0 and 1 handle interrupts.
# - moves all interrupts off cpus specified below starting at 2 and above.
@stephen-hannam
stephen-hannam / fork-pin-cpu.md
Created May 30, 2022 23:42
C - fork and pin to cpu

Template: Recursive Calls if fork returns positive value

#include <sched.h>
#define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \
                        } while (0)
                        
cpu_set_t set;
CPU_ZERO(&set);
@stephen-hannam
stephen-hannam / priv-escal-from-LFS.md
Created October 19, 2021 19:32
Procedural Privilege Escalation (as seen in LFS)

Procedural Privilege Escalation (from LFS scripts)

as_root()
{
  if   [ $EUID = 0 ];        then $*
  elif [ -x /usr/bin/sudo ]; then sudo $*
  else                            su -c \\"$*\\"
  fi
}
@stephen-hannam
stephen-hannam / linux-net-ns.md
Last active May 31, 2022 00:05
Linux Network Namespaces

Instructions

  1. Create two network namespaces
ip netns add ns0
ip netns add ns1
  1. Assign interfaces to namespaces
@stephen-hannam
stephen-hannam / rm_by_field_of_ls
Created February 4, 2021 23:16
delete files by grepped field from ls
`ls -la | grep <> | tr -s ' ' | cut -d ' ' -f9 | xargs rm`
@stephen-hannam
stephen-hannam / unix_box_chars.md
Last active August 3, 2020 23:58
Show us dem funky unix box characters

UNIX Box Chars Like a Scamp

#!/bin/bash

on='\x1b(0' # Esc ( 0
off='\x1b(B' # Esc ( B

for i in 6a 6b 6c 6d 6e 71 74 75 76 77 78; do
  printf "0x$i \x$i $on\x$i$off\n"

done

@stephen-hannam
stephen-hannam / docker_1liners.md
Last active August 3, 2020 23:53
Docker 1 liners

Dockery do

remove all containers

$docker rm $(docker ps -a -q)

remove all images

$docker rmi $(docker images -q)

remove all images forcefully

$docker rmi $(docker images -q) --force

@stephen-hannam
stephen-hannam / tail_grep_follow.md
Last active August 3, 2020 23:54
TAIL|GREP LOG in RT

Filter Log as it's Written and Append Timestamp

tail -f afile.log | egrep -i --line-buffered 'matching|filter|terms' | awk '{ printf strftime("%c") "\n" $0}'

@stephen-hannam
stephen-hannam / footnotes_test.md
Last active April 10, 2020 21:29
markdown footnotes test

Bla bla 1

more bla blah

more bla blah

more bla blah

more bla blah

@stephen-hannam
stephen-hannam / cli_trees.md
Last active April 16, 2020 21:46
Try different ways to represent cli directory trees in markdown

Ampersand: & &

a_b, a_b

*** represents a user defined substring

.
├── C
│   ├── ***_handling/