Ubuntu 18.04 ใน VirtualBox

ติดตั้ง Ubuntu 18.04 ใน VirtualBox แล้วลง Guest Addition แต่พอ reboot แล้วปรับขนาดหน้าจอไม่ได้ และขึ้น Error ว่า

VBoxClient the VirtualBox kernel service is not running. 

ลองดู /var/log/vboxadd-setup.log เจอว่า

modprobe vboxguest failed

ให้แก้ไขด้วยคำสั่ง

sudo apt-get install dkms build-essential linux-headers-$(uname -r)

restart แล้วก็น่าจะใช้ได้ปกติละ

ติดตั้ง Graphviz บน Ubuntu 18.04

ติดตั้ง Graphviz

sudo apt install graphviz
sudo yum install graphviz

ดูเวอร์ชันที่ติดตั้ง

$ dot -V
dot - graphviz version 2.40.1 (20161225.0304)

ทดลองใช้งานทาง Command Line

echo 'digraph { a -> b }' | dot -Tsvg > output.svg
echo 'digraph { a -> b }' | dot -Tsvg -o output.svg

ใส่ข้อความและกำหนดสีของข้อความ (set a graph attribute -Gname[=value])

echo 'digraph { a -> b }' | dot -Tsvg -Gfontcolor=red -Glabel="My favorite letters" > output2.svg

กำหนดรูปแบบของโหนด (set a default node attribute -Nname[=value] )

echo 'digraph { a -> b }' | dot -Tsvg -Nfontcolor=red -Nshape=rect > output3.svg

กำหนดรูปแบบของ edge และลูกศร (set a default edge attribute -Ename[=value])

บันทึกไฟล์ output เป็น png หรือฟอร์แมตอื่นๆดู supported formats

echo 'digraph { a -> b }' | dot -Tpng -Ecolor=red -Earrowhead=diamond > output4.png

ติดตั้ง obsfs บน Ubuntu 18.04

!! ใช้ Huawei obsutil tool ดีกว่า !!

ดาว์นโหลด obsfs จาก Developer Tools จะได้ไฟล์ติดตั้งสำหรับ Ubuntu 14.04

วิธีติดตั้ง Introduction to obsfs, Method 1: Downloading and Installing obsfs, Method 2: Generating obsfs by Compilation

wget https://obs-community-intl.obs.ap-southeast-1.myhuaweicloud.com/obsfs/current/obsfs_Ubuntu14.04_amd64.tar.gz

แตกไฟล์

tar -zxvf obsfs_Ubuntu14.04_amd64.tar.gz

ติดตั้ง obsfs

sudo ./install_obsfs.sh

ลองเรียกใช้งานจะ error

sudo obsfs
obsfs: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by obsfs)

ให้ติดตั้ง libcurl3

sudo apt-get install libcurl3 -y

ลองเรียกใช้อีกทีจะใช้ได้ละ

sudo obsfs
obsfs: missing BUCKET argument.
Usage: obsfs PFS:[PATH] MOUNTPOINT [OPTION]...
sudo obsfs --version
Huawei Object Storage Service File System V 3.19.7

ติดตั้ง vsftpd บน Ubuntu 18.04

vsftpd – FTP Server Installation
vsftpd is an FTP daemon available in Ubuntu.

$ sudo apt install vsftpd

Anonymous FTP Configuration
By default vsftpd is not configured to allow anonymous download. If you wish to enable anonymous download edit /etc/vsftpd.conf by changing:

anonymous_enable=Yes

During installation a ftp user is created with a home directory of /srv/ftp. This is the default FTP directory.

If you wish to change this location, to /srv/files/ftp for example, simply create a directory in another location and change the ftp user’s home directory:

sudo mkdir /srv/files/ftp
sudo usermod -d /srv/files/ftp ftp

After making the change restart vsftpd:

sudo systemctl restart vsftpd.service

Finally, copy any files and directories you would like to make available through anonymous FTP to /srv/files/ftp, or /srv/ftp if you wish to use the default.

กำหนดให้สามารถ upload ไฟล์เข้ามาได้

แก้ไขไฟล์ /etc/vsftpd.conf

write_enable=YES

เสร็จแล้ว restart vsftpd:

sudo systemctl restart vsftpd.service

Link

ติดตั้ง MySql บน Ubuntu 18.04

1.Installing MySQL

sudo apt update
sudo apt install mysql-server

2.Configuring MySQL

sudo mysql_secure_installation

In order to use a password to connect to MySQL as root, you will need to switch its authentication method from auth_socket to mysql_native_password. To do this, open up the MySQL prompt from your terminal:

sudo mysql

Next, check which authentication method each of your MySQL user accounts use with the following command:

SELECT user,authentication_string,plugin,host FROM mysql.user;
Output
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;

Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:

SELECT user,authentication_string,plugin,host FROM mysql.user;
Output
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             | *3636DACC8616D997782ADD0839F92C1571D6D78F | mysql_native_password | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

ทีนี้ก็จะ login ด้วย $ mysql -u root -p ได้ละ

3.Adjusting User Authentication and Privileges

$ mysql -u root -p
mysql> GRANT ALL ON *.* TO 'sammy'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;

4.Testing MySQL

$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-02-06 15:32:25 +07; 17min ago
 Main PID: 3831 (mysqld)
    Tasks: 28 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─3831 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

ถ้า mysql ไม่ start ให้ start ด้วย

$ sudo systemctl start mysql 

ดูเวอร์ชันของ mysqladmin

$ sudo mysqladmin -p -u root version
Enter password: 
mysqladmin  Ver 8.42 Distrib 5.7.29, for Linux on x86_64
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version		5.7.29-0ubuntu0.18.04.1
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/run/mysqld/mysqld.sock
Uptime:			18 min 31 sec

Threads: 1  Questions: 21  Slow queries: 0  Opens: 113  Flush tables: 1  Open tables: 106  Queries per second avg: 0.018

ติดตั้ง Nginx บน Ubuntu 18.04

1.Installing Nginx

$ sudo apt update
$ sudo apt install nginx

2.Adjusting the Firewall

$ sudo ufw app list
Available applications:
  CUPS
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  • Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
  • Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
  • Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
$ sudo ufw allow 'Nginx Full'
$ sudo ufw allow 'Nginx HTTP'
$ sudo ufw status
Status: inactive
$ sudo ufw enable
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
Nginx Full                 ALLOW       Anywhere
Nginx HTTP                 ALLOW       Anywhere
Nginx Full (v6)            ALLOW       Anywhere (v6)
Nginx HTTP (v6)            ALLOW       Anywhere (v6)

เปิดพอร์ทแบบกำหนดไปเลย

$ sudo ufw allow 22/tcp
$ sudo ufw allow 80/tcp
$ sudo ufw allow 443/tcp

3.Checking your Web Server

$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-02-06 14:26:15 +07; 33min ago
     Docs: man:nginx(8)
 Main PID: 5720 (nginx)
    Tasks: 5 (limit: 4915)
   CGroup: /system.slice/nginx.service
           ├─5720 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           ├─5721 nginx: worker process
           ├─5722 nginx: worker process
           ├─5723 nginx: worker process
           └─5724 nginx: worker process