Friday, September 29, 2017

How can I disable dnsmasq listen port 53 on the Ubuntu 16.04 LTS?

By default the DNS Server of Ubuntu 16.04 LTS will be, i.e., localhost.

Therefore, system will forward DNS query to the localhost first, and forward to the DNS server which obtained from the DHCP server afterward.

Actually, I didn't prefer this method, so that I would like to turn off  this mechanism via steps were listed below:

1. Open /etc/NetworkManager/NetworkManager.conf

2. To disable dnsmasq

3. Restart NetworkManager

4. Examine /etc/resolv.conf


Friday, September 22, 2017

How can I switch multi-user or graphical mode via one command? (Systemd)

To switch multi-user to graphical mode (runlevel 3 to runlevel 5)

# systemctl set-default graphical && reboot

To switch graphical to multi-user mode (runlevel 5 to runlevel 3)

# systemctl set-default multi-user && reboot

Monday, September 18, 2017

How to know the system and service manage daemon of your Linux? (SysVinit or Systemd)

It's simple, just check your pid 1. (ps --pid 1)



Thursday, September 14, 2017

How can I backup and restore MBR via dd command?

Check device name of HD:
# lsblk

Backup MBR:
# dd if=/dev/sda of=file bs=1 count=512

1. The size of MBR is 512 bytes and located in the first sector.
2. Of cause you need to save MBR backup file somewhere else.

Restore MBR:
# dd if=file of=/dev/sda bs=1 count=512

Monday, September 11, 2017

Snap commands

Here I want to list some of snap commands that I often use.

Also here is a website to understand all of snap commands:

Log on to a snap store:
lawchiu@localhost:~$ sudo snap login of "":
Login successful

Log out snap store:
lawchiu@localhost:~$ snap logout

Update snap:
lawchiu@localhost:~$ snap refresh
All snaps up to date
List installed snap:
lawchiu@localhost:~$ snap list
Name             Version       Rev   Developer            Notes
checkbox-snappy  2.2           859   ce-certification-qa  devmode
core             16-2.27.5     2774  canonical            core
hello            2.10          20    canonical            -
pc               16.04-0.8     9     canonical            gadget
pc-kernel        4.4.0-83.106  68    canonical            kernel

Remove snap:
lawchiu@localhost:~$ snap remove hello
hello removed

Find packages:
lawchiu@localhost:~$ snap find 

Thursday, September 07, 2017

Install and use glances on Ubuntu

Glances is a great tools which able to monitor CPU, Memory, Disk, Network statistics... etc.

Please refer to glances website for details.

1. Install glances via apt:
lawrencechiu@lawrencechiu-HP-Compaq-6005-Pro-SFF-PC:~$ sudo apt-get install glances

2. Executed glances:
lawrencechiu@lawrencechiu-HP-Compaq-6005-Pro-SFF-PC:~$ sudo glances

3. Then you can see CPU usage, Memory status, SWAP, Network statistics, Disk IO, Disk usage, and PID info in one screen below:

Green means OK
Blue means CAREFUL
Purple means WARNING
Red means: CRITICAL

 a  Sort processes automatically          b  Bytes or bits for network I/O
 c  Sort processes by CPU%                l  Show/hide alert logs
 m  Sort processes by MEM%            w  Delete warning alerts
 p  Sort processes by name                  x  Delete warning and critical alerts
 i  Sort processes by I/O rate               1  Global CPU or per-CPU stats
 t  Sort processes by CPU times          h  Show/hide this help screen
 d  Show/hide disk I/O stats                T  View network I/O as combination
 f  Show/hide filesystem stats             u  View cumulative network I/O
 n  Show/hide network stats                F  Show filesystem free space
 s  Show/hide sensors stats                  g  Generate graphs for current history
 2  Show/hide left sidebar                    r  Reset history
 z  Enable/disable processes stats        q  Quit (Esc and Ctrl-C also work)
 e  Enable/disable top extended stats
 /  Enable/disable short processes name
 D  Enable/disable Docker stats


Thursday, August 31, 2017

How can I remote ssh login to the Ubuntu 16.04 LTS via root?

By default you are unable to ssh login to the Ubuntu 16.04 LTS via root, but you can enable it step by step as following:

1. Login to the system via regular user account.

2. Set password to root account (Due to root password is empty by default)
sudo passwd root
3. To modify the configuration file of sshd_config (Marked PermitRootLogin prohibit-password, and added PermitRootLogin yes )
sudo vi /etc/ssh/sshd_config
# Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password 
PermitRootLogin yes 
StrictModes yes
4. Restart sshd
 sudo systemctl restart ssh


Tuesday, August 29, 2017

Unable to logon to the Ubuntu Core with 2nd SSH public key?

After I added a new SSH public key into my Ubuntu One. However, I am unable to logon to the Ubuntu Core system with this new key, therefore I logon to the Ubuntu Core by original public key.

Afterward, I noticed that my system didn't sync up a new public key from Ubuntu One automatically.

Until now I have no idea if this is a defect or limitation, please advice, if any.

Added 2nd public key via manually into the ~/.ssh/authorized_keys

Wednesday, August 16, 2017

How to deploy Ubuntu Core from KVM to VirtualBox?

1. Download Ubuntu Core of KVM image from URL below:

2. To decompress xz.

3. To convert the format of img to the vdi via VBoxManage command below:

VBoxManage.exe convertdd ubuntu-core-16-amd64.img ubuntu-core-16-amd64.vdi
4. Import vdi file above to the VirtualBox without issue.

Wednesday, June 14, 2017


    for each_line in data:

    print('File is not existing'

透過Python的try & except,程式碼果真變得很簡潔~

Monday, May 22, 2017


今天學習了如何將Python function模組化.
1. 撰寫python, 存檔為*.py
2. 撰寫 for metadata (*.py跟setup.py需在同一個目錄下)
3. 執行python sdist 以建構發行套件檔案4. 執行python install 來安裝發行套件到本地端

開啟一個新檔案把module 用import的方式匯入, 透過引用正確的module名稱跟函式就可以執行了.

Tuesday, April 25, 2017


I saw this tools recently, and I am definitely to try it. :)


Thursday, April 06, 2017

Root file system is mounted as read only ?

I encountered this symptom and found out similar issue and solution is listed as below:

fsck -p /dev/sdX