-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory


This warning/error ever happened to you? Whenever you try to ssh to your server or try to update your spamassassin (sa-update) you will get this error.

Last login: Mon Nov  6 11:17:54 2017 from
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[root@sa ~]# sa-update
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Follow below steps to fix it.

  1. login to your server
  2. vi /etc/environment and add below lines

  3. LANG=en_US.utf-8

  4. Save and quit
  5. Done


Posted in Uncategorized

Create a Bash Alias in OSX/MacOS


When I bought my Mac, the .bash_login file wasn’t there. I need to create it for myself so that I could put prompt info, alias, functions, etc. in it.

Here are the steps if you would like to create one:

  1. Start up Terminal
  2. Type cd ~/ to go to your home folder
  3. Type touch .bash_profile to create your new file.
  4. Edit .bash_profile with your favorite editor (or you can just type open -e .bash_profileto open it in TextEdit.
  5. Type . .bash_profile to reload .bash_profile and update any alias you add.


Posted in Mac, MacOS, OSX, UNIX | Tagged , , ,

How to Install Cacti on CentOS 7


Cacti is a configurable, scalable network and resource monitoring system based on the RRDTool suite. It works on systems ranging from simple LAN installations, to multi data center LANs. Cacti provides user management, as well as acquisition of data from multiple sources in an easy-to-use interface. This guide sets up a Cacti installation on a CentOS 7 server.

Getting Started

To complete this guide, you will need the following:
• 1 Node running CentOS 7 with internet.

While good for learning how to set up Cacti on CentOS, it is better to install Cacti on a running server once you are familiar with the process, as monitoring is crucial for production-facing assets.


Let’s update all installed packages. Not only does this apply any known security fixes, but it also resolves issues in the base CentOS system.

yum update -y

Cacti depends on Apache, PHP, the MariaDB MySQL fork, and the associated modules needed to make PHP and Apache work together. We’ll install those next.

yum install nano httpd httpd-devel mariadb-server php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli -y

SNMP is also crucial to the Cacti stack. We’ll install net-snmp, the php-snmp module so PHP can retrieve SNMP data, and finally rrdtool.

yum install php-snmp net-snmp-utils net-snmp-libs rrdtool -y

Let’s start bringing up the various components Cacti needs. We’ll begin by launching Apache, MariaDB and SNMP.

systemctl start httpd.service
systemctl start snmpd.service
systemctl start mariadb.service

All of these should be configured to start at boot. Here we configure these components to launch when the server starts.

systemctl enable httpd.service
systemctl enable snmpd.service
systemctl enable mariadb.service

We must now secure access to Cacti. Leaving monitoring solutions open to public viewing is a security risk. This next step adds password authentication for Cacti.


Cacti needs a database, which will now be created. We’ll also create a cacti user and grant it all database privileges.

mysql -u root -p
MariaDB> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactipassword';
MariaDB> GRANT ALL PRIVILEGES ON cactidb.* TO 'cactiuser'@'localhost';
MariaDB> exit

It is finally time to install Cacti itself.

yum install epel-release -y
yum install cacti -y

Cacti ships with a cacti.sql database dump that should be imported into MySQL. We need to find where it was stored in order to perform the import.

rpm -ql cacti|grep cacti.sql

Now we’ll actually import the schema we’ve just found. This command loads the cacti.sql dump into the database we created previously.

mysql -u cactiuser -p cactidb < /usr/share/doc/cacti-0.8.8h/cacti.sql

Cacti needs to know how to connect to the database. We must add the database name and credentials to its database configuration file.

nano /etc/cacti/db.php
database_default = "cactidb";
database_hostname = "localhost";
database_username = "cactiuser";
database_password = "cactipassword";

Apache must be accessible from the network so we can view Cacti’s statistics. Edit /etc/httpd/conf.d/cacti.conf.

nano /etc/httpd/conf.d/cacti.conf

Change these two lines:

# httpd 2.4
Require host localhost <—- This one

# httpd 2.2
Order deny,allow
Deny from all
Allow from localhost <—- This one



# httpd 2.4
Require all granted

# httpd 2.2
Order deny,allow
Deny from all
Allow from all


Restart Apache so it picks up the configuration changes we’ve just made.

systemctl restart httpd.service

There is a crontab entry for Cacti that must be activated in order for it to create its graphs. Uncomment the line in /etc/cron.d/cacti.

nano /etc/cron.d/cacti

#*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1


*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

In order for Cacti to log its results, we’ll need to create an empty cacti.log.

mkdir /var/log/cacti
touch /var/log/cacti/cacti.log

The remaining installation steps are done via the web interface. Visit http://your_ip/cacti to finish the process.

When prompted for a username and password, enter “admin” for both. These should be changed as soon as possible.

P/S: If you get MySQL TimeZone error please follow below steps

root-bash> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
mysql> use mysql;
mysql> GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
mysql> flush privileges;


This CentOS 7 server is now being monitored by Cacti. While the results of monitoring an empty server are not terribly interesting, the true utility of monitoring becomes quickly apparent when it is used on a production server managing actual workloads. If this guide was helpful to you, kindly share it with others who may also be interested.

ref: here


Posted in Browser, cacti, Install, Linux, SQL | Tagged

How to Browsing the Web Using SSH Tunnel


Sometimes you need to configure something on your client office (router/firewall), but the only way to do that was to be on the their internal network and browse to it using a browser. Trying text based browsers didn’t work, the only way to access and administer the router was to use a full featured browser from behind the firewall itself. There was a DMZ linux machine that I could SSH to, but no VPN available. I figured out how to do it using Putty and Firefox, and this is how you do it.

What you need?

  1. Putty
  2. Firefox browser.

Configure SSH tunnel using Putty

Open Putty and Enter the hostname or IP of the machine you want to establish a remote connection to.  Next under Connection->SSH->Tunnels find the radio boxes under the Destination field and make sure Dynamic is selected.  Next under where it reads Add new forwarded port: enter a source port.  For this example lets use 696, enter this in the source port field and click the Add button.  You should see a value in the Forwarded ports: list that reads D696.  That’s all there is to the Putty side of things.  Next go back to the session area and save the current configuration as a saved session if you’d like, then Open the SSH connection.

Configure Firefox

Launch Firefox, select Tools->Options and click the Advanced tab. Within the Advanced tab, click on the Network tab and click the Settings button.

Within the Network Settings dialog, select the Manual proxy configuration radio button and enter the following for the SOCKS Host: and Port:

SOCKS Host: localhost
SOCKS Port: 696

Click OK on the Settings dialog, then Click OK on the Options dialog. Now you should be good to go.  Enter a new URL in the Firefox address bar and you’ll be browsing from the remote end of the SSH connection.



Posted in Browser, Linux, UNIX | Tagged , ,

How to Enable su Access in FreeBSD


How can a “normal” user get root rights, or actually switch to root account using the su command when working under FreeBSD?

To do that, that “normal” user needs to be in wheel group. So this command will enable a given user to be able to switch to root account with the command su – root or just su –

pw groupmod wheel -m [user]


pw groupmod wheel -m hanief

Now that user hanief will be able to become root. This is a good security feature that FreeBSD has.



Posted in freeBSD, Linux, UNIX | Tagged , , ,

How to Search Deleted Accounts in Zimbra



Zimbra keeps track of deleted accounts in its MySQL database. So if it will be necessary to search for accounts that may have existed some time ago, you can list all accounts by SQL.

As the zimbra user issue the following command:
mysql -e "select email, from_unixtime(deleted_at) from zimbra.deleted_account order by deleted_at"




Posted in SQL, Zimbra | Tagged , , ,