Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@forestbaker
forestbaker / ufw_commands.sh
Created August 29, 2016 20:48
UFW commands
# Check UFW Firewall rules:
ufw status
ufw status numbered
ufw status verbose
# Enable UFW logging:
ufw logging (on|off|low|medium|high|full)
ufw logging on = ufw logging low
# Insert a rule at position 1
@forestbaker
forestbaker / disable_ipv6_linux.sh
Created August 29, 2016 20:47
disable IPv6 on linux
# Disable IPv6 in ufw
sed -i 's/^IPV6=YES/IPV6=NO/I' /etc/default/ufw
disable ufw; enable ufw
@forestbaker
forestbaker / Useful_MySQL_Queries.sql
Created August 29, 2016 20:45
Useful MySQL Queries
# Display Storage Space used by Tables in a MySQL Database called "DiagDomain":
SELECT table_name AS "Tables", round(((data_length + index_length)/1024/1024/1024), 2) "Size in GB" FROM information_schema.TABLES WHERE table_schema = "DiagDomain" ORDER BY (data_length + index_length) DESC;
# Display Storage Space used by all MySQL Databases:
SELECT table_schema "database", sum(data_length + index_length)/1024/1024/1024 "Size in GB" FROM information_schema.TABLES GROUP BY table_schema;
@forestbaker
forestbaker / READ_FPDMA_QUEUED.sh
Created August 29, 2016 20:40
Got “READ FPDMA QUEUED” errors from “dmesg” output
# Got “READ FPDMA QUEUED” errors from “dmesg” output
# Likely have an issue with the hard disk controller driver
# resolve by disabling NCQ
echo 1 > /sys/block/sdX/device/queue_depth
# verify if NCQ is enabled
# returned value will be higher than “1”
cat /sys/block/sdX/device/queue_depth
@forestbaker
forestbaker / keybase.md
Created August 19, 2016 16:00
keybase public key to authenticate my digital identity

Keybase proof

I hereby claim:

  • I am forestbaker on github.
  • I am forestbaker (https://keybase.io/forestbaker) on keybase.
  • I have a public key whose fingerprint is 342E AAB2 572D 6739 3A3E ED4C 26FD 1568 3381 4EBA

To claim this, I am signing this object:

@forestbaker
forestbaker / dumping_core_captain.sh
Last active March 1, 2016 05:54
when you want to run programming marathon, first take a core dump
#!/bin/bash
#pseudo
if $(ulimit -c)
then
ulimit -c unlimited
mkdir -m 1777 -p /var/log/dumps
echo "kernel.core_pattern=var/log/dumps/core.%e.%p" >> /etc/sysctl.conf
# echo “/var/log/dumps/core.%e.%p” > /proc/sys/kernel/core_pattern
@forestbaker
forestbaker / fix_dis_LC_ALL
Last active February 29, 2016 21:22
Error message on apt-get auto-remove
issue:
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
identify:
locale -a
will return error message as above and options for locale settings, choose any of the available options.
selecting C reduces shell execution time.
@forestbaker
forestbaker / no_public_key_available.sh
Last active February 26, 2016 03:32
“no public key available” on apt-get update
#!/bin/bash
# “no public key available” on apt-get update
sudo aptitude install debian-keyring debian-archive-keyring
http://mirrors.cat.pdx.edu jessie
@forestbaker
forestbaker / shell_exit_codes.sh
Last active January 21, 2016 06:46
shell exit code numbers, meanings, examples and comments
#!/bin/sh
header='"Exit_Code_Number","Meaning","Example","Comments"'
"1","Catchall for general errors","let 'var1 = 1/0'","Miscellaneous errors, such as 'divide by zero' and other impermissible operations"
"2","Misuse of shell builtins (according to Bash documentation)","empty_function() {}","Missing keyword or command, or permission problem (and diff return code on a failed binary file comparison)"
"126","Command invoked cannot execute","/dev/null","Permission problem or command is not an executable"
"127","command not found","illegal_command","Possible problem with $PATH or a typo"
"128","Invalid argument to exit","exit 3.14159","exit takes only integer args in the range 0 - 255 (see first footnote)"
"128+n","Fatal error signal 'n'","kill -9","$PPID of script $? returns 137 (128 + 9)"
"130","Script terminated by Control-C","Ctl-C","Control-C is fatal error signal 2, (130 = 128 + 2, see above)"
@forestbaker
forestbaker / cron_cheat_sheet.txt
Last active November 16, 2017 10:30
cron timing cheat sheet
#kudos: Alain Kelder
#+--------------- minute (0-59)
#| +------------- hour (0-23)
#| | +----------- day of month (1-31)
#| | | +--------- month (1-12)
#| | | | +------- day of week (0-7), 0=Sunday
#| | | | | user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly