Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Last active November 20, 2015 06:34
Show Gist options
  • Save forestbaker/c4b1e81dca1796b91bb3 to your computer and use it in GitHub Desktop.
Save forestbaker/c4b1e81dca1796b91bb3 to your computer and use it in GitHub Desktop.
favorite flavorites
# # Includes perfect date perfected. The uses go beyond backups, beyond space and time ... ok not time.
# # Creates a directory structure of ./YYYY/mm/dd/HH/MM/SS
mkdir -p "$(date '+%Y/%m/%d/%H/%M/%S')"
# enDIRing elegant epoch
# # -p is optional - unless co-processing!
# # the " and ' are also optional, but "'safer'"
# # for scripting, do set the epoch in a variable, reference that variable - write once read many and yer done!
mkdir -p "$(date '+%s')"
declare -rx DATE_TIME=$(date '+%Y%m%d%H%M%S')
declare -rx YEAR=${DATE_TIME:0:3}
declare -rx MONTH=${DATE_TIME:4:5}
# add timestamp to history
export HISTTIMEFORMAT='+%Y%m%d_%H%M%S '
# append to dotfile
echo "export HISTTIMEFORMAT='+%Y%m%d_%H%M%S '" >> $HOME/.bashrc
# display single column of filenames - uses number '1' not lowercase 'l'
ls -1
# create an IP alias
/sbin/ifconfig eth0:1 192.168.3.33
# make a backup - creates foo.bak
cp /path/to/foo{,.bak}
# display value of IFS
echo $IFS | cat -vte
#top 10 largest files sorted - common cmd to use
du -sk * | sort -nr | head
# same result with one less option used for sort
du -sk * | sort -n | tail
# test it first, it will remove files ...
# tomcat file refresher
updatedb && service tomcat6 stop && for BLORP in locate *.war; do rm -rf ${BLORP%.war} && touch ${BLORP} && chmod -x ${BLORP}; done && service tomcat6 start
# check if ipv6 is off or on
# return 1 = ipv6 is disabled
# return 0 = ipv6 is enabled
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
# find applications that bind to ipv6 ports
netstat -lnp | egrep 'tcp6|udp6'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment