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.

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

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