Category Archives: HowTo

Set the HostName and Computer Name via command line on OS X

Work recently acquired a few MacBook laptops to be used and shared by staff. Though the computing staff is not expected to have immense knowledge about OS X,  when things break down we are the first point of contact.

The last time I used a Mac machine extensively was around 2007. Then I switched to Debian and could never look back. Anyway, there must be lot of new things and I’ll try document or post snippets here as I learn new things.

The first one for today is to set the hostname and computer name from a command line.

$ export PC_NAME="macarena"
$ sudo scutil --set ComputerName "$PC_NAME" && \
$ sudo scutil --set HostName "$PC_NAME" && \
$ sudo scutil --set LocalHostName "$PC_NAME"

Reference: OS X – Set the HostName, Computer Name, and Bonjour Name via command line

Build Docker Client for ARMv8

The other day, after successfully building Docker-ce 17.06.0-dev for Odroid C2 which has ARMv8 CPU, i couldn’t find Docker client. Maybe it was just me not building the Docker engine correctly.

Anyway, after some more times, I also managed building the Docker client for the Odroid C2. It turned out, like many things, it wasn’t that  hard after you figured it out. It’s worth to note too that the build instruction on is to use Docker container. It didn’t work for me, and I decided to just build the Docker cli locally on the Odroid C2 instead.

First clone the repository:

$ go get
can't load package: package no Go files in /home/kenno/dev/gowork/src/

So what just happened? Instead of running git clone, I use go get command to pull the code from the repo to a path in $GOPATH, since I’m going to build it using go anyway.

Next we can just build it:

$ cd $GOPATH/src/
go build

When it’s finished, we can run the Docker cli:

Notice that we the Version, “Git commit”, and “Built” fields are set to unknown.

 Version:      unknown-version
 Git commit:   unknown-commit
 Built:        unknown-buildtime

Is there something we can do about? Yes, we can!

$ cd $GOPATH/src/
$ source $GOPATH/src/
$ go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"

After the compilation, the Docker cli binary file can be found in ./build directory.

Let’s run it again:

The Version field is still “unknown-version”. This makes sense as we build the code from the master branch.

Changing a User’s Password on FreeBSD

Before getting into how to change a user’s password on FreeBSD, let’s have a quick revision on how that can be done on a Linux system.

As a user we can change the password by typing:

$ passwd
Changing password for user kenno.
Changing password for kenno.
Current password: 

Or with a root account, we can change/set the password for another user:

# passwd kenno
Changing password for user kenno.
New password: 

How about a FreeBSD? It should be the same way as how it’s done on Linux right? Right? Well, not quite.

On a FreeBSD system, in addition to run the passwd command, we also need to generate the password databases to be “in sync” with the plain text files.

# pwd_mkdb /etc/master.passwd

You can learn more about both passwd and pwd_mkdb, by running:

$ man passwd
$ man pwd_mkdb

Ref: Can’t change user password

How to remove a user password

Sure, you Linux gurus must be laughing at me to see this post. However, this is my 2nd time needing to remove a user’s password and I had to Google for it! So here is just a quick tip to mind your truly:

# passwd -d your_username

In case you’re wondering why I need to remove a password for an account, it’s for my 4 year old daughter who enjoys playing supertuxcart. She wants to have her own user account on a Fedora 24 box without a password.


Fix corrupted GPT on FreeBSD

One of the disks in my FreeBSD server reported an issue:

Jul 14 18:00:56 nas kernel: GEOM: da0: the primary GPT table is corrupt or invalid.
Jul 14 18:00:56 nas kernel: GEOM: da0: using the secondary instead -- recovery strongly advised.
Jul 14 18:00:56 nas kernel: GEOM: diskid/DISK-67304734999999999999: the primary GPT table is corrupt or invalid.
Jul 14 18:00:56 nas kernel: GEOM: diskid/DISK-67304734999999999999: using the secondary instead -- recovery strongly advised.

To verify it, first I used gdisk command:

root@nas:~ # gdisk /dev/da0
GPT fdisk (gdisk) version 0.8.10

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.

Command (? for help): q

An alternative way to verify this is to use gpart command:

root@nas:~ # gpart show da0
=>       34  976773101  da0  GPT  (466G) [CORRUPT]
         34  976773101       - free -  (466G)

I think it’s possible use gdisk to repair the corrupted GPT table, but I tried gpart and it worked:

nas:~ # gpart recover /dev/da0
da0 recovered
root@nas:~ # gpart show da0
=>       34  976773101  da0  GPT  (466G)
         34  976773101       - free -  (466G)