[HOW TO] Ibus ibus-unikey on Elementary OS | install ibus-unikey on ubuntu | can not install ibus-unikey on ubuntu

have you ever installed ibus-unikey in elementary OS?

A few days ago, I have issues with it. Avowedly, I installed, also add vietnamese keyboard into keyboard input method. What's happened?

And finally, I see it. If you have the save issues, you can use this tip to solve this.

To start, you must install dconf-editor,
org\gnome\desktop\applications\input-sources

per-windows: checked
sources: [('xkb','us'),('ibus','Unikey')]
xkb-options []

now you use Crl + Space to switch language.

 Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] install driver canon in linux | install canon printer in ubuntu | install canon mf3010 in elementary OS

Yesterday I have tried to install Canon Printer MF3010. It is not easy as me think.

Firstly, I come to canon officially of MF3010 to downloaded driver. But it is not success. I still can not install MF3010. What the help?

Workaround, I think that the driver still can not install truly. Where? 

or

It help me to resolve the problem with driver MF3010 in Elementary OS. Hope this help for you.

 Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

Grail run-app | Grails run-app change default port | Grail run app locally



You need to run app in grails before deploying it on your web application. Luckily, grails support them.

Simply you do follows:

1. Go to your grails directory
2. Use "grails run-app" command
3. If you want to change default port of grails run-app 8080. How to? Use command:  grails -Dserver.port=9001 run-app


Run the grails run-app command.
The grails run-app command starts the Enterprise Server in the background and runs the application in one step. You don't need to create a WAR file or deploy your application.
To test your application, point your browser to http://host:port/app-dir-name.
For example, point to http://localhost:8080/helloworld. You should see a screen that begins, “Welcome to Grails.” Selecting the HelloController link should change the display to, “Hello World!”
Link reference: https://docs.oracle.com/cd/E19776-01/820-4496/ghflk/index.html

 Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

HOW DO I GRANT PRIVILEGES IN MYSQL?


Grant for each table:
GRANT permission ON database.table TO 'user'@'localhost';

Grant for database:
GRANT permission ON database.* TO user@'localhost' IDENTIFIED BY 'password';

Once you have given the desired privileges for your user, you will need to run this command within the MySQL command prompt:
FLUSH PRIVILEGES;

To see a list of the privileges that have been granted to a specific user:
select * from mysql.user where User='username';

PrivilegeMeaning
ALL [PRIVILEGES]Sets all simple privileges except GRANT OPTION
ALTEREnables use of ALTER TABLE
CREATEEnables use of CREATE TABLE
CREATE TEMPORARY TABLESEnables use of CREATE TEMPORARY TABLE
DELETEEnables use of DELETE
DROPEnables use of DROP TABLE
EXECUTENot implemented
FILEEnables use of SELECT ... INTO OUTFILE and LOAD DATA INFILE
INDEXEnables use of CREATE INDEX and DROP INDEX
INSERTEnables use of INSERT
LOCK TABLESEnables use of LOCK TABLES on tables for which you have the SELECT privilege
PROCESSEnables the user to see all processes with SHOW PROCESSLIST
REFERENCESNot implemented
RELOADEnables use of FLUSH
REPLICATION CLIENTEnables the user to ask where slave or master servers are
REPLICATION SLAVENeeded for replication slaves (to read binary log events from the master)
SELECTEnables use of SELECT
SHOW DATABASESSHOW DATABASES shows all databases
SHUTDOWNEnables use of MySQLadmin shutdown
SUPEREnables use of CHANGE MASTER, KILL, PURGE MASTER LOGS, and SET GLOBAL statements, the MySQLadmin debug command; allows you to connect (once) even if max_connections is reached
UPDATEEnables use of UPDATE
USAGESynonym for privileges
GRANT OPTIONEnables privileges to be granted

what are the differences between CSV and XLS?

Today I think about CSV file & XLS file, and what are the differences between them?

Humhum, as I known that XLS is file format of Microsoft Excel. CSV is format frequently export by IT man.

Google now, I get one result:

