[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