Rsync to AWS EC2 Using .PEM key

The standard AWS EC2 instances support using a .PEM key to log in, instead of a more common SSH username/password combination. If you want to use Rsync to transfer data from your local machine to an AWS EC2 instance you will need to change the Rsync command to be something like this:

rsync -rave "ssh -i PEMKEYFILE.pem" /path/to/local/files/* [email protected]_INSTANCE_HOSTNAME:/path/to/remote/files

For simplicities sake I ensured that I was in the directory where the .pem key was saved, but you can adjust the command to give the path to your key file.

Beyond this it’s just like regular Rsync, so just follow the on-screen commands and you get secured file transfer between your local machine and your remote AWS EC2 instance



Elasticsearch: Updating Index Analysis

It is also possible to define new analyzers for the index. But it is required to close the index first and open it after the changes are made.

For example if content analyzer hasn’t been defined on myindex yet you can use the following commands to add it:

POST /twitter/_close

PUT /twitter/_settings
  "analysis" : {

POST /twitter/_open

Connect to the MySQL on Docker with CMD

I connect to the bash into the running MySQL container:

$ docker exec -t -icontainer_mysql_name/bin/bash

-i is the shortcut for --interactive option. This options is used for keep STDIN open even if not attached

-t is the shortcut for --tty option, used to allocate a pseudo-TTY

I run MySQL client from bash MySQL container:

$ mysql -uroot -proot

-u is shortcut for --user=name option, used to define user for login if not current user.

-p is shortcut for -password[=name] option, used to define password to use when connecting to server. If password is not given it’s asked from the tty.


$ docker exec -t -i container_mysql_name /bin/bash -c "mysql -uroot -proot"

The Best Free Third-Party Drivers: FUSE for macOS

FUSE for macOS

This method is free, but it requires a good bit of work, and is less secure. To make your Mac automatically mount NTFS partitions in read-write mode, you’ll have to temporarily disable System Integrity Protection and replace one of Apple’s built-in tools with a binary that is more vulnerable to attack. So this method is a security risk.

However, you can use FUSE to mount NTFS partitions in read-write mode manually if you don’t mind using the Terminal. This is more secure, but it’s more work.

First, download FUSE for macOS and install it. Use the default options when installing it.

RELATED: How to Install Packages with Homebrew for OS X

You’ll also need Apple’s command line developer tools installed to continue. If you haven’t installed them yet, you can open a Terminal window from Finder > Applications > Utilities and run the following command to do so:

xcode-select --install

Click “Install” when you’re prompted to install the tools.

RELATED: How to Install Packages with Homebrew for OS X

In addtion, you’ll need to download and install homebrew if you haven’t already installed it on your Mac. Homebrew is a “package manager” for Mac OS X. Copy-paste the following command into a Terminal window and press Enter to install it:

/usr/bin/ruby -e "$(curl -fsSL"

Press Enter and provide your password when prompted. The script will automatically download and install Homebrew.

Once you’ve installed the developer tools and Homebrew, run the following command in a Terminal window to install ntfs-3g:

brew install ntfs-3g

You can now manually mount NTFS partitions in read/write mode. From a terminal window, run the following command to create a mount point at /Volumes/NTFS. You only need to do this once.

sudo mkdir /Volumes/NTFS

When you connect an NTFS drive to the computer, run the following command to list any disk partitions:

diskutil list

You can then identify the device name of the NTFS partition. Just look for the partition with the Windows_NTFS file system. In the screenshot below, it’s /dev/disk3s1 .

The NTFS partition was probably automatically mounted by your Mac, so you’ll need to unmount it first. Run the following command, replacing /dev/disk2s1 with the device name of your NTFS partition.

sudo umount /dev/disk2s1

To mount the drive, run the following command, replacing /dev/disk2s1 with the device name of your NTFS partition.

sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other

You’ll see the file system mounted at /Volumes/NTFS. It will also appear on your desktop as a normal mounted drive. You can eject it normally when you want to unplug it.

If you’re happy manually mounting partitions with the above instructions, you don’t have to continue.

RELATED: How to Disable System Integrity Protection on a Mac (and Why You Shouldn’t)

If you want to make your Mac automatically mount NTFS drives you connect in read-write mode, you’ll need to disable System Integrity Protection.

WarningYou probably don’t want to do this! The software’s official instructions warn that this is a security risk. You will be replacing the NTFS mount tools in your Mac with the ntfs-3g tools, which will run as the root user. Because of the way Homebrew installs software, malware running on your Mac could overwrite these tools. It’s probably not work the risk, but we’ll explain how to do if if you want to take the risk.

Reboot your Mac and hold Command+R while it’s booting. It’ll boot into a special recovery mode environment.

Launch a terminal from the Utilities menu in recovery mode and run the following command:

csrutil disable

Once you have, reboot your Mac normally.

From the Mac desktop, open a Terminal window again and run the following commands to make ntfs-3g function:

sudo mv /sbin/mount_ntfs /sbin/mount_ntfs.original

sudo ln -s /usr/local/sbin/mount_ntfs /sbin/mount_ntfs

Lastly, re-enable System Integrity Protection. Reboot your Mac and hold Command+R while it’s booting to enter recovery mode. Launch a terminal in recovery mode and run the following command:

csrutil enable

Once you have, reboot your Mac. NTFS-write support should be functioning now.

To undo your changes and uninstall everything, you’ll need to first disable System Integrity Protection. After you do, run the following commands:

sudo rm /sbin/mount_ntfs

sudo mv /sbin/mount_ntfs.original /sbin/mount_ntfs

brew uninstall ntfs-3g

You can then uninstall FUSE for macOS from its panel in the System Preferences window and re-enable System Integrity Protection.

You can see why we recommend the $20 option instead now, huh?

Apple’s Experimental NTFS-Writing Support: Don’t Do This, Seriously

We don’t recommend the below method because it’s the least tested. This might not work properly, so don’t blame us or Apple if you experience problems. It’s still unstable as of macOS 10.12 Sierra, and it may never be fully stable. This is really just here for educational purposes.

First, be sure that your drive has a convenient single-word label. If it doesn’t, change its label. This will make this process easier.

You’ll first need to launch a terminal. Navigate to Finder > Applications > Utilities > Terminal or press Command+Space, type Terminal, and press Enter.

Type the following command into the terminal to open the /etc/fstab file for editing in the nano text editor:

sudo nano /etc/fstab

Add the following line to nano, replacing “NAME” with the label of your NTFS drive:

LABEL=NAME none ntfs rw,auto,nobrowse

Press Ctrl+O to save the file after you’re done, and then press Ctrl+X to close nano.

(If you have multiple NTFS drives you want to write to, add a different line for each.)

Connect the drive to the computer—unplug it and reconnect it if it’s already connected—and you’ll see it under the “/Volumes” directory. In a Finder window, you can click Go > Go to Folder and type “/Volumes” into the box to access it. It won’t pop up automatically and appear on your desktop like drives normally do.

To undo this change later, just repeat the above process to open the /etc/fstab file in nano. Delete the line you added to the file and save your changes.

Most Mac users will be better off formatting external drives with exFAT, ensuring they work well on both Windows and Mac OS X without any extra work. if you must write to an NTFS drive, one of the paid, third-party drivers will be the easiest option with the best performance and least risk of file corruption.

View Permission all file in directory with Number

This can be used to list all directory files with their permissions:

ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \ *2^(8-i));if(k)printf("%0o ",k);print}'


แก้ปัญหา การใช้งาน node หลาย version ในเครื่องเดียวด้วย NVM

Node Version Manager


ในการ install หรือ update nvm, คุณสามารถติดตั้งด้วย cURL:

curl -o- | bash

หรือ Wget:

wget -qO- | bash


export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm

เข้าไปที่ ~/.bash_profile

Verify installation
ในการ verify nvm ว่ามีการติดตั้งแล้วให้ใช้คำสั่ง:

command -v nvm


ในการติดตั้ง node ใน version ที่ต้องการ
nvm install 9.11.2 version
nvm install 9.11.2

กำหนด node ให้เป็น version ที่ต้องการ
nvm use 8.11.3

เรียกดู path ของ version ที่กำหนด
nvm which 9.11.2

รัน node script shell แบบ กำหนด version
nvm exec 8.11.3 node --version