[HOW TO] install Visual Studio Code in Arch Linux

I am moving Linux working environment from Ubuntu to Antergos. And I need to install Visual Studio Code for working with Git. 

Also saw something on this progress that is needed for newbie. So I write down this article. Hope it can be help you faster. 

This article follows step-by-step theory, so it is easy to do. 

Step 1:
You must download git repository 
[root@cliff Downloads]# git clone https://AUR.archlinux.org/visual-studio-code-bin.git

Step 2:
Then go inside 
[root@cliff Downloads]# cd visual-studio-code-bin/
[root@cliff visual-studio-code-bin]# ls
PKGBUILD  visual-studio-code.desktop  visual-studio-code-url-handler.desktop

Step 3:
And make a pacman package
[cliff@cliff visual-studio-code-bin]$ makepkg -s
==> Making package: visual-studio-code-bin 1.33.1-1 (Mon 29 Apr 2019 03:59:40 PM +07)
==> Checking runtime dependencies...
==> Installing missing dependencies...
...
==> Finished making: visual-studio-code-bin 1.33.1-1 (Mon 29 Apr 2019 04:00:34 PM +07)

makepkg should download *.tar.gz from Visual Studio Code and convert it to pacman package 
==> Finished making: visual-studio-code-bin 1.33.1-1 (Mon 29 Apr 2019 04:00:34 PM +07)

Step 4:
Then install 
[cliff@cliff visual-studio-code-bin]$ sudo pacman -U visual-studio-code-bin-1.33.1-1-x86_64.pkg.tar 

Step 5:
Finally, you can start it for now. I am using i3, so can take it via Ctrl + D and type "visual studio code" and press. 

Tiến Phan - R0039

Knowledge is Endless
Sharing for Success 

[HOW TO] fix ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

Hey guys,

I am working with MySQL, then want to export the data to csv file. 
mysql> select name,address from devices into outfile '/tmp/devices.csv' fields terminated by ',' enclosed by '"' lines terminated by '\n';ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

Oops! unlucky, it returns the error. Before me, someone started MySQL with --secure-file-priv
mysql> SHOW VARIABLES LIKE "secure_file_priv"; 
+------------------+-----------------------+| 
Variable_name    | Value                  
|+------------------+-----------------------+| 
secure_file_priv | /var/lib/mysql-files/ | 
+------------------+-----------------------+ 
1 row in set (0.00 sec)

it looks like that all of files store at /var/lib/mysql-files/ as declared. Then I try to export again.
mysql> select name,address from devices INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';Query OK, 891 rows affected (0.01 sec)

it works!!!


Tiến Phan - R0039

Knowledge is Endless
Sharing for Success 


[HOW TO] set application log to rsyslog on Ubuntu server

Depending on your application, also your purpose, you want to direct the log to fixed log path. So, if you are using rsyslog as a syslog service on Ubuntu, please follow this article.

I am using trigger to do this.

Go to log path
root@sta-tn:/etc/rsyslog.d#

then write a sub-rsyslog configuration.
root@sta-tn:/etc/rsyslog.d# vim 10-sta.conf 
if $programname == 'STA'  then {  
/var/log/sta.log    
stop 
}

You can declare more directive here. Then restart rsyslog service
root@sta-tn:/etc/rsyslog.d# systemctl restart rsyslog

Another way, you can use imfile module to do this.

Tiến Phan - R0039

Knowledge is Endless
Sharing for Success 

[HOW TO] The following signatures couldn't be verified because the public key is not available: NO_PUBKEY

sky@zabbix4-srv-01:/opt/packages$ sudo apt-get updateGet:1 http://repo.zabbix.com/zabbix/4.0/ubuntu xenial InRelease [7096 B]Hit:2 http://security.ubuntu.com/ubuntu xenial-security InReleaseGet:3 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease [23.9 kB]Hit:4 http://us.archive.ubuntu.com/ubuntu xenial InReleaseGet:5 http://repo.zabbix.com/zabbix/4.0/ubuntu xenial/main Sources [1196 B]Ign:3 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InReleaseHit:6 http://us.archive.ubuntu.com/ubuntu xenial-updates InReleaseGet:7 http://repo.zabbix.com/zabbix/4.0/ubuntu xenial/main amd64 Packages [2697 B]Get:8 http://repo.zabbix.com/zabbix/4.0/ubuntu xenial/main i386 Packages [2685 B]Hit:9 http://us.archive.ubuntu.com/ubuntu xenial-backports InReleaseFetched 37.5 kB in 1s (33.2 kB/s)Reading package lists... DoneW: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6CW: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease' is not signed.N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.N: See apt-secure(8) manpage for repository creation and user configuration details.

sky@zabbix4-srv-01:/opt/packages$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6CExecuting: /tmp/tmp.8btYCLAEE0/gpg.1.sh --keyserverkeyserver.ubuntu.com--recv-keys4F4EA0AAE5267A6Cgpg: requesting key E5267A6C from hkp server keyserver.ubuntu.comgpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" importedgpg: Total number processed: 1gpg:               imported: 1  (RSA: 1)


sky@zabbix4-srv-01:/opt/packages$skylab@zabbix4-srv-01:/opt/packages$ sudo apt-get updateHit:1 http://repo.zabbix.com/zabbix/4.0/ubuntu xenial InReleaseHit:2 http://security.ubuntu.com/ubuntu xenial-security InReleaseGet:3 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease [23.9 kB]Hit:4 http://us.archive.ubuntu.com/ubuntu xenial InReleaseHit:5 http://us.archive.ubuntu.com/ubuntu xenial-updates InReleaseHit:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InReleaseFetched 23.9 kB in 1s (22.1 kB/s)Reading package lists... Done

Tiến Phan - R0039

Knowledge is Endless
Sharing for Success 

[HOW TO] using loopback files

Morning, 

Sometimes, you want to have a specified mount point for backing up. But, you could not find any free mount point. 

Also I explain why do we need to have a specified mount point.
1. To mark as a backup mount point other purpose, then nobody have a mistake with this. 
2. Clearly mount point for managing 

So, why did I us "loopback file? 
Using "loopback file", I do it. Loopback filesystems are very interesting components of Linux-like systems. Daily, we create filesystems on device (disk drive partitions). These storage devices are available as device files such as /dev/device_name. Then we mount it at a directory called a mount point. On the other hand, loopback filesystems are those that we create in files rather than a physical device. We can then mount those files as filesystems at a mount point. It is logical disk inside a file on your physical disk.

How I do it? 
Create raw file with "dd" command
$ dd if=/dev/zero of=loopbackfile.img bs=1GB count=1

then I have a 1GB file loopbackfile.img. Then I format this file to ext4 using mkfs command as follows:
$ mkfs.ext4 loopbackfile.img

and create a new directory 
$mkdir /mnt/loopback

mount the loopback file to /mnt/loopback as follows
$ mount -o loop loopbackfile.img /mnt/loopback

option "-o loop" is used to mount loopback filesystems. Also it attaches to a device called /dev/loop1 or loop2.

then I use "df -h" command
/dev/loop0      976M  2,6M  907M   1% /mnt/loopback

finally, I should add "mount -o loop loopbackfile.img /mnt/loopback" to /etc/fstab. Why? because it will follow the system startup and already have the mount point. I could not remember to add it every system boot. Of course, I need to use it as a static partition on this case. If you don't need it, you can ignore this. 

Good luck! 

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success