Comma-Separated Values (CSV):These files hold plain text as a series of values (cells) separated by commas (,) in a series of lines (rows). You can actually open a CSV file in a text editor. Many applications are capable of reading CSV files, and many languages provide built-in functions that simplify reading/writing CSV format.


Excel (represented as XL) Spreadsheet (XLS):It is an MS Excel workbook binary file, which holds information about all the worksheets in a workbook, comprising both content and formatting (number masking, colouring, conditional formatting, etc), and can also hold additionals like charts, images, etc. XLS files can only be read by applications that have been especially written to read their format, and can only be written in the same way.

Source: internet

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] reset password MAC OS 10.11

Do you want to reset Mac's password?
Unlucky, you do not know how to do it.

Ok, no problem. Here I show you.

Solution 1:
Access Single-User mode.

a. Shutdown your computer.
b. Use hand to hold down the "Command" key and "S" key. Hold both of these together and do not let go through the next step.
c. Wait until you see a bunch of white writing scrolling by on a back screen. Now you are in Single-User mode.
d. mount -uw /
e. launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist and press [Return]
f. ls /Users and press [Return]. A list of all of the accounts on your computer will be listed
g. dscl . -passwd /Users/your_username your_password
h. Restart the computer and try the new password.

Solution 2:
Recovery mode
a. Shutdown your computer.
b. Use hand to hold down the "Command" key and "S" key. Hold both of these together and do not let go through the next step.
c. Wait until you see a bunch of white writing scrolling by on a back screen. Now you are in Single-User mode.
d. mount -uw /
e. rm /var/db/.AppleSetupDone . Remove the hidden file that trigger’s OS X to skip the setup assistant at startup:
f. type "reboot" to restart your Mac.
g. now configure with a new account (user/password)
h. after login, you can change the password of previous user.

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success


[NOTE] The core file in linux

Warning!
The core file contains a memory dump of a worker process
at the moment of a crash and therefore can contain sensitive
information, such as passwords, keys, or private data. Therefore,
never share core files with people you don't trust.

In Linux I Trust

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] lsyncd: Error, Consider increasing /proc/sys/fs/inotify/max_user_watches | lsyncd dead but pid file exists

hello,

30 minutes ago, I go around our server to ensure the data synchronization runs day-by-day. But ...
It is not run 3 days ago.

What happened?

Ok, step-by-step

Check lsyncd:
[root@01 ~]# /etc/init.d/lsyncd status
lsyncd dead but pid file exists

Huh-uh,
[root@01 ~]# less /var/log/lsyncd/lsyncd.log
lsyncd: Error, Consider increasing /proc/sys/fs/inotify/max_user_watches

How to fix?

$ echo 524288 > /proc/sys/fs/inotify/max_user_watches

man inotify(7) says:
The following interfaces can be used to limit the amount of kernel memory consumed by inotify:
/proc/sys/fs/inotify/max_queued_events 
The value in this file is used when an application calls inotify_init(2) to set an upper limit on the number of events that can be queued to the corresponding inotify instance. Events in excess of this limit are dropped, but an IN_Q_OVERFLOW event is always generated.
/proc/sys/fs/inotify/max_user_instances 
This specifies an upper limit on the number of inotify instances that can be created per real user ID.
/proc/sys/fs/inotify/max_user_watches 
This specifies an upper limit on the number of watches that can be created per real user ID.

Restart lsyncd
[root@01 ~]# /etc/init.d/lsyncd restart
Stopping lsyncd:                                           [FAILED]
Starting lsyncd:                                           [  OK  ]
[root@01 ~]# 
[root@01 ~]# /etc/init.d/lsyncd status
lsyncd (pid  605) is running...

Hope this help!

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] Dumping and importing from/to MySQL in an UTF-8 safe way

to avoid your shell character set from messing with imports, use -r to export and SOURCE when importing.
Export: mysqldump -uroot -p database -r utf8.dump
Import: mysql -uroot -p --default-character-set=utf8 database
mysql> SET names='utf8'
mysql> SOURCE utf8.dump

 Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] configure MySQL master slave replication

Hello

Yesterday I have been working on MySQL Replication between two servers. And I think you will need it as a reference article. Because of I also re-search a lot before starting.

Some question:
What is MySQL replication?
How to do?
How is Master? is Slave?
How to configure?
MySQL replication for non-standard port?
How to stop MySQL replication?
How it works?

Ok, let's start!

What is MySQL replication?
MySQL replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database

How to do?
It has two components: master & slave. They have to configure on two servers. The mysql data will be transferred real time between them.

How is Master? is Slave?
Master: it is running on production in your company. The data will be transferred from here to slave server. Slave: The data will be transferred to here. In case of disaster, this will be take over as master (primary database).

How to configure?

MySQL replication for non-standard port?

How to stop MySQL replication?

How it works?


[HOW TO] 2015/10/12 15:39:35 [error] 30666#0: *5 open() "/home/www/html/index.html" failed (13: Permission denied), client: 127.0.0.1, server: **.vn, request: "GET /index.html HTTP/1.1", host: "*.**.vn"

I am creating the backup server to prepare in case of disaster. It seems well until I can not get the index.html. I use nginx as web server.

What happened? Afterwards I come to /var/log/nginx/error.log to totally view.

2015/10/12 15:39:35 [error] 30666#0: *5 open() "/home/www/html/index.html" failed (13: Permission denied), client: 127.0.0.1, server: **.vn, request: "GET /index.html HTTP/1.1", host: "*.**.vn"

Humhumhum nginx has a thorny permission. But where is it?

Because of I chowned "web root server" in nginx configuration is:
$chown -R nginx.nginx /home/www
$chmod -R /home/www

I do not know exactly what happened? Okay, I need to review with mine knowledge. Oh SELINUX, maybe it is root cause of issues. And it right!

$vi /etc/selinux/config


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

I need to edit as below:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

And I go to reboot the server. Happily, I can open the web page.

Thank you for seeing, see you soon.

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success


[HOW TO] Exporting and Importing An Individual MySQL Table

In moving databases from development to production it is sometimes necessary to export individual tables so that they can be imported into another database.
Exporting the Table
To export the table run the following command from the command line:
“mysqldump -p – –user=username dbname tableName > tableName.sql
This will export the tableName to the file tableName.sql.
[NOTE: there should be no space between the two dashes, but I have to write it that way so that it display properly].
Importing the TableTo import the table run the following command from the command line:
mysql -u username -p -D dbname < tableName.sql
The path to the tableName.sql needs to be prepended with the absolute path to that file. At this point the table will be imported into the DB and you are ready to go!
I ran into this issue when attempting to add new tables to my database. I am unable to run the “LOAD DATA INFILE” command, that I had previously used to populate tables, because Webfaction does not give the permission to run the command. Therefore the simplest solution was to export a table from the MySQL database on my personal machine and then import it to the database on the Webfaction server, using the export/import commands seen above.
Hope this helps someone out with exporting individual tables and as always if any clarification is needed or I missed something feel free to let me know.
–Steve
Thank you Steve :)


[HOW TO] What is net.ipv4.conf.default.rp_filter

/usr/share/doc/kernel-doc-2.6.32/Documentation/networking/ip-sysctl.txt

rp_filter - INTEGER
        0 - No source validation.
        1 - Strict mode as defined in RFC3704 Strict Reverse Path 
            Each incoming packet is tested against the FIB and if the interface
            is not the best reverse path the packet check will fail.
            By default failed packets are discarded.
        2 - Loose mode as defined in RFC3704 Loose Reverse Path 
            Each incoming packet's source address is also tested against the FIB
            and if the source address is not reachable via any interface
            the packet check will fail.

        Current recommended practice in RFC3704 is to enable strict mode 
        to prevent IP spoofing from DDos attacks. If using asymmetric routing
        or other complicated routing, then loose mode is recommended.

        The max value from conf/{all,interface}/rp_filter is used 
        when doing source validation on the {interface}.

        Default value is 0. Note that some distributions enable it
        in startup scripts.

[HOW TO] How to exclude table in mysql

Today morning, developer told me: please send me the database of ***.
Me: do you really need to it?
Developer: ya, I need it.
Me: okay, wait me for minutes.

And I need to exclude one table in database with him. Databases has some tables securely, he did not know it.

How to export database while excluding the table?

mysqldump --ignore-table=db_name.table_name db_name > export.sql
mysqldump --no-data db_name table_name >> export.sql

Above command help you.

Hope this help!

-
Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] enable/ configure iptables in Fedora 22

In Fedora 22, firewall has no active. Here I'll learn how to enable the iptables firewall application and make sure that runtime rules persist after a reboot.

The iptables package is already installed, but to be enable, you need to install the iptables-services package.

sudo yum install iptables-services
sudo systemctl enable iptables.service
sudo systemctl start iptables.service

To view the rules, type:
sudo iptables -L

Example iptables rules:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 139 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] configure Postfix to use Gmail SMTP on Fedora/ Linux/ Ubuntu

I have just created a script to monitoring website. It send the email to me when any website is down. Script store in my local, thus I think to build a MTA in my laptop.

Here I show the outlet for task list:
1. Configure MTA local use Google Mail
2. Create cron job to run script every boot time.

1. Configure MTA local use Google Mail
I have chosen Postfix as MTA. A few time ago, I configured Postfix, so now I do it fast. However, I wonder what will come if I use Google as relay host? I like this is good ideas. A moment later, I found a method to do.

Then open postfix configuration file:
tien localhost ~ $sudo vi /etc/postfix/main.cf
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

As you see, I did not store user name & password in above lines. They will store in different file. Open/Create
tien localhost ~ $sudo vi /etc/postfix/sasl_passwd

And add following line:
[smtp.gmail.com]:587    USERNAME@gmail.com:PASSWORD

If you want to use our Google App's domain, please replace @gmail.com with your @domain.com

Set permission sasl_passwd file:
tien localhost ~ $sudo chmod 400 /etc/postfix/sasl_passwd

Update postfix configuration to use sasl_passwd file:
tien localhost ~ $sudo postmap /etc/postfix/sasl_passwd

Next, validate certificates to avoid running into error. Just run following command:
tien localhost ~ $sudo cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Finally, please reload postfix
tien localhost ~ $sudo /etc/init.d/postfix reload

All is done. Now you can test

tien localhost ~ $echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com

2. Create cron job to run script every boot time.
Use special strung called @reboot to run job at startup (boot time)
$crontab -e -u tien

@reboot sh /home/tien/Script/webmonitor/mosite.sh

3. Troubleshooting
Google Mail SMTP server has a limit of 500 email per day. So use wisely!

Error: “SASL authentication failed; server smtp.gmail.com”
You need to unlock the captcha by visiting this page https://www.google.com/accounts/DisplayUnlockCaptcha
You can run test again after unlocking captcha

Reference: https://rtcamp.com/tutorials/linux/ubuntu-postfix-gmail-smtp/

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success


[HOW TO] install Postfix MTA

Here I show you the step-by-step to install MTA on server/ client.

  123  yum install postfix
  127  alternatives --set mta /usr/sbin/sendmail.postfix 
  133  cp /etc/postfix/main.cf /etc/postfix/main.cf.orig
  134  vi /etc/postfix/main.cf 
  135  /etc/init.d/postfix restart
  136  chkconfig postfix on

As you see, it is a short guidance :D

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] install Geary on Fedora 22 | Geary is having issues

I am using fedora 22 and I am really fed up with Thunderbird. On Linux there are a few Mail Client alternatives to the Thunderbird email client. But I still did not like.

Until now, Geary is an interesting beast. It looks like a beautiful girl to write an email.

I'm fairly confident that you will like it.

On personally social page, I wrote as above. But the fact it runs unstable. It looks like it need more dependencies packages and I did not know that.

One hour ago, I feel uncomfortable with it. What the fuck! I need to fix it. I go to Geary home page https://wiki.gnome.org/Apps/Geary and download source.

Extract it, I read INSTALL memo. Good, exactly the same thing I thought. Afterward I followed this instruction and get the good result. Geary is running stable.

As a habit, I think you will need it. It is a reason to write down.

1. Firstly, building Geary requires Vala 0.22.1 or higher with a full GObject introspection repository, intltool, cmake, desktop-file-validate, and xml2po. Thus you must install vala:
$ sudo yum install vala

2. You also install the rest of the build dependencies for Geary in any version of Fedora by running this command:

$ sudo yum install gobject-introspection-devel intltool cmake desktop-file-utils gnome-doc-utils libcanberra-devel libgee-devel glib2-devel gmime-devel gtk3-devel libnotify-devel sqlite-devel unique3-devel webkitgtk3-devel libsecret-devel libxml2-devel vala-tools gcr-devel

3. Combine
Go to Geary directory, follows:
$./configure$sudu make$sudo make install

By default, Geary will install under /usr/local.  The configure script can customize the prefix directory.  Run ./configure --help for instructions and other installation options. In some case, you will install cmake if any. Please install to continue.

If you have any issues, please contact me.

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success


[HOW TO] exit MySQL command prompt?

Hello dude,

Mysql gives me a shit :(

I ran the invalid command mysql like this:
mysql> select * from conf
    -> 

I can not exit the. Google, someone suggest me use Ctrl + C or Ctrl + D to solve this. But it give:    
-> Aborted

What the fuck? How to solve it?

*Fortunately* I find it: "\c"

mysql> select * from conf -> -> -> -> -> \cmysql>

:) hope this help

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success


What is the Difference between Call Filter and Data Filter?

Hello,

I have confused between Call Filter and Data Filter in Vigor Draytek configuration.

I search officially document and googled relatively link. Finally I see what I need in i-helpdesk.com.au

Now I show you that hope it can help reduce your time. Hope you see this post in the top result of google :))

IP filter architecture categorizes traffic into two types: Call Filter and Data Filter. This is based on whether the Internet connection is up or down (WAN link status is up or down).

Call Filter – applies when there is no existing Internet connection.The Call Filter is applied to all outgoing traffic. It will check packets according to the filter rules. If legal, the packet will be allowed to pass. Then the router shall “initiate a call” to start the Internet connection and send the packet out to Internet.

Data Filter – applies when there is an existing Internet connection. The Data Filter is applied to incoming and outgoing traffic. It will check packets according to the filter rules. If legal, the packet will be allowed to pass through the router.

The following illustrations are flow charts explaining how router will treat incoming traffic and outgoing traffic respectively.




Thank you :)

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success






Wireshark Filters frequently use

Hello,

I show you somes Wireshark Filters frequently use :) Hope this help,

1.       ip.addr == 10.0.0.1
[Sets a filter for any packet with 10.0.0.1, as either the source or dest]

2.       ip.addr==10.0.0.1  && ip.addr==10.0.0.2
[sets a conversation filter between the two defined IP addresses]

3.       http or dns
[sets a filter to display all http and dns]

4.       tcp.port==4000
[sets a filter for any TCP packet with 4000 as a source or dest port]

5.       tcp.flags.reset==1
[displays all TCP resets]

6.       http.request
[displays all HTTP GET requests]

7.       tcp contains traffic
[displays all TCP packets that contain the word ‘traffic’. Excellent when searching on a specific string or user ID]

8.       !(arp or icmp or dns)
[masks out arp, icmp, dns, or whatever other protocols may be background noise. Allowing you to focus on the traffic of interest]

9.       udp contains 33:27:58
[sets a filter for the HEX values of 0x33 0x27 0x58 at any offset]

10.   tcp.analysis.retransmission
[displays all retransmissions in the trace. Helps when tracking down slow application performance and packet loss]

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] remove the special character in linux?

Do you need to remove the special character in linux?

A quick tip will be help you.

Firstly, you use "ls -il" to show the inode information of file/ folder

[~]# ls -il
total 17900
1048619 -rw-r--r--  1 root root     297 Jul 23 15:15 \

To be continued, you use find command to delete them by inode
[~]#find . -inum  1048619 -exec rm -rf {} \;

It will find and remove them without prompt.

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] Easiest way to fix MySQL UTF8 to Latin1 character set encoding issues.

MySQL originally used the latin1 character set by default which stored characters in a 2-byte sequence. In recent versions it defaults to UTF-8 to be friendlier to international users.

When migrating MySQL databases, occasionally you’ll see odd characters appear on the new system. For example, a simple quote mark may be replaced by 4-5 characters of junk symbols.

This happens when MySQL is trying to display characters using a different character set to the one they are stored in. To fix, we need to make sure the database is marked as latin1 when we export it from the old system, and then re-encode it into UTF-8 when importing it into it’s new home.

Export:
mysqldump -u $user -p --opt --quote-names --skip-set-charset \
--default-character-set=latin1 $dbname > dump.sql

Import:
mysql -u $user -p --default-character-set=utf8 $dbname < dump.sql

Source: blog . Thank you :)


Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] Export mysql result to csv file

Hello,

Export mysql result to csv file is necessary. It is useful in case of you need to send the result to developer or others.

You can follow:

SELECT *
FROM report
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

What it means?
FIELDS TERMINATED BY ',' :the fields will be separated by commas,
ENCLOSED BY '"' :each field will be enclosed in “double quotes,”
LINES TERMINATED BY '\n'; :each row will be output on a new line separated by a newline (\n)

Hope this help!

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

Export/Import/Create database with exact character set (eg. utf8)

Hello,

A short article,

1. Export database with exact character set (eg. utf8)
$mysqldump -uUSERNAME -pPASSWORD --default-character-set=utf8 USER_DATABASE > backup.sql

2. Import database with exact character set (eg. utf8)
#mysql -uUSERNAME -pPASSWORD --default-character-set=utf8 USER_DATABASE < backup.sql

3. Create database with exact character set (eg. utf8)
$mysql -uroot -p
...
mysql> CREATE DATABASE mydb CHARACTER SET utf8;
 

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] copy multiple files from remote host to local host

Hello,


A short article,

copy multiple files from remote host to local host

$scp your_user_remotehost@remote_host:/direct1/\{file1,file2,file3\} /home/local_host

Thank you for reading this article, please a comment if you are interested.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

Install Sun/Oracle Java JDK/JRE 7u79/80 on Fedora 22/21/20/19, CentOS/Red Hat (RHEL) 7.1/6.6/5.11

1. Download Sun/Oracle Java JDK/JRE 7u79/80 32-bit/64-bit RPM packages

Download Sun/Oracle Java 7u79 or 7u80 from here http://www.oracle.com/technetwork/java/javase/downloads/index.html. Select rpm package (jdk-7u79-linux-i586.rpm, jdk-7u79-linux-x64.rpm, jre-7u79-linux-i586.rpm or jre-7u79-linux-x64.rpm) or (jdk-7u80-linux-i586.rpm, jdk-7u80-linux-x64.rpm, jre-7u80-linux-i586.rpm or jre-7u80-linux-x64.rpm).

2. Change to root user.

sudo -i
## OR ##
su -

3. Install Java JDK or JRE package

## JDK 32-bit ##
rpm -Uvh /path/to/binary/jdk-7u79-linux-i586.rpm
# OR #
rpm -Uvh /path/to/binary/jdk-7u80-linux-i586.rpm
## JDK 64-bit ##
rpm -Uvh /path/to/binary/jdk-7u79-linux-x64.rpm
# OR #
rpm -Uvh /path/to/binary/jdk-7u80-linux-x64.rpm
## JRE 32-bit ##
rpm -Uvh /path/to/binary/jre-7u79-linux-i586.rpm
# OR #
rpm -Uvh /path/to/binary/jre-7u80-linux-i586.rpm
## JRE 64-bit ##
rpm -Uvh /path/to/binary/jre-7u79-linux-x64.rpm
# OR #
rpm -Uvh /path/to/binary/jre-7u80-linux-x64.rpm

4a. Install Sun/Oracle JDK java, javaws, libjavaplugin.so (for Firefox/Mozilla) and javac with alternatives –install command

Use Java JDK latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000
## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 200000
## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 200000
## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000

Use Java JDK CPU absolute version (/usr/java/jdk1.7.0_79)

## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_79/jre/bin/java 200000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_79/jre/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0_79/jre/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_79/jre/lib/amd64/libnpjp2.so 200000

## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_79/bin/javac 200000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_79/bin/jar 200000

 

Use Java JDK PSU absolute version (/usr/java/jdk1.7.0_80)

## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_80/jre/bin/java 200000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_80/jre/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0_80/jre/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_80/jre/lib/amd64/libnpjp2.so 200000
## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_80/bin/javac 200000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_80/bin/jar 200000

 

4b. Install Sun/Oracle JRE java, javaws and libjavaplugin.so (for Firefox/Mozilla) with alternatives –install command

Use Java JRE latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 200000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/lib/amd64/libnpjp2.so 200000

 

Use Java JRE CPU absolute version (/usr/java/jre1.7.0_79)

## java ##
alternatives --install /usr/bin/java java /usr/java/jre1.7.0_79/bin/java 200000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jre1.7.0_79/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre1.7.0_79/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jre1.7.0_79/lib/amd64/libnpjp2.so 200000

 

Use Java JRE PSU absolute version (/usr/java/jre1.7.0_80)

## java ##
alternatives --install /usr/bin/java java /usr/java/jre1.7.0_80/bin/java 200000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jre1.7.0_80/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre1.7.0_80/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jre1.7.0_80/lib/amd64/libnpjp2.so 200000

 

5. Check current java, javac, javaws and libjavaplugin.so versions

java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

javaws
Java(TM) Web Start 10.51.2.13-fcs
[...]

javac -version
javac 1.7.0_79

6. Swap between OpenJDK and Sun/Oracle Java JDK/JRE 6 and 7 versions

java

alternatives --config java

There are 5 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/java/jdk1.6.0_26/jre/bin/java
   4           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   5           /usr/java/jdk1.7.0_79/jre/bin/java

Enter to keep the current selection[+], or type selection number: 5

 

javaws

alternatives --config javaws

There are 3 programs which provide 'javaws'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/javaws
 + 2           /usr/java/jdk1.6.0_26/jre/bin/javaws
   3           /usr/java/jdk1.7.0_79/jre/bin/javaws

Enter to keep the current selection[+], or type selection number: 3

 

libjavaplugin.so (32-bit)

alternatives --config libjavaplugin.so

There are 3 programs which provide 'libjavaplugin.so'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/i386/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/i386/libnpjp2.so
   3           /usr/java/jdk1.7.0_79/jre/lib/i386/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 3

 

libjavaplugin.so.x86_64 (64-bit)

alternatives --config libjavaplugin.so.x86_64

There are 3 programs which provide 'libjavaplugin.so.x86_64'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/amd64/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/amd64/libnpjp2.so
   3           /usr/java/jdk1.7.0_79/jre/lib/amd64/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 3

 

javac

alternatives --config javac

There are 3 programs which provide 'javac'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/bin/javac
 + 2           /usr/java/jdk1.6.0_26/bin/javac
   3           /usr/java/jdk1.7.0_79/bin/javac

Enter to keep the current selection[+], or type selection number: 3

 

Post-Installation Setup

Add JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file
Java JDK and JRE latest version (/usr/java/latest)

## export JAVA_HOME JDK/JRE ##
export JAVA_HOME="/usr/java/latest"

Java JDK and JRE absolute version (/usr/java/jdk1.7.0_79)
## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.7.0_79"

## export JAVA_HOME JRE ##
export JAVA_HOME="/usr/java/jre1.7.0_79"

Java JDK and JRE absolute version (/usr/java/jdk1.7.0_80)
## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.7.0_80"

## export JAVA_HOME JRE ##
export JAVA_HOME="/usr/java/jre1.7.0_80"


Totally reference: http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/