Skip to main content

Posts

Finding multiple folders in Linux with single command

Finding multiple folders with single commend on Linux is not a big deal.

I wanna know all temp / tmp and cache folders in websites, that are configured with WHM to exclude from the backup. Here is the command for that,


find /home/*/public_html \( -type d -iname "cache" -or -iname "tmp" -or -iname "temp" \)

To know size of these folders,

find /home/*/public_html \( -type d -iname "cache" -or -iname "tmp" -or -iname "temp" \) -exec du -sh {} \;
Recent posts

Finding files with in date range

Here is the command for find files that was modifed between 1st July 2018 to 20th July 2018 with it's details,

find . -type f -name "*.php" -newermt 2018-07-01 ! -newermt 2018-07-21 -exec ls -l {} \;

Please note, you have to mention next date of till date.

Shell script for read line from text file

My need:


Read line from the text file by shell script and append few text before and after the line.

Script:

#!/bin/bash
file="/root/scource.txt"
while IFS= read -r line
do
                echo -e "        <User>"
                echo -e "            <Path>$line</Path>"
                echo -e "        </User>"
done <"$file"


cat source.txt

/home/kumar
/home/moulee
/home/admin

Output:
<User>
  <Path>/home/kumar</Path>
</User>
<User>
  <Path>/home/moulee</Path>
</User>
<User>
  <Path>/home/admin </Path>
</User>

Copy all Incoming Outgoing Emails - Employee monitor

How can we monitor employee's email conversations ?

If we are running company, It's too impotent to monitoring employee's email conversations which is traveled by company domain name. If you are using WHM with Exim mail server, it's too easy.

Let's consider "domain.com" is your company domain, you have 50's of mail IDs. You are having a mail ID "monitor@domain.com" and you need to archive / monitor all your mails incoming and outgoing mails to "monitor@domain.com".

To do this, you must have access to server with ssh (root access) and WHM (root access).

1. "/usr/local/cpanel/etc/exim/sysfilter/options"is path where you can store all custom filters.

#cd /usr/local/cpanel/etc/exim/sysfilter/options

2. Create a empty file for store your filter rules. You can create as much of filter as you want, so create a file with understandable name with domain name, replace domain_com to your company domain name.

#vim incoming_outgoing_do…

Device eth0 does not seem to be present, delaying initialization - Virtual Box Error - CentOS 6.6

Hello everyone,

Today I've faced an error on Virtual Box with CentOS 6.6 today, If you are frequently use virtual machines, you'll see these kind of errors. Let's explain my situation.
I've installed and used CentOS 6.6 for python before 2 months, later I've deleted it's account (not files) from Virtual Box because of no frequent use. Today I need to test something on that server. So I've created account and pointed this virtual machine to newly created account.
Once server up, logged to server and tried to ping for check the network. Network not succeeded, when I check IP with ifconfig, I can see only loopback network. "service network restart" says "Device eth0 does not seem to be present, delaying initialization".

Okay, What is solution now ?

Reason for this issue: When we install guest OS with virtual box, It'll assign mac address to it's guest OS's device. But in our case, we have installed guest OS already and it alrea…

Increase WordPress URL Length

Hello Guys,

I'm back here after a long period. Today I would like to share the simple trick for WordPress Blogging. If you need to increase URL length in wordpress sites, do following things.

1. On page "wp-includes/formatting.php" find the following line and change the value that mention as Bold

function sanitize_title_with_dashes

$title = utf8_uri_encode($title, 300);

2. In database, find the table and change the value of table field.
wp_post => post_name => varchar 300

============================

Drawback of this setup

Whenever WordPress release update and you update your website, the default setting will be over write.

But, It won't affect the custom URL that you have assigned to the post. So that old URLs may not work until you do the same URL length increasing process.

Installing PHP 5.6 on Ubuntu Server 14.04.4 LTS

Hello Beginners,

Hopefully most of the Sys Admin kids won't consider about LTS (Long Term Support) or EOL (End Of Life) on product.

Every product have it's version and its end of life, you can see about EOL of php by following link.

http://php.net/supported-versions.php
http://php.net/eol.php

As same Ubuntu have

https://wiki.ubuntu.com/LTS

Okay now, why we discuss about it,
Ubuntu 14.04.4 LTS is latest product of Ubuntu which have Long Term Support, PHP 5.5 is php version support by Ubuntu 14.04.4 LTS, that means php in it's EOL. So it's good to install Ubuntu 14.04.4 with PHP 5.6

Normal repo of Ubuntu don't have PHP 5.6, so we can do following steps to install PHP.

$sudo add-apt-repository ppa:ondrej/php5-5.6
$sudo apt-get update
$sudo apt-get install php5
$php5 -v

That's it.

Enabling Modules in PHP5 & Apache2 @ Ubuntu 14.04.4 LTS

Usually beginners of LAMP administrator having trouble to installing and enabling modules of PHP and Apache2

In older days we can do this by config page or by linking modules location to PHP or Apache module enable location, but we can do same with following comments easily, Please note this is advisable if you using Ubuntu repository to install packages.

Enabling module for Apache2

$sudo a2enmod module_name

Ex.

$sudo a2enmod rewrite

Enabling module for PHP5

$sudo php5enmod module_name

Ex.
$sudo php5enmod mcrypt