| by Scott Kilroy

Build your docker image

docker build -t GROUPNAME/DOCKERPAGENAME:VERSION DIRECTORY so for example docker build -t example/ docker-node-hello:latest .

Read More
| by Scott Kilroy

Installing docker

If you’re using linux you can install docker by doing the following: ubuntu apt-get install docker.io sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker Fedora yum -y install docker-io Mac OSX Install the docker toolbox Windows Also has a tool box but I’ve never used it. Docker Cheatsheet https://github.com/wsargent/docker-cheat-sheet

Read More
| by Scott Kilroy

Amazon – recommended repo

The default repos for Amazon’s Centos are lacking a lot.  Add this repo to the default Amazon Centos setup. in /etc/yum.repos.d/ius.repo comment out: mirrorlist=http://dmirr.iuscommunity.org/mirrorlist?repo=ius-el5&arch=$basearch add: baseurl=http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/$basearch

Read More
| by Scott Kilroy

Updating Drupal

The best way to handle minor updates is to first back everything up (your web directory and your database) then download the new version of drupal to a directory (lets use ~/drupalupdate as the download directory and /var/www/html as the webdirectory) cd into the download directory and run the following command find * -type f -exec echo cp {} /var/www/html/{} \; This one just test everything and echos what it would really do.  If everything looks good run find * […]

Read More
| by Scott Kilroy

Print the total bytes of files in a directory grouped by date

ls -l|awk ‘length($6)==3{x[$6″ “$7]+=$5};END{for(i in x)printf”%s:\t%d\n”,i,x[i]}’

Read More
| by Scott Kilroy

Optimize and repair all mysql tables

mysqlcheck -o -u root -p –all-databases

Read More
| by Scott Kilroy

Reset the mysql root password

Stop the mysql daemon Restart mysql using the command mysqld_safe –skip-grant-tables Now you should be able to connect as root Once connected run the following: update user set Password=PASSWORD(‘new-password’) where user=’root’; then flush privileges exit mysql restart mysql and you should be able to login with the new password

Read More
| by Scott Kilroy

See all open ports

lsof -i TCP| fgrep LISTEN

Read More
| by Scott Kilroy

Remove top navbar from wordpress

Edit wp-includes/functions.php and add the following add_action(‘after_setup_theme’, ‘remove_admin_bar’); function remove_admin_bar() { if (!current_user_can(‘administrator’) && !is_admin()) { show_admin_bar(false); } } Now the top navbar will only showup for admin users.

Read More
| by Scott Kilroy

Find the largest file in a directory tree

find /path -type f -exec ls -s {} \; | sort -n | tail -1

Read More
| by Scott Kilroy

Compress the contents current directory, but compress the smallest files first

ls -s | awk NR!=1 | sort -n | awk ‘{print $2}’ | xargs bzip2 -9v

Read More
| by Scott Kilroy

Using netstat

netstat -ntulp displays everything that is listening tcp and udp and the ip that it is listening on

Read More
| by Scott Kilroy

View network traffic (by port number)

To view web traffic (for example) use tcpdump -s 0 -w – port 80 | tcpdump -r – -A

Read More
| by Scott Kilroy

VIM guide

A good basic starting point for using Vim is http://www.pixelbeat.org/vim.tips.html

Read More
| by Scott Kilroy

Filter duplicate lines from a sorted files

cat list-1 list-2 list-3 | sort | uniq > final.list

Read More
| by Scott Kilroy

Debugging bash scripts

Debugg bash scripts by runing with option -x example bash -x scriptname.sh

Read More
| by Scott Kilroy

lowercase filen names

#! /bin/bash DIR=$1 for a in `ls $DIR` do fname=`echo $a | tr A-Z a-z` mv $DIR/$a $DIR/$fname done; exit 0

Read More
| by Scott Kilroy

Kill all process associated with a user

skill -TERM -u USERNAME

Read More
| by Scott Kilroy

Force a user off the system

slay USERNAME

Read More
| by Scott Kilroy

Linux Security

“Yes, I’m paranoid — but am I paranoid enough?” ― David Foster Wallace, Infinite Jest Hardening Public Servers Install system accounting On Debian based systems run ‘apt-get install acct’ then you can use commands lastcomm and sa to see who ran various comands. Also a log file will be writen to /var/log/account/pacct Remove compilers from production severs use the command ‘apt-get –purge remove gcc’ Setup remote logging See http://www.thegeekstuff.com/2012/01/rsyslog-remote-logging/ to find out how Install fail2ban Linux.com has a good intro to fail2ban http://www.linux.com/learn/tutorials/469597-weekend-project-keep-out-repeat-offenders-with-fail2ban-on-linux

Read More