Skip to content

Instantly share code, notes, and snippets.

@macmladen
Last active August 5, 2016 05:44
Show Gist options
  • Save macmladen/4648209 to your computer and use it in GitHub Desktop.
Save macmladen/4648209 to your computer and use it in GitHub Desktop.
*nix sys-admin
# PS1 command prompt
# Color | Code
# ------+-----
# Black 0;30 Red 0;31 Green 0;32 Brown 0;33
# Blue 0;34 Purple 0;35 Cyan 0;36
#
# http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
export PS1='\[\e[0;32m\]\u@\h:\[\e[0m\]\w \t \$ '
export PS1='\[\e[0;35m\]\w\n\[\e[0;34m\]\u@\h:\[\e[0m\]\w \t \$ '
# Display my IP
curl http://icanhazip.com
wget -qO - http://canihazip.com/s
# Add id-rsa.pub key
ssh root@system.com 'echo '`cat ~/local/id-rsa.pub`' >> ~/.ssh/authorized_keys'
# List available shells
cat /etc/shells
chsh -s /bin/fish
/bin/fish --version
# Timing scripts 2
start=`date +%s`
stuff
end=`date +%s`
runtime=$((end-start))
# Timing scripts 1
{ time sleep 1 ; } 2> time.txt
(time ls) > outfile 2>&1
# Check HDD speed, use conv to avoid cache
hdparm -tT /dev/sda
dd if=/dev/zero of=test bs=1048576 count=2048 conv=fdatasync
dd if=test of=/dev/null bs=1048576
# Explore connections http://www.linuxchix.org/content/courses/security/netstat
sudo netstat # all connections without servers
sudo netstat -pl # all active servers
# http://stackoverflow.com/questions/4421633/who-is-listening-on-a-given-tcp-port-on-mac-os-x
sudo lsof -i -n -P | grep TCP
# Bogus MIPS
cat /proc/cpuinfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment