As the doctor gone rogue

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.

Blog at