Last active
January 27, 2016 22:55
-
-
Save forestbaker/a769d77b9903ac812fe0 to your computer and use it in GitHub Desktop.
Brevis pimentorum que in domo esse debeant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 88 | |
echo '=======================================================================================' | |
# 80 | |
echo '===============================================================================' | |
# 75 | |
echo '==========================================================================' | |
# 72 | |
echo '=======================================================================' | |
# 70 | |
echo '=====================================================================' | |
# one megabyte is one million bytes | |
# (2^10)^2 | |
declare -rx LIMIT_64MB=$(( 1048576 * 64 )) | |
# display applications using ipv6 | |
netstat -lp -6 | |
# use paste instead of tr to pretty print a list into a row | |
dpkg -l | grep sasl | awk '{print$2}' | paste -sd' ' | |
# use column to evenly justify a space or tab delimited file | |
column -t file1 | |
# use column to evenly justify a csv file | |
column -t -s, file2 | |
# Get the process id of a process | |
pidof $1 | |
pgrep $1 | |
# Use "date +$DATE4FILE" to create a file name based on the time | |
DATE4FILE='%Y%m%d%H%M%S' | |
# easier to read | |
DATE4READ='%Y-%m-%d_%H:%M:%S' | |
# outputs 'servername was restarted x days ago' | |
echo "$HOSTNAME was restarted $(uptime | tr , ' ' | awk '{print $3" "$4}') ago" | |
# trim some fat | |
| head -2 | tail -1 | |
# find newish files | |
touch -t "$(date '+%Y%m%d0000')" datestamp && find / -newer ./timestamp -print | |
# check the existence of a named process | |
[ "$(type -t type)" ] && echo true || echo false | |
# display users home directory path | |
grep $USER /etc/passwd | cut -d: -f 6 | |
getent passwd $UID | cut -d: -f 6 | |
# display users default shell | |
getent passwd $UID | cut -d: -f3,7 | grep "^${UID}:" | |
echo $SHELL | |
echo $BASH_VERSION | |
cat /proc/$$/cmdline | |
ls -l /proc/$$/exe | |
# track start and end time of a script | |
start="$(date +%s)" | |
end="$(date +%s)" | |
diff="$(expr $end - $start)" | |
echo "Started at $start : Ended at $end" | |
echo "Elapsed time = $diff seconds" | |
# same as above with bash builtin | |
# echo "$BASH_SECONDS" | |
# duration of visitation by IP | |
grep "^12.106.111.10 " access_log | grep -vw css | grep -vw gif | grep -vw jpg | grep -vw png | grep -vw ico | awk '{ print $4,$7 }' | cut -c2- | |
grep "^12.106.111.10 " /var/log/apache2/access_log | egrep -vw 'css|gif|jpg|png|ico' | awk '{ print $4,$7 }' | cut -c2- | |
# unique visitors | |
cut -d" " -f1 /var/log/apache2/access_log | sort -u | |
# display width of terminal | |
echo "$(stty size | cut -d" " -f2)" | |
# /usr/openwin/bin/resize sets COLUMNS | |
echo "$COLUMNS" | |
# display threads associated with a PID | |
ps -e -T | grep $(pidof firefox) | |
# count them | |
ps -e -T | grep $(pidof firefox) | wc -l | |
# limit cpu use usage of a running process | |
## -l is the limit from 0 to 100 | |
cpulimit -p PID -l 50 | |
# limit using path to the executable | |
cpulimit -P /usr/bin/whoami -l 50 | |
# make a copy of the repositories used for installation of packages | |
cp /etc/apt/sources.list $HOME/repo_sources.list | |
# display list of installed packages | |
dpkg --get-selections | egrep -v 'deinstall|hold|purge' | awk '{print $1}' | |
# output list of installed packages to a file | |
dpkg --get-selections | egrep -v 'deinstall|hold|purge' > installedpackages.txt | |
# install packages from a file | |
apt-get update | |
dpkg --set-selections < installedpackages.txt | |
apt-get dselect-upgrade | |
# oneliner install packages from a file | |
cat installedpackages.txt | xargs -a installedpackages.txt sudo aptitude install | |
# install packages onto a computer without internet from a cd or thumbdrive | |
apt-get install aptoncd | |
# benchmark hdd | |
hdparm -t /dev/sda | |
# storage space used by directory - alias? | |
du -s * 2>/dev/null | sort -n | cut -f2 | xargs du -sh 2>/dev/null | |
# install 64bit tor browser | |
wget https://www.torproject.org/dist/torbrowser/5.5/tor-browser-linux64-5.5_en-US.tar.xz | |
tar -xvJf tor-browser-linux64-5.5_en-US.tar.xz | |
cd tor-browser_en-US | |
./start-tor-browser.desktop | |
# install 32bit tor browser | |
wget https://www.torproject.org/dist/torbrowser/5.5/tor-browser-linux32-5.5_en-US.tar.xz | |
tar -xvJf tor-browser-linux32-5.5_en-US.tar.xz | |
cd tor-browser_en-US | |
./start-tor-browser.desktop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment