Monthly Archives: March 2017

Linux Disk Usage

I found a good link which lists good usages of the Linux command “du”.

This command allows me to see the usage in a ascending sort which is really helpful.

Tested on Linux.
du -h / | sort -h

Tested on Mac OS.
du -hs * | gsort -h

In case you don’t have gsort install coreutils.
brew install coreutils

This variation allows me to see any line which has the text “G” in it which basically allows me to see folders using space in GBs. Agreed it might give some folder names as well with “G” in it but I can bear with it.

Tested on Linux.
du -h /the/path | sort -h | grep "G"

Tested on Mac OS.
du -h /the/path | gsort -h | grep "G" 

Setting up Sonarqube docker instance

In order to setup a fully functional Sonarqube server via docker I use the following consolidated command:


docker run \
--detach \
--name=sonarqube \
--publish 9000:9000 \
--publish 9092:9092 \
--env="SONARQUBE_JDBC_USERNAME=sonar" \
--env="SONARQUBE_JDBC_PASSWORD=sonar" \
--env="SONARQUBE_JDBC_URL=jdbc:mysql://mysql:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true" \
--link mysql:mysql \
sonarqube:5.1

This connects my dockerized mysql instance with sonar and it is able to create tables and start using MySQL properly for storing all it’s data.

Setting up MySQL docker instance

In order to setup a fully functional MySQL server via docker I use the following consolidated command:

docker run \
--detach \
--name=mysql \
--env="MYSQL_ROOT_PASSWORD=abcd1234" \
--publish 6603:3306 \
--volume=~/Docker/mysql/conf.d:/etc/mysql/conf.d \
--volume=~/Docker/mysql/mysql-datadir:/var/lib/mysql \
mysql

The advantage of the above approach is that the configuration files can be defined under ~/Docker/mysql/conf.d folder on my system and it will be picked up whenever I bootup this instance. The second thing is that all information written by this instance will be stored outside of VM in the path ~/Docker/mysql/mysql-datadir on my system. So In case this VM goes away due to some unexplained reasons I can still bootup another docker instance of MySQL and point it to this data directory.

Maven: Installing / adding local jar into your local maven repository

I needed to install a local jar file into my laptop’s local maven repository and found this article. I used this approach to install this jar file in my repo:

mvn install:install-file -Dfile=my-model-1.2.1.jar -DgroupId=com.cyberaka.my.package -DartifactId=my-model -Dversion=1.2.1 -Dpackaging=jar -DgeneratePom=true

This duly added the local jar file under appropriate group id and artifact id inside my maven repository and I was able to refer to this dependency through my project’s pom.