By default the DNS Server of Ubuntu 16.04 LTS will be 127.0.0.1:53, 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:
Steps:
1. Open /etc/NetworkManager/NetworkManager.conf
2. To disable dnsmasq
3. Restart NetworkManager
4. Examine /etc/resolv.conf
Done.
Friday, September 29, 2017
Friday, September 22, 2017
How can I switch multi-user or graphical mode via one command? (Systemd)
Monday, September 18, 2017
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
Note:
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
# lsblk
Backup MBR:
# dd if=/dev/sda of=file bs=1 count=512
Note:
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:
https://snapcraft.io/docs/reference/snap-command
Log on to a snap store:
Log out snap store:
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
lawchiu@localhost:~$
Remove snap:
lawchiu@localhost:~$ snap remove hello
hello removed
Find packages:
lawchiu@localhost:~$ snap find
Also here is a website to understand all of snap commands:
https://snapcraft.io/docs/reference/snap-command
Log on to a snap store:
lawchiu@localhost:~$ sudo snap login xxx.xxx@gmail.comPassword of "xxx.xxx@gmail.com":
Login successful
Log out snap store:
lawchiu@localhost:~$ snap logout
Update snap:
lawchiu@localhost:~$ snap refreshList installed snap:
All snaps up to date
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
lawchiu@localhost:~$
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.
Steps:
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
Hotkey:
Please refer to glances website for details.
Steps:
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
Hotkey:
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
Enjoy~
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)
Done.
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 root3. 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
Done.
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.
Workaround:
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.
Workaround:
Added 2nd public key via manually into the ~/.ssh/authorized_keys
Wednesday, August 16, 2017
How to deploy Ubuntu Core from KVM to VirtualBox?
Steps:
1. Download Ubuntu Core of KVM image from URL below:
https://developer.ubuntu.com/core/get-started/kvm
2. To decompress xz.
3. To convert the format of img to the vdi via VBoxManage command below:
1. Download Ubuntu Core of KVM image from URL below:
https://developer.ubuntu.com/core/get-started/kvm
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.vdi4. Import vdi file above to the VirtualBox without issue.
Wednesday, June 14, 2017
Python的額外錯誤處理
Example:
try:
data=open('open_file.txt')
for each_line in data:
try:
(var1,var2)=each_line.split(":",1)
print(var1)
print(var2)
except:
print(each_line)
data.close()
except:
print('File is not existing')
透過Python的try & except,程式碼果真變得很簡潔~
Monday, May 22, 2017
如何將Python程式模組化?
今天學習了如何將Python function模組化.
實際的步驟:
1. 撰寫python, 存檔為*.py
2. 撰寫setup.py for metadata (*.py跟setup.py需在同一個目錄下)
3. 執行python setup.py sdist 以建構發行套件檔案4. 執行python setup.py install 來安裝發行套件到本地端
開啟一個新檔案把module 用import的方式匯入, 透過引用正確的module名稱跟函式就可以執行了.
Tuesday, April 25, 2017
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:
http://www.unix.com/linux/168716-root-filesystem-goes-readonly.html
Method:
http://www.unix.com/linux/168716-root-filesystem-goes-readonly.html
Method:
fsck -p /dev/sdX
Subscribe to:
Posts (Atom)