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~