Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@forestbaker
forestbaker / mpstat_iostat.txt
Created December 20, 2015 04:47
how to use mptstat and iostat to gather statistical information about CPU, RAM and Disk usage.
### mpstat command ###
# all cpu utilization
mpstat -A
# processor utilization by CPU
mpstat -P 0
mpstat -P 1
# gather multiple reports over time
@forestbaker
forestbaker / fix_grub_hidden_timeout_warning.sh
Last active January 14, 2016 15:56
Resolves a warning message often seen when updating Linux: "Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported."
#!/bin/bash
if [ -f /etc/default/grub ]; then
sed -i '/GRUB_HIDDEN_TIMEOUT=/s/^/#/g' /etc/default/grub
update-grub
fi
exit 0
@forestbaker
forestbaker / rename.sh
Created January 14, 2016 16:14
bulk renaming files just got a whole lot easier...
#!/bin/bash
rename -vs
# usage:
# rename oldfilename newfilename *filepattern
# example:
# rename files in present directory ending with .htm to .html
@forestbaker
forestbaker / distro_discovery.txt
Created January 14, 2016 18:56
one off file names for specific distros
Novell SuSE
/etc/SuSE-release
Red Hat
/etc/redhat-release, /etc/redhat_version
Fedora
/etc/fedora-release
Slackware
@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
@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 / 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 / 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 / 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 / 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: