Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@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 / 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 / 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 / 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 / test_64_bit.sh
Created December 8, 2015 22:58
Test if the kernel supports 64-bit
#!/bin/bash
# These commands test if the system is 64-bit. If not, a warning message in red is displayed, if it is 64-bit, x86_64 is displayed
[ 64 -eq $(arch | cut -c 5-) ] && arch || echo -e "\e[0;41mTHIS IS NOT A 64-BIT OS\e[0m"
[ 64=="$(arch | cut -c 5-)" ] && arch || echo -e "\e[0;41mTHIS IS NOT A 64-BIT OS\e[0m"
# Here is a new one, inspired by a post in this thread:
# http://unix.stackexchange.com/questions/12453/how-to-determine-linux-kernel-architecture
((1<<32)) && arch || echo -e "\e[0;41mTHIS IS NOT A 64-BIT OS\e[0m"
@forestbaker
forestbaker / keyboard_shortcuts.txt
Last active January 18, 2016 08:15
command line keyboard shortcuts
#!/bin/bash
#
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
@forestbaker
forestbaker / websites.url
Last active December 21, 2015 20:42
websites
#################
# ENTERTAINMENT #
# free movies on youtube
https://www.openculture.com/freemoviesonline
http://www.openculture.com/freeaudiobooks
https://www.openculture.com/free_textbooks
##############
# ENCRYPTION #
@forestbaker
forestbaker / check_CertExpire.sh
Created December 5, 2015 02:21
6 week check ssl certificate expiration
#!/bin/bash
# rough function of http://blog.commandlinekungfu.com/2014/06/episode-179-check-is-in-mail.html
check_CertExpire() {
for d in "$@"; do
echo -ne $d\\t;
[[ $(( $(date +%s -d "$(echo | openssl s_client -connect www.$d:443 2>/dev/null |
openssl x509 -noout -dates | tail -1 | cut -f2 -d=)") - $(date +%s) ))
@forestbaker
forestbaker / find_flavorites
Last active December 6, 2015 02:21
find flavorites - oddly useful find commands
# finds all executable files in a sub-directory - casts a wide net
find /mydir/mysubdir -executable -type f
# find all duplicates in sub-directories - slooow
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w64 --all-repeated=separate
# find dupes while excluding .svn
find -type d -name ".svn" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".svn" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w64 --all-repeated=separate
# faster dupe finder (removes 2nd find loop)
find -not -empty -type f -printf "%-30s'\t\"%h/%f\"\n" | sort -rn -t$'\t' | uniq -w30 -D | cut -f 2 -d $'\t' | xargs md5sum | sort | uniq -w32 --all-repeated=separate
@forestbaker
forestbaker / LimitFirefoxConnections
Last active November 17, 2015 07:45
limit Firefox connections
# limit Firefox connections/downloads to 8
# change values below in about:config
network.http.max-persistent-connections-per-server
network.http.max-persistent-connections-per-proxy