Deleting a Partition on USB Flash Disk – Linux


I would always get the error below when trying to delete a partition on a USB flash disk:

Error deleting partition /dev/sdb2: Command-line `parted --script "/dev/sdb" "rm 2"' exited with non-zero exit status 1: Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
(udisks-error-quark, 0) 


According this answer on askubuntu, the above “was caused by a low-level device tool (like dd) writing blocks at the wrong size directly onto the device.

There are a number of solutions offered, like using dd. The safest, maybe using fdisk as described:

user@whiscardz ~ $ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sdb: 14.9 GiB, 15955132416 bytes, 31162368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x60dfafa1

Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 0 2156351 2156352 1G 7 HPFS/NTFS/exFAT
/dev/sdb2 2135488 2140031 4544 2.2M ef EFI (FAT-12/16/32)

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): d
Selected partition 2
Partition 2 has been deleted.

Command (m for help): p
Disk /dev/sdb: 14.9 GiB, 15955132416 bytes, 31162368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x60dfafa1

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


Unable to delete USB Drive partitions (Block size error)

Change MySQL root password on Windows


Needed to reset the MySQL root password on a windows machine.


Got this solution from this stack overflow answer: Resetting ROOT password in MySQL 5.6

0) shut down service mysql56

1) go to C:\ProgramData\MySQL\MySQL Server 5.6, note that ProgramData is a hidden folder (confirm this is the directory MySQL is installed on Windows by go to the Services Window and check the properties of the mysql service)

2) looking for file my.ini, open it and add one line skip-grant-tables below [mysqld],save



3) start service mysql56

4) by right, you can access the database, run mysql

5) and use the query below to update the password

update mysql.user set password=PASSWORD('NEW PASSWORD') where user='root';

6) shut down the service again, remove the line skip-grant-tables save it, and start the service again. try to use the password you set to login.


Resetting ROOT password in MySQL 5.6

Ubuntu Hash-Mismatch Error


On ubuntu 16.04 I was getting the following error when I do apt-get update:

whiscard@whiscardz ~ $ sudo apt-get update
Hit:1 xenial InRelease
Hit:2 xenial InRelease
Get:3 xenial-security InRelease [102 kB]
Get:4 xenial-updates InRelease [102 kB]
Err:13 xenial-updates/main amd64 Packages
Hash Sum mismatch
Get:14 xenial-updates/main i386 Packages [456 kB]
Fetched 821 kB in 4s (171 kB/s)
Reading package lists... Done
E: Failed to fetch Hash Sum mismatch
E: Failed to fetch
E: Failed to fetch
E: Some index files failed to download. They have been ignored, or old ones used instead.


The solution was to first clear out the local repository and then delete the contents of /var/lib/apt/lists/ and then resynchronize the package index files from their sources so:

whiscard@whiscardz ~ $ sudo apt-get clean
whiscard@whiscardz ~ $ sudo rm -rf /var/lib/apt/lists/*
whiscard@whiscardz ~ $ sudo apt-get update


How do you fix apt-get update “Hash Sum mismatch”

How do I fix APT errors “W: Failed to fetch […] Hash Sum mismatch”?

“Hash Sum mismatch” errors from apt-get when using apt-cacher-ng

Windows Server Task Scheduler Error: 2147943726


A database backup using the Task Scheduler Stopped running and it was throwing this error:

Task Scheduler failed to start “\Fence Check Rota” task for user “xxx-xxx\xxx”. Additional Data: Error Value: 2147943726.


According to this answer in the Microsoft blog, the issue could have been caused by a change in password for the user meant to run the scheduled task. Solution explained is as follows:

  • in task scheduler, click on the scheduled job properties >>> then settings
  • iin the last listed option:
    “if the task is already running, the following rule appplies:”
    select “stop the existing instance” from the drop down list.
  • when you click save you will be prompted for a password. Enter it and then exit.
  • Run the scheduled task and see if it works.


Task Scheduler failed to start. Additional Data: Error Value: 2147943726. What does this mean?


Add MySQL.cnf file to Mac OS Homebrew MySQL Install


Installed MySQL using homebrew but this did not create a my.cnf file by default.


Copied the example of my.cnf file in the cellular mysql path (/usr/local/Cellar/mysql/5.x.xx/support-files) to (/etc) having added the sql_mode explained in the MySQL 5.7 customizations

 $ cp /usr/local/Cellar/mysql/5.7.17/support-files/my-default.cnf /etc/my.cnf 

Open the my.cnf and add the sql_code variable as explained in the MySQL 5.7 customizations post.


MySQL my.cnf location on OS X?

How do I find where MySQL is loading its config from?


Manually Install Tomcat7 on Ubuntu 16.04


Tomcat7 in the Ubuntu 16.04 repository was compiled using Java8 and this caused a problem with OpenMRS that needed Java7.

This issue has been mentioned also on stackoverflow and also apache bugzilla.


The solution was to download Apache manually. I used Apache v7.0.70. You can download and extract the folder in the tmp folder:

root@whiscardz # cd /tmp/
root@whiscardz /tmp # curl -O 
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 8715k 100 8715k 0 0 2155k 0 0:00:04 0:00:04 --:--:-- 2155k

root@whiscardz /tmp # ll apache-tomcat-7.0.70.tar.gz 
-rw-r--r-- 1 root root 8924465 Jan 13 13:00 apache-tomcat-7.0.70.tar.gz
root@whiscardz /tmp # tar xzvf apache-tomcat-7*tar.gz -C /opt/tomcat --strip-components=1

root@whiscardz /tmp # ll /opt/tomcat/
total 124
drwxr-xr-x 9 root root 4096 Jan 13 13:01 ./
drwxr-xr-x 11 root root 4096 Jan 13 12:55 ../
drwxr-xr-x 2 root root 4096 Jan 13 13:01 bin/
drwxr-xr-x 2 root root 4096 Jun 15 2016 conf/
drwxr-xr-x 2 root root 4096 Jan 13 13:01 lib/
-rw-r--r-- 1 root root 56846 Jun 15 2016 LICENSE
drwxr-xr-x 2 root root 4096 Jun 15 2016 logs/
-rw-r--r-- 1 root root 1239 Jun 15 2016 NOTICE
-rw-r--r-- 1 root root 8965 Jun 15 2016 RELEASE-NOTES
-rw-r--r-- 1 root root 16195 Jun 15 2016 RUNNING.txt
drwxr-xr-x 2 root root 4096 Jan 13 13:01 temp/
drwxr-xr-x 7 root root 4096 Jun 15 2016 webapps/
drwxr-xr-x 2 root root 4096 Jun 15 2016 work/
root@whiscardz /tmp # 

Create a tomcat user and group:

root@whiscardz # groupadd tomcat
root@whiscardz # useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

cd to the directory and then change the owner and permissions and group of the files and directories:

root@whiscardz # cd /opt/tomcat/

root@whiscardz /opt/tomcat # chgrp -R tomcat conf
root@whiscardz /opt/tomcat # chmod g+rwx conf
root@whiscardz /opt/tomcat # chmod g+r conf/*
root@whiscardz /opt/tomcat # chown -R tomcat work/ temp/ logs/ 

Then check the path of Java. This will be used in the JAVA_HOME env variable only appending /jre to the end of the result.

See JAVA_HOME Environment variable in the systemd service file below:

root@whiscardz ~ # update-java-alternatives -l
java-7-oracle 1 /usr/lib/jvm/java-7-oracle 

Create a systemd service file below. Make sure to edit the JAVA_HOME;CATALINA_PID;  CATALINA_HOME; CATALINA_BASE; CATALINA_OPTS; ExecStart and ExecStop Variables to suite your environment

root@whiscardz ~ # vim /etc/systemd/system/tomcat.service

Description=Apache Tomcat Web Application Container


Environment='CATALINA_OPTS=-Xmx2048M -Xms2048M -XX:PermSize=512m -XX:MaxPermSize=512m -XX:NewSize=256m -server -XX:+UseParallelGC'




Reload the systemd daemon so that it picks up your tomcat.service file above. Then you can start tomcat. You can also stop tomcat and check if it stops.

Then you can enable the service so that it is started when the machine is rebooted :

root@whiscardz ~ # systemctl daemon-reload
root@whiscardz ~ # systemctl start tomcat

root@whiscardz ~ # systemctl stop tomcat
root@whiscardz ~ # systemctl enable tomcat 

Incase you should down tomcat using the script alone and it doesnt shutdown, check out this post.


How To Install Apache Tomcat 8 on Ubuntu 16.04

Install Apache Tomcat 9 on CentOS 7 / RHEL 7 / Ubuntu 16.04

How to Install Tomcat 7.0.68 Server on Ubuntu, Debian & LinuxMint

Tomcat shutdown does not kill process

Tomcat doesn’t stop. How can I debug this?

Tomcat 7 doesn’t shut down, process keeps running?

Apache Tomcat 8 Start stop script init.d script

Starting, Stopping, and Restarting Tomcat

Check IP on Docker Image


I had a situation where one docker image with a webserver was connecting to another docker image with a MySQL server. Now couple of other docker images were added to the server and this caused an IP change on the MySQL docker image. So I needed a way to check the New IP.


Used the following to get the IP of the docker image:

# docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)


Getting a docker container’s ip address from the host

Linux Change Timezone Terminal


Had a docker images that wasnt in the correct timezone.


For one docker image, the solution was to use:

ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

The other docker image, I used:

dpkg-reconfigure tzdata

Another way to do this is to list the timezones and then set as follows:

#timedatectl list-timezones
#timedatectl set-timezone Europe/Athens


How to change time-zone settings from the command line