Home Blog

How to install cron (crond, crontab)

Are you looking for crontab on a new install of CentOS 5? Well if you do a custom installation and don’t select anything then it will not be installed by default. In order to install it there just needs to be one package installed. See the below commands to install and setup crontab.

Use this command to install crontab, start the cron daemon, and turn it on at startup.

yum install vixie-cron crontabs
/sbin/chkconfig crond on
/sbin/service crond start

To edit crontab entries use the following command which will open up the crontab editor in vi the default text editor.

crontab -e

set default editor for crontab

export EDITOR=/usr/bin/nano

Originally posted 2016-02-29 00:42:04.

How To Create A RAID-1 Setup On A CentOS/RedHat 6.0 Server



This tutorial is for turning a single disk CentOS 6 system into a two disk RAID1 system. The GRUB bootloader will be configured in such a way that the system will still be able to boot if one of the hard drives fails (no matter which one).


NOTE: Everything has to be done as root:

su -
enter root password

In this example the initial layout for the hard disks was:

Disk with installed OS. “Original”

Device Mountpoint Size

/dev/sdb ~1002GB
/dev/sdb1 /boot 256MB
/dev/sdb2 / 24GB
/dev/sdb3 swap 4GB
/dev/sdb5 /var 4GB
/dev/sdb6 /home ~900GB

And we will be adding the other hard disk: /dev/sda (~1002GB). “Target disk”.

1. Back everything up! You might want to get your data back after you crashed the conversion. Trust me on this!

2. Verify Backup! See above.

3. Create partitions on /dev/sda identical to the partitions on /dev/sdb:

sfdisk -d /dev/sdb | sfdisk /dev/sda

4. We load a few kernel modules (to avoid a reboot):

modprobe linear
modprobe raid0
modprobe raid1

5. Now run:

cat /proc/mdstat

The output should look as follows:

[email protected]:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1]
unused devices: <none>

Here we see now that the RAID kernel modules are working, but there are no RAID sets yet.

6. Run the following commands:

mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda1 missing
mdadm --create /dev/md1 --level=1 --raid-disks=2 /dev/sda2 missing
mdadm --create /dev/md2 --level=1 --raid-disks=2 /dev/sda5 missing
mdadm --create /dev/md3 --level=1 --raid-disks=2 /dev/sda6 missing

This generates the raid devices 0 to 3 in a degenerated state because the second drive is missing.

7. If you want to use Grub 0.97 (default in CentOS 5 or 6)) on RAID 1, you need to specify an older version of metadata than the default. Add the option “–metadata=0.90” to the above command. Otherwise Grub will respond with “Filesystem type unknown, partition type 0xfd” and refuse to install. This is supposedly not necessary with Grub 2.

Like this:

mdadm --create /dev/md0 --metadata=0.90 --level=1 --raid-devices=2 /dev/sda1 missing

8. Check the output of

cat /proc/mdstat

#cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb2[1]
473792 blocks [2/2] [U_]

md2 : active raid1 sdb5[1]
4980032 blocks [2/2] [U_]

md3 : active raid1 sdb6[1]
3349440 blocks [2/2] [U_]

md0 : active raid1 sdb1[1]
80192 blocks [2/2] [U_]

unused devices: <none>

9. Create a mdadm.conf from your current configuration:

mdadm --detail --scan > /etc/mdadm.conf

10. Display the contents of the file:

cat /etc/mdadm.conf

At the bottom of the file you should now see details about our (degraded) RAID arrays.

11. We use dracut to rebuild the initramfs with the new mdadm.conf:

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.old
dracut --mdadmconf --force /boot/initramfs-$(uname -r).img $(uname -r)

12. Create the filesystems on these new software raid devices:

mkfs.ext2 /dev/md0 # For /boot ext2 is good
mkfs.ext4 /dev/md1 # For / ext4 is good
mkfs.ext4 /dev/md2 # For /home ext4 is good
mkfs.ext4 /dev/md3 # For /var ext4 is good
mkswap -c /dev/sda2 #We want swap partitions on both drives for performance

13. Copy the data from the existing (and still running) partitions to the newly created raid partitions:

mkdir /mnt/raid
mount /dev/md0 /mnt/raid
cd /boot; find . -depth | cpio -pmd /mnt/raid

(If SELinux is in use also do this:

touch /mnt/raid/.autorelabel


umount /mnt/raid
mount /dev/md1 /mnt/raid
cd / ; find . -depth -xdev | grep -v '^\./tmp/' | cpio -pmd /mnt/raid
umount /mnt/raid

NOTES: You really do not want to copy files in /tmp and /var/tmp.
This command will create empty mount points like ‘proc’ or ‘dev’ and will not forget things like /.autofsck.

mount /dev/md2 /mnt/raid
cd /var; find . -depth | cpio -pmd /mnt/raid sync umount /mnt/raid
mount /dev/md3 /mnt/raid
cd /home; find . -depth | cpio -pmd /mnt/raid
umount /mnt/raid

At this point we have our raid system created and the existing data was mirrored manually onto the new devices.
To make sure that the system will boot from the raid devices we have to change some entries in /etc/fstab and /boot/grub/menu.lst.

Originally posted 2016-02-28 00:25:01.

Linux Centos 6 Change Server Hostname

am a new CentOS Linux server user. How do I change hostname on CentOS Linux? How can I change server hostname on CentOS Linux  6?

You need to use the following commands to set or view current hostname, domain name and/or FQDN (Fully Qualified Domain Name):

  1. dnsdomainname command : Display the system’s DNS domain name.
  2. hostname command : Show or set the system’s host name.

You also need to edit the following files for a hostname change:

  1. /etc/sysconfig/network file.
  2. /etc/hosts file.

In this tutorial, I will show you how to set/change a server hostname in CentOS Linux to “server.servernoobs.com”.

Display current hostname

Type the following command:
# hostname
Sample outputs:


To display current domain name, type the following command:
# dnsdomainname
Sample outputs:


Hostname change procedure on CentOS

Open the terminal or login to the remote server using ssh client. Edit /etc/sysconfig/network file, enter:
# nano /etc/sysconfig/network
Find and modify HOSTNAME value to set to FADN such as server.servernoobs.com:


Save and close the file.

Edit hosts file

Edit /etc/hosts file, enter:
# nano /etc/hosts
You need to set or change the host that is set to your IP address on server. localhost server.servernoobs.com server  # Added by ServerNoobs

Save and close the file.

Set hostname manually without rebooting the box

Type the following command:
# hostname server.servernoobs.com

Restart the CentOS networking and other services (if any)

You need to restart the networking service on CentOS Linux, enter:
# service network restart
# /etc/init.d/network restart

Verify new hostnames

Simply type the following commands:
# hostname
# dnsdomainname

Originally posted 2016-02-27 00:16:25.

Installing Plex Media Server on Centos 6


Plex Media Server is a user-friendly way to store all your movies, shows, and other media in one place–and make it accessible from any device, whether you’re at home or on-the-go. If you’re looking for a no-headache way to watch your movies anywhere, this is it.

What Is Plex Media Server?

Here’s a common situation that all too many people find themselves in. You have media files–music, movies, TV shows, and even photos–but you don’t have an easy way to easily access them on your plentiful and varied devices.

Do you copy your Blu-ray rips over to your laptop? What about your phone–do you convert the files so they’re smaller and compatible? Do you fling shows to your TV via your desktop and Chromecast? Do you upload all your photos to your iCloud account to send them to your TV via Apple TV? What about your music? What if you’re away from home on a business trip and you want to stream your TV shows to your iPad?

Even for serious geeks with a lot of experience managing their media, it’s a huge pain to get all your devices talking and accessing the same collection. It doesn’t have to be that way, though. Plex is a centralized media server system that eliminates virtually every problem you run into while managing a large personal media collection.

The Plex model is simple: you park all your media on a single computer with the Plex server software installed, and then you install Plex on on all your other devices. You can install it on Windows, Linux, or Mac computers as well as Android and iOS, video game consoles like Xbox and PlayStation, your Apple TV, and there are even smart TVs that come with Plex built right in. Then, from any of those devices, you can remotely access your entire media library and watch it with no hassle.


1. Grab latest plex server

go to https://plex.tv/downloads and choose the one best match for you system

I got

wget http://downloads.plexapp.com/plex-media-server/

Install the package

rpm -i plexmediaserver-

Start the plex server

/etc/init.d/plexmediaserver start

Then from MY UBUNTU LAPTOP i run

ssh -f [email protected] -L 2000:localhost:32400 -N

Where is my ip to my centos/plex server

Then from MY UBUNTU LAPTOP i start chrome and browse to


And after plex is configures its up and running and you can start using plex.

Originally posted 2017-01-31 07:54:13.

ConfigServer Firewall : Binary location for [/usr/bin/host] in csf.conf is either incorrect, is not installed or is not executable

The following error may occur while reloading CSF (csf -r) :

*WARNING* Binary location for [HOST] [/usr/bin/host] in /etc/csf/csf.conf is either incorrect, is not installed or is not executable
*WARNING* Missing or incorrect binary locations will break csf and lfd functionality

In this particular case, CSF was installed on a CentOS 7 server and there wasn’t any “host” executable under /usr/bin.

To resolve this issue, just install the missing package which is provided by Bind Utilities (bind-utils) :

yum install bind-utils

Originally posted 2017-01-30 21:06:28.

Linux / UNIX: Create Large 1GB Binary Image File With dd Command

How do I create 1 GB or 10 GB image file instantly with dd command under UNIX / Linux / BSD operating systems using a shell prompt?

You can use dd command to create image files for network or file system testing. First, make sure you’ve sufficient disk space to create a image file using dd:


$ df -H
To create 1MB file (1024kb), enter:
$ dd if=/dev/zero of=test.img bs=1024 count=0 seek=1024
To create 10MB file , enter:
$ dd if=/dev/zero of=test.img bs=1024 count=0 seek=$[1024*10]
To create 100MB file , enter:
$ dd if=/dev/zero of=test.img bs=1024 count=0 seek=$[1024*100]
$ ls -lh test.img

To create 10GB, file:
$ dd if=/dev/zero of=10g.img bs=1000 count=0 seek=$[1000*1000*10]
Sample output:

0+0 records in
0+0 records out
0 bytes transferred in 0.000014 secs (0 bytes/sec)

Verify file size (note bs factor in original dd command):
$ ls -lh 10g
-rw-r–r– 1 root wheel 9.3G Jun 2 12:07 10g.img

Originally posted 2016-02-26 00:11:21.

CentOS: yum Command Reinstall Package


How do I re-install a package using the yum command under CentOS Linux server?

You can use the yum command with the reinstall option. This will reinstall the identical versioned package as currently installed. The syntax is as follows:

yum reinstall packageName
yum reinstall packageName1 packageName2

In this example reinstall a package called keepalived, type:
# yum reinstall keepalived
Sample outputs:

Loaded plugins: product-id, rhnplugin, subscription-manager
Updating certificate-based repositories.
Setting up Reinstall Process
Resolving Dependencies
--> Running transaction check
---> Package keepalived.x86_64 0:1.2.2-2.el6 will be reinstalled
--> Finished Dependency Resolution
Dependencies Resolved
 Package                             Arch                            Version                                 Repository                     Size
 keepalived                          x86_64                          1.2.2-2.el6                             epel                          147 k
Transaction Summary
Reinstall     1 Package(s)
Total download size: 147 k
Installed size: 380 k
Is this ok [y/N]: y
Downloading Packages:
keepalived-1.2.2-2.el6.x86_64.rpm                                                                                         | 147 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : keepalived-1.2.2-2.el6.x86_64                                                                                                 1/1
Installed products updated.
  keepalived.x86_64 0:1.2.2-2.el6

Originally posted 2016-02-24 23:55:53.

Nginx Redirect URL With HTTP/1.1 301 Moved Permanently Header

How do I redirect old ugly urls such as http://example.com/store/view.jsp?product=foo with clean url – http://example.com/store/view/product/foo using nginx reverse proxy?

You need to use HttpRewriteModule under nginx web server. This module makes it possible to change URI using regular expressions (PCRE), and to redirect and select configuration depending on variables. The syntax is as follows to chage URI in accordance with the regular expression and the replacement string.

rewrite regex replacement flag

Please note that directives are carried out in order of appearance in the configuration file. Here is sample configuration for the same:

# rewrite urls
rewrite ^/store/view/product/(.*) /store/view.jsp?product=$1  permanent;
## Uncomment the following line to redirect old urls with HTTP/301 ##
# rewrite "^/store/view.jsp?product=(.*)$" ^/store/view/product/$1 permanent;

Here is another example with try_files directive which checks for the existence of files in order, and returns the first file that is found:

### Add inside server { ... } directive block ###
### Only works with Nginx version 0.7.65+ ###
        location / {
                index store.php;
                try_files $uri $uri/ @ourcleanurls;
        # rewrite urls #
        location @ourcleanurls {
                rewrite ^/media/(.*) /includes/cache/helper.php?m=$1&images=1 last;
                rewrite ^/css/(.*) /includes/cache/helper.php?m=$1&css=1 last;
                rewrite ^/js/(.*) /includes/helper.php?m=$1&js=1&c=false last;
                rewrite ^/(.*) /store.php?pid=$1 last;

You need to reload the nginx server using the following command:
# /usr/local/nginx/sbin/nginx -s reload

How Do I Test New Changes?

You can use the curl command to test new changes including HTTP/1.1 301 Moved message:
$ curl -I http://example.com/store/view/product/foo
$ curl -I http://example.com/store/view.jsp?product=foo

Originally posted 2016-02-23 23:39:21.

Migrate from Mysql to MariaDB in cPanel/WHM

MariaDB is “An enhanced, drop-in replacement for MySQL”. Below you will find some steps on how to affectively stop cPanel/WHM from maintaining MySQL and begin utilizing MariaDB for any and all database activity on your server but please note that, cPanel/WHM no longer maintains MySQL on your system it is on the Systems Administrator to manage and maintain any updates and maintenance on the database software. We recommend only experienced systems administrators perform the steps below and we are not responsible for any possible data loss.

Step 1: Backup existing MySQL data

Make sure to save all existing data just in case there are any issues.

cp -Rf /var/lib/mysql /var/lib/mysql-old
mv /etc/my.cnf /etc/my.cnf-old

Step 2: Disable the targets so cPanel no longer handles MySQL updates

The following will mark the versions of MySQL we distribute as uninstalled so they are no longer maintained by cPanel/WHM

/scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
/scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
/scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled

Step 3: Remove existing MySQL RPM’s so theres a clean slate for MariaDB

Important: The below command will uninstall the MySQL RPM’s!

/scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55
[20130623.211100]   The following RPMs are unneeded on your system and should be uninstalled:
[20130623.211100]   MySQL55-client.5.5.31-1.cp1136
[20130623.211100]   MySQL55-devel.5.5.31-1.cp1136
[20130623.211100]   MySQL55-server.5.5.31-1.cp1136
[20130623.211100]   MySQL55-shared.5.5.31-1.cp1136
[20130623.211100]   MySQL55-test.5.5.31-1.cp1136
[20130623.211100]   Removing 0 broken rpms: 
[20130623.211100]   rpm: no packages given for erase
[20130623.211100]   No new RPMS needed for install
[20130623.211100]   Uninstalling unneeded rpms: MySQL55-test MySQL55-server MySQL55-client MySQL55-shared MySQL55-devel

Step 4: Create a yum repository for MariaDB

Access https://downloads.mariadb.org/mariadb/repositories and select the DISTRO and place the repo content to /etc/yum.repos.d/MariaDB.repo

EX (In my cause):

#nano /etc/yum.repos.d/MariaDB.repo

# MariaDB 5.5 CentOS repository list - created 2013-06-23 21:13 UTC
# http://mariadb.org/mariadb/repositories/
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64

Step 5: install MariaDB using the  following command

yum install MariaDB-server MariaDB-client MariaDB-devel

##If you are having any dependency problem, please remove php from the /etc/yum.conf file and then run yum  command again. Please add it back to yum conf once the package is installed. 

/etc/init.d/mysql start
/etc/init.d/mysql restart

Final Step: Rebuild easyapache/php to ensure modules are intact/working

/scripts/easyapache --build


Originally posted 2016-02-22 23:25:29.

Install EPEL Repo on a CentOS and RHEL 7

How do I install the extra repositories such as Fedora EPEL repo on a Red Hat Enterprise Linux server version 7.x or CentOS Linux server version 7.x?

You can easily install various packages by configuring a CentOS 7 or RHEL 7 system to use Fedora EPEL repos and third party packages. Please note that these packages are not officially supported by either CentOS or Red Hat, but provides many popular packages and apps.

How to install RHEL EPEL repository on Centos 7 or RHEL 7

The following instuctions assumes that you are running command as root user on a CentOS/RHEL 7 system and want to use use Fedora Epel repos.

Install the extra EPEL repositories

The command is as follows to download epel release for CentOS and RHEL 7 using wget command:

cd /tmp
wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
ls *.rpm

To install epel-release-7-0.2.noarch.rpm, type:

sudo yum install epel-release-7-0.2.noarch.rpm

Sample outputs:

Loaded plugins: amazon-id, rhui-lb
Examining epel-release-7-0.2.noarch.rpm: epel-release-7-0.2.noarch
Marking epel-release-7-0.2.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-0.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package             Arch          Version         Repository                         Size
 epel-release        noarch        7-0.2           /epel-release-7-0.2.noarch         22 k
Transaction Summary
Install  1 Package
Total size: 22 k
Installed size: 22 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-0.2.noarch                                               1/1
  Verifying  : epel-release-7-0.2.noarch                                               1/1
  epel-release.noarch 0:7-0.2

List your new repos

Once installed you should see epel repo using the following yum repolist command
$ sudo yum repolist
Sample outputs:

Loaded plugins: amazon-id, rhui-lb
repo id                                         repo name                            status
epel/x86_64                                     Extra Packages for Enterprise Linux  4,444
rhui-REGION-client-config-server-7/x86_64       Red Hat Update Infrastructure 2.0 Cl     1
rhui-REGION-rhel-server-releases/7Server/x86_64 Red Hat Enterprise Linux Server 7 (R 4,457
repolist: 8,902

Search and install package

To list all available packages under a repo called epel, enter:
$ sudo yum --disablerepo="*" --enablerepo="epel" list available
$ sudo yum --disablerepo="*" --enablerepo="epel" list available | grep 'package'
$ sudo yum --disablerepo="*" --enablerepo="epel" list available | less

Example: Search and install htop package from epel repo on a CentOS/RHEL 7.x

The commands are as follows:

## search it ##
sudo yum search htop
## get more info, if found ##
sudo yum info htop
## install it ##
sudo yum install htop

And, there you have it, a larger number of packages to install from EPEL repo on a CentOS and Red Hat Enterprise Linux (RHEL) version 7.x.

Originally posted 2016-02-21 23:12:55.