How to Clear the Password History in Linux

In Red Hat Enterprise Linux 7 (RHEL 7) the password history is stored in the file /etc/security/opasswd. You can only edit this file while logged in as the root user. You can either selectively delete old passwords from the file or you can clear everything out of the file with the command:

echo “” > /etc/security/opasswd

Sendmail Hangs When Starting Up or When Using It with PHP

If you notice Sendmail hanging up for many minutes while starting up at boot or while being used such as sending an email from a PHP script, it is probably a DNS lookup problem. Ensure your /etc/hosts file has the appropriate entries for your server that sendmail is running on:

127.0.0.1       localhost localhost.localdomain
192.168.1.80    www.foo.com www
192.168.1.80    www.foo.com.

Replace “www.foo.com” and “www” with your server’s fully qualified domain name and host name respectively. Replace “192.168.1.80” with the IP address of your server. The last entry with the “.” at the end is critical so don’t forget it.

Terminal


How to Mirror A Directory Locally Using Rsync

Most of the instructions for mirroring a directory with Rsync involve mirroring the data to a different server. You can also use Rsync to sync or mirror a directory on the same computer as the source directory.

Here is an example command on how to mirror two directories locally. In this example, /home/apache/public_html is the source directory and /home/apache/public_html_bak is the destination directory. Forward slashes at the end of the directory names in the rsync command are important so don’t forget them. The sync is one-way in that the destination will mirror the source:

rsync -avr --delete --links /home/apache/public_html/ /home/apache/public_html_bak/

If you need to preserve ACLs and Extended attributes then you need to add the -A and -X switches:

rsync -avrAX --delete --links /home/apache/public_html/ /home/apache/public_html_bak/

If you want to just do a dry run to see what will happen when you run Rsync, then add the -n switch:

rsync -avrAXn --delete --links /home/apache/public_html/ /home/apache/public_html_bak/

Terminal


How to Not Update a Package From a Specific Repository Using Yum

If you are using Yum to manage packages from multiple repositories it may be beneficial for you to not update a particular package against a specific repository in favor of another one. To do this, simply add the following line to the Yum configuration file for the repository you want to ignore:

exclude=packageName1 packageName2 packageName3

For example, say in CentOS 5 you wanted to not update the php-pecl-mailparse package against the Epel repository. You would edit the file /etc/yum.d/epel.repo and add the exclude line like so:

[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch                 
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basear$
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
exclude=php-pecl-mailparse

...

Terminal