As the doctor gone rogue

October 18, 2016

Add/Remove user from a group

Filed under: bash, SysAdmin, ubuntu — hypotheses @ 3:15 am

  • Add a user bhoom to an existing group superman: sudo usermod -A -g superman bhoom
  • remove bhoom from a group superhero: sudo gpasswd -d superhero bhoom
  • Create a new group legends:sudo groupadd legends

October 15, 2016

Find files and listing details on Linux

Filed under: bash, miscellaneous, ubuntu — Tags: , , , , , — hypotheses @ 12:01 pm

One common task that we always have to do relatively often is to find the location of some specific files. Although you may have some clues that those files are located in your current working directory, “.” symbolic link used in the command below, you may have no clue to which sub-folder your files are.


September 8, 2016

value too great for base ?!

Filed under: bash — hypotheses @ 11:11 pm

So, I wrote a script trying to get it to output the previous month as a number with a leading “0”. The problem arrives as bash complains of some errors.

Initially, my script looked like this

MO=$(date '+%m')
P_MONTH=$(printf "%0*d\n" 2 $MO2);

The last line is there so that I still get a numeric month with a leading zero. However, this for some reasons, gave the error “value too great for base”.

After trying to figure out what it actually means, the base here is the numeric base, which bash thinks number with leading “0” is octal.
So, the solution to fix this is to reassure that the ${MO} variable, which is the numeric Month is a base-10 number.

You can achieve this as follow

MO=$(date '+%m');MO=$((10#$MO))
P_MONTH=$(printf "%0*d\n" 2 $MO2);

April 27, 2016

Encrypt a few files or folder on OsX

Filed under: bash, miscellaneous, OsX, SysAdmin — hypotheses @ 4:00 pm

May be you are working on a sensitive data, or just want to secure your personal data on your personal computers. Mac offers the whole hard disk encryption when you install the system, as well as, encryption of your backup through “Time Machine”. However, there are times that you might want to add an extra security to your file. May be you save some of the files to Dropbox or Google Drive, and the file might contain your personal health information that you would not want just anyone to be able to simply read it.

There’s a simple tool in OsX that can help you do this.

zip -e [] [file-to-be-encrypt]

zip utility will ask you to create a password. The stronger the password. The harder it will be to crack it. However, make sure you will remember the password, too. For this reason, I recommend you to use a password manager, e.g. LastPass is one of an excellent and easy to use tool with several browser integration for both mobile device and personal computer.

Just for the peace of mind. The encryption algorithm in zip might not be very strong. But at least, you save some disk space, and there’s one more extra-security of a password protection that you have to go through before accessing the content of the file.

April 24, 2016

Write a Ubuntu Linux USB boot disk

Filed under: miscellaneous, OsX, SysAdmin, ubuntu — hypotheses @ 8:47 pm

Getting the Linux Image

You’ll get an iso file from your preferred repository. Following the link to the Ubuntu mirror at KMUTT in Thailand.
Ubuntu 14.04.4 LTS (Trusty Tahr)
Ubuntu 16.04 LTS Xenial Xerus

Convert iso to img

hdiutil convert -format UDRW -o ubuntu-16.04-server-amd64.img ubuntu-16.04-server-amd64.iso

See man hdiutil for detail about the command

Create a bootable USB drive

  • plug the USB drive into your computer and find out which mount point it is mounted to.
diskutil list

This will show the list of all drives mounted to your system right now. The description of which drive is a UBS drive should be quite clear.
– Unmount the disk before we proceed to write a bootable image on it.

# unmount it
diskutil unmount /dev/disk2
  • copy the disk image to your usb drive.
sudo dd if=ubuntu-16.04-server-amd64.img.dmg of=/dev/rdisk2 bs=1m

With /dev/rdisk2 instead of /dev/disk2, you are writing the raw data to the USB drive which will be several folds faster than writing through the buffered /dev/disk2 [ref]

Eject the USB drive

  • After writing the image, a diaglog box will alert you that the disk is not readable. Simple eject the disk.
  • Alternatively, at the command diskutil eject /dev/disk2

April 15, 2016

Set sleep time (OsX)

Filed under: OsX, SysAdmin — Tags: , — hypotheses @ 2:10 pm

Find the current sleep time

sudo systemsetup -getcomputersleep

Disable sleep time

sudo systemsetup -setcomputersleep Never


Set sleep time to specificN minutes

sudo systemsetup -setcomputersleep 60

This will set the sleep time to  60 minutes.

If you prefer to do this from the GUI, go to System Preference > Energy Saver and choose the desire time to sleep.


April 14, 2016

How to reset a root password?

Filed under: miscellaneous, ubuntu, Virtual Machine — Tags: , , — hypotheses @ 5:52 am

What do you do when you forget the “root” account password?
Install new OS is not always a good idea. As long as you still have physical access to the computer, it is somewhat possible to try the followings. Depending on whether you are working with Mac or Linux. See the detail and additional reference through the links below.
  1. Restart the Mac while holding down the Option key, and double-click the icon for the Recovery partition. …
  2. Choose Utilities > Terminal.
  3. In Terminal, type resetpassword .
  1. Reboot your computer.
  2. Hold Shift during boot to start GRUB menu.
  3. Highlight your image and press E to edit.
  4. Find the line starting with “linux” and append rw init=/bin/bash at the end of that line.
  5. Press Ctrl + X to boot.
  6. Type in passwd username.
  7. Set your password.

November 27, 2015

Appending multiple vcf

Filed under: Uncategorized — Tags: , , — hypotheses @ 12:10 am

If you have multiple vcf files split by chromosome from the same samples, this is the case when performing joint variant calls of multiple samples in GATK. At the end of the day, if you want to have a single vcf file from this project, CatVariants tool (a command line tool in GATK) is pretty fast. Although I think this might be just the case of simple cat of multiple files except the vcf header, this tools still come in handy especially when you already have GATK installed. (more…)

Failed to set default locale

Filed under: R — Tags: , — hypotheses @ 12:00 am

If Rstudio complains about failure to set default locale,

try this

$ defaults write org.R-project.R force.LANG=en_US.UTF-8

November 3, 2015

Add exising users to an existing group in Ubuntu

Filed under: ubuntu — Tags: , — hypotheses @ 1:22 am

sudo usermod -a -G groupName userName
« Newer PostsOlder Posts »

Create a free website or blog at