Skip to content

Instantly share code, notes, and snippets.

View Strykar's full-sized avatar
💭
What is Bash?

Avinash H. Duduskar Strykar

💭
What is Bash?
  • India
View GitHub Profile
#!/bin/bash
#METHOD=netperf
METHOD=nuttcp
HOST=ref1
HOSTIP="192.168.0.2"
TARGETUSER=root
TARGET=target
#!/bin/sh
# Two examples for batch conversion of RRD to XML (done on the host the RRD were created on)
# Convert from XML back to RRD on the new host/arch
for f in *.rrd; do rrdtool dump ${f} > ${f}.xml; done
for f in *.xml; do rrdtool restore ${f} `echo ${f} | cut -f1 -d .`.rrd; done
find /tmp/data -type f -iname '*.rrd' -print0|while IFS= read -r -d '' f; do rrdtool dump ${f} > ${f}.xml; done
find /tmp/data -type f -iname '*.xml' -print0|while IFS= read -r -d '' f; do rrdtool restore ${f} `echo ${f} | cut -f1 -d .`.rrd -f; done
#See busy $10 Linode vm vs this $5 spare DO - https://gist.github.com/fwaggle/0ca82bc8454813550fc21b0200e58d9a
% sudo diskinfo -ctv /dev/gpt/rootfs
/dev/gpt/rootfs
512 # sectorsize
21474836480 # mediasize in bytes (20G)
41943040 # mediasize in sectors
0 # stripesize
1073759744 # stripeoffset
41610 # Cylinders according to firmware.
16 # Heads according to firmware.
# ipsec.conf - strongSwan IPsec configuration file
config setup
# uniqueids=yes
# charondebug="cfg 2, lib 1, dmn 1, ike 5, net 1, knl 1"
conn %default
keyexchange=ikev2
dpdaction=clear
#BadTCP
tcp.analysis.flags && ! tcp.analysis.window_update
#TCP header length is less than 28 and has the SYN flag enabled
(tcp.hdr_len < 28) && (tcp.flags.syn == 1)
#TCP stream time delta < 1s and packet does not have the RST/FIN flag set and no HTTP GET [&& (http.request.method != "GET")]
#Plot I/O chart vs tcp.time_delta
(tcp.time_delta > 1) && (tcp.flags.reset == 0) && (tcp.flags.fin == 0)
(tcp.time_delta > .5) && (tcp.flags.reset == 0) && (tcp.flags.fin == 0)
#!/bin/sh
# Check disk usage periodically via cron and free space up if $full - Stry
# send email to $admin
#ADMIN="admin@hackerzlair.org"
# set alert level in percentage
ALERT=95
# List directories we can safely smoke
#!/bin/bash
# Wrapper for cron to check and start TF2 server from $SCRIPT if need be
# cron is setup as:
# @reboot /home/tf2server/tf2d.sh start &> /dev/null
# */5 * * * * /home/tf2server/crontf2d.sh &> /dev/null
#
if ! /usr/bin/pgrep srcds ; then /home/tf2server/tf2d.sh start; fi
# Script to delete files older than one hour - run from cron
# Wednesday, November 07, 2007
#!/bin/bash
find /path/to/dir -cmin +60 -type f -maxdepth 1 -exec rm {} \;
#!/bin/bash
find / -type f -ignore_readdir_race -size +20M -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
On fbsd and bash:
sudo find / -type f -ignore_readdir_race -size +20M -exec ls -lh {} \; | awk '{ print $5 ": " $9 " - " $3 }'
#1
cacls d:\cygwin /T /e /g Administrators:f
rmdir /S d:\cygwin
#2
takeown /f "d:\cygwin" /r /d Y
icacls "d:\cygwin" /T /Q /C /reset