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 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 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)

# system 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)

SysVinit:


Systemd:





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


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:
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 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
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:
 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)
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

Done.