Example

Remove logs older than 5 days

# find /var/log* -mtime +5 -exec rm {} \;
rm: cannot remove `/var/log/tomcat6': Is a directory
rm: cannot remove `/var/log/proftpd': Is a directory
rm: cannot remove `/var/log/clamav': Is a directory
rm: cannot remove `/var/log/prelink': Is a directory
rm: cannot remove `/var/log/sssd': Is a directory
rm: cannot remove `/var/log/roundcubemail': Is a directory
rm: cannot remove `/var/log/samba': Is a directory
rm: cannot remove `/var/log/samba/old': Is a directory
rm: cannot remove `/var/log/ConsoleKit': Is a directory
rm: cannot remove `/var/log/ntpstats': Is a directory
rm: cannot remove `/var/log/mailman': Is a directory
rm: cannot remove `/var/log/cups': Is a directory
rm: cannot remove `/var/log/audit': Is a directory

In a typical UNIX/LINUX-style file listing, a file will be displayed in the following way:

ls -l index.php

Output:

-rw-r--r--. 1 www-data www-data 405 Nov 14 01:45 index.php

The first character indicates the file type. It can be a regular file (-), directory (d), a symbolic link (l), or other special types of files. The following nine characters represent the file permissions, three triplets of three characters each. The first triplet shows the owner permissions, the second one group permissions, and the last triplet shows everybody else permissions.

-rw-r--r--.

r stands for read permission;
w stands for write permission;
x stands for execute permission.

The permissions are divided into three parts.

The first three characters after the initial – are (rw-) are for Owner permissions. The owner of the file, the user “www-data”, can read the file and write (modify) it.

The next three characters (r–) are for group permissions. Members of the group “www-data” can read the file.

The last three characters (r–) are for other (world) permissions. These are the permissions for everyone else on the system. Users other than “group” who are not members of the “www-data” group can only read the file.

For directories, the permissions have a slightly different meaning.

For example:

ls -la
drwxr-xr-x  8 www-data www-data  4096 Feb 21 11:28 wp-content

Read determines if the user can get a list of the files in the directory;

Write determines if the user can create or delete files in the directory. A point of interest in this case is that if a user has write access to the directory, the user can delete files that are in that directory even if the username has no write permissions for the particular files;

Execute determines if the user can cd into the directory.

To summarize:

In this case, the owner, user, can do just about anything in the directory. Members of the group staff can list the contents of the directory and browse it. No one else is allowed access to the directory. Permissions are also often represented by digits. For example, 755 is the same as

-rwxr-xr-x.

The permission bits correspond to a certain number: 4 stands for r, 2 for w, 1 for x.

The reason for this is that in binary 100 (r–) is 4 in decimal; 10 (or 010, -w-) in binary is 2; and 1 (or 001, –x) in binary is 1 in decimal.

This allows for adding the numbers together, which can give a number from 0 to 7 for each of the three parts of the permissions set.

Here is a nice grid.

-rw-r--r-- 8 www-data www-data 12.0K Apr  28 10:10 file_name
|[-][-][-]-   [------] [---]
| |  |  | |      |       |
| |  |  | |      |       +-----------> 7. Group
| |  |  | |      +-------------------> 6. Owner
| |  |  | +--------------------------> 5. Alternate Access Method
| |  |  +----------------------------> 4. Others Permissions
| |  +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type

Here are several ways to kill all the processes in linux.
Where username is my userid.


# pkill -u username

or


# ps -o pid -u pu | xargs kill -1


# pgrep -u username | sudo xargs kill -9 

Show processes run for a username and sshd


# pgrep -u username sshd

SMART (Self-Monitoring, Analysis, and Reporting Technology) allows you to see the status or overall health of a hard drive. This information is instumental in providing warning signs of problems with a hard drive.

All Linux distributions provide the smartmontools package, which contain the smartctl program used to display SMART information from attached drives. This package also provides the smartd daemon which periodically polls the drives to obtain SMART information.

Using smartd is essential as it can let you know immediately when a SMART attribute fails.

With the -i option, you can view the type of drive, its serial number, and so forth. In a system with a lot of drives, having this information recorded can assist in knowing which drive device (i.e., /dev/sda) corresponds with which physical drive.

Install:

# yum install smartmontools

Now start the service of Smartctl.


#service smartd start 
# chkconfig smartd on

To enable Smart Capability for the disk run below command.

#smartctl -s on /dev/sdb

To disable Smart Capability for the disk run below command.


#smartctl -s off  /dev/sdb

To display details Smart info for the disk run below command.


#smartctl -a /dev/sdb              // For IDE drive
#smartctl -a -d ata /dev/sdb       // For SATA drive

To begin, see what the drive details are:


[root@austin ~]# fdisk -l

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          62      497983+  83  Linux
/dev/sda2              64         584     4184932+  82  Linux swap / Solaris
/dev/sda3             585       30390   239416695   82  Linux swap / Solaris

Now we know the single drive is sda. Also, you can usually identify which hard disks are on your system by
looking in /proc/ide and in /proc/scsi.

# smartctl -i /dev/sda
root@austin ~]# smartctl -i /dev/sda
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.el6.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital RE3 Serial ATA
Device Model:     WDC WD2502ABYS-18B7A0
Serial Number:    WD-WCAT19910234
LU WWN Device Id: 5 0014ee 157014252
Firmware Version: 02.03B04
User Capacity:    250,000,000,000 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Thu Nov 27 16:10:20 2014 MST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

[root@austin ~]# smartctl -i /dev/sda
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.el6.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital RE3 Serial ATA
Device Model:     WDC WD2502ABYS-18B7A0
Serial Number:    WD-WCAT19910234
LU WWN Device Id: 5 0014ee 157014252
Firmware Version: 02.03B04
User Capacity:    250,000,000,000 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Thu Nov 27 16:14:54 2014 MST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Now, edit /etc/smartd.conf and add entries for your drives:


/dev/sda -d ata -H -m root
/dev/sdb -d ata -H -m root

Turn the service on:


# chkconfig smartd on
# service smartd start

The smartctl program also allows for you to view and test SMART attributes of a drive. You can quickly check the overall health of a drive by using:

# smartctl -H /dev/sda

smartctl can be used to initiate long and short tests for the drive. These should be run periodically to do quick, or full, self-tests of the drive:


# smartctl --test=short /dev/sda
# smartctl --test=long /dev/sda
# smartctl -a /dev/sda

More info : https://wiki.archlinux.org/index.php/S.M.A.R.T.

Source: http://kb.odin.com/en/118378

php version – php-5.4.31

CentOS 6.5
Plesk Panel 12.0
Current php version 5.3

1. SSH to your Plesk server (or Apache Service Node for Parallels Plesk Automation) as root, download the PHP source, unpack it, and configure it:

# cd /usr/local/src
# mkdir php540
# cd php540
# wget http://www.php.net/get/php-5.4.31.tar.gz/from/at2.php.net/mirror
# tar xzvf php-5.4.0.tar.gz
# cd php-5.4.0
# ./configure '--with-libdir=lib64' '--cache-file=../config.cache' '--prefix=/usr/local/php540-cgi' '--with-config-file-path=/usr/local/php540-cgi/etc' '--disable-debug' '--with-pic' '--disable-rpath' '--enable-fastcgi' '--with-bz2' '--with-curl' '--with-freetype-dir=/usr/local/php540-cgi' '--with-png-dir=/usr/local/php540-cgi' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr/local/php540-cgi' '--with-openssl' '--with-pspell' '--with-pcre-regex' '--with-zlib' '--enable-exif' '--enable-ftp' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--with-unixODBC=/usr' '--enable-shmop' '--enable-calendar' '--without-sqlite3' '--with-libxml-dir=/usr/local/php540-cgi' '--enable-pcntl' '--with-imap' '--with-imap-ssl' '--enable-mbstring' '--enable-mbregex' '--with-gd' '--enable-bcmath' '--with-xmlrpc' '--with-ldap' '--with-ldap-sasl' '--with-mysql=/usr' '--with-mysqli' '--with-snmp' '--enable-soap' '--with-xsl' '--enable-xmlreader' '--enable-xmlwriter' '--enable-pdo' '--with-pdo-mysql' '--with-pdo-pgsql' '--with-pear=/usr/local/php540-cgi/pear' '--with-mcrypt' '--enable-intl' '--without-pdo-sqlite' '--with-config-file-scan-dir=/usr/local/php540-cgi/php.d'

Note: You MUST USE THE PREFIX SWITCH in order for your new PHP to be installed inside a single directory. As you can see, the prefix here is /usr/local/php540-cgi/

Note: Above are the sample command line arguments you may encounter with errors regarding the absence of a package (e.g. mysql-devel). The default arguments are described in the documentation

Choosing a prefix is very important because it prevents your new PHP installation from interfering with the other PHP installations available on the server.

Compile and install PHP:

# make
# make install

Set up php.ini:

# cp php.ini-development /usr/local/php540-cgi/php.ini

You can edit the php.ini file to set PHP options. If you prefer having php.ini in another location, run the configure utility with the option –with-config-file-path=/some/path in step #1.

Register the new PHP version:

In Parallels Plesk Panel

    /usr/local/psa/bin/php_handler --add -displayname  -path  -phpini  -type  -id 

where

-displayname is the PHP version name that will be shown in the Plesk UI. We recommend you include the version number in the displayname. For example, you could name the version “5.3.3-custom”.

-path is the location of the PHP CGI binary file. You can find this in the output of the command make install in the line Installing PHP CGI binary. For example, if you see the line Installing PHP CGI binary: /usr/local/bin/, the location you need to specify is /usr/local/bin/php-cgi. Learn more at the Official PHP web Site.

-phpini is the location of the php.ini file, for example, /some/path/php.ini .

-type is the type of the PHP handler associated with this version. Learn more about PHP handlers in the section: PHP Handlers.

Important: You can set either the CGI or FastCGI PHP handler. mod_php is not supported.
-id (optional) is the identifier you will use when referring to this PHP version (for example, when adjusting or removing it).

Compile errors.

Error:

#error: xml2-config not found. Please check your libxml2 installation

Solution:

# yum install libxml2-devel

Error:

#configure: error: Cannot find OpenSSL's 

Solution:

# yum install openssl-devel

Error:

# configure: error: Please reinstall the BZip2 distribution

Solution:

# yum install bzip2-devel

Error:

# configure: error: jpeglib.h not found.

Solution:

# yum install libjpeg-devel

Error:

# configure: error: png.h not found.

Solution:

# yum install libpng-devel

Error:

# Configure: error: freetype.h not found.

Solution:

# yum install freetype-devel

Error:

# Configure: error: Unable to locate gmp.h

Solution:

# yum install gmp-devel

Error:

# configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Solution:

# yum install libc-client-devel 

Error: Multilib version problems found. This often means that the root
cause is something else and multilib version checking is just
pointing out that there is a problem. Eg.:

1. You have an upgrade for libc-client which is missing some
dependency that another package requires. Yum is trying to
solve this by installing an older version of libc-client of the
different architecture. If you exclude the bad architecture
yum will tell you what the root cause is (which package
requires what). You can try redoing the upgrade with
–exclude libc-client.otherarch … this should give you an error
message showing the root cause of the problem.

2. You have multiple architectures of libc-client installed, but
yum can only see an upgrade for one of those arcitectures.
If you don’t want/need both architectures anymore then you
can remove the one with the missing update and everything
will work.

3. You have duplicate versions of libc-client installed already.
You can use “yum check” to get yum show these errors.

…you can also use –setopt=protected_multilib=false to remove
this checking, however this is almost never the correct thing to
do as something else is very likely to go wrong (often causing
much more problems).

Protected multilib versions: libc-client-2007e-11.el6.i686 != libc-client-2007e-11.el6.art.x86_64
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

I searched and the fix was to enable the atomic repo that was installed but disabled.

nano /etc/yum.repos.d/atomic
enabled = 1
# configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
# yum install libicu-devel
# configure: error: mcrypt.h not found. Please reinstall libmcrypt.
# yum install libmcrypt libmcrypt-devel

Then I got another:

Error: Package: libmcrypt-devel-2.5.7-5.el6.art.x86_64 (atomic)
Requires: libmcrypt = 2.5.7-5.el6.art
Installed: libmcrypt-2.5.8-9.el6.x86_64 (@epel)
libmcrypt = 2.5.8-9.el6
Available: libmcrypt-2.5.7-5.el6.art.x86_64 (atomic)
libmcrypt = 2.5.7-5.el6.art
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

I disabled atomic repo and then got:

Error: Package: libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64 (rpmforge)
Requires: libmcrypt = 2.5.7-1.2.el6.rf
Installed: libmcrypt-2.5.8-9.el6.x86_64 (@epel)
libmcrypt = 2.5.8-9.el6
Available: libmcrypt-2.5.7-1.2.el6.rf.x86_64 (rpmforge)
libmcrypt = 2.5.7-1.2.el6.rf
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

I disabled rpmforge repo enabled the epel repo.

# configure: error: Cannot find MySQL header files under /usr.
# yum install mysql-devel
# configure: error: ODBC header file '/usr/include/sqlext.h' not found!
# yum install unixODBC-devel
# configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
# yum install postgresql-devel
# configure: error: Cannot find pspell
#yum install aspell-devel
# configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
# yum install net-snmp-devel
# error: xslt-config not found
# yum install libxslt-devel

PHP error for fastcgi

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
configure: WARNING: unrecognized options: --enable-fastcgi

From – http://php.net/manual/en/configure.about.php

-enable-fastcgi
If this is enabled, the CGI module will be built with support for FastCGI also. Available since PHP 4.3.0
As of PHP 5.3.0 this argument no longer exists and is enabled by –enable-cgi instead.

So, I changed the option:

# --enable-fastcgi

to

# --enable-cgi

New configure string:

 ./configure '--with-libdir=lib64' '--cache-file=../config.cache' '--prefix=/usr/local/php540-cgi' '--with-config-file-path=/usr/local/php540-cgi/etc' '--disable-debug' '--with-pic' '--disable-rpath' '--enable-cgi' '--with-bz2' '--with-curl' '--with-freetype-dir=/usr/local/php540-cgi' '--with-png-dir=/usr/local/php540-cgi' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr/local/php540-cgi' '--with-openssl' '--with-pspell' '--with-pcre-regex' '--with-zlib' '--enable-exif' '--enable-ftp' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--with-unixODBC=/usr' '--enable-shmop' '--enable-calendar' '--without-sqlite3' '--with-libxml-dir=/usr/local/php540-cgi' '--enable-pcntl' '--with-imap' '--with-imap-ssl' '--enable-mbstring' '--enable-mbregex' '--with-gd' '--enable-bcmath' '--with-xmlrpc' '--with-ldap' '--with-ldap-sasl' '--with-mysql=/usr' '--with-mysqli' '--with-snmp' '--enable-soap' '--with-xsl' '--enable-xmlreader' '--enable-xmlwriter' '--enable-pdo' '--with-pdo-mysql' '--with-pdo-pgsql' '--with-pear=/usr/local/php540-cgi/pear' '--with-mcrypt' '--enable-intl' '--without-pdo-sqlite' '--with-config-file-scan-dir=/usr/local/php540-cgi/php.d'

And, no errors

License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

Error with "make"
# make
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

You need to install the Tools needed for development using the GNU Libtool Dynamic Module Loader

yum install libtool-ltdl-devel

Then ran –

# make clean

# make

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
invertedregexiterator.inc
clicommand.inc
directorytreeiterator.inc
directorygraphiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

# make test

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype < 2.4.10 [ext/gd/tests/bug43073.phpt]
gmp_gcdext() basic tests [ext/gmp/tests/022.phpt]
Bug #64124 IPv6 malformed [ext/snmp/tests/bug64124.phpt]
Bug #64159: Truncated snmpget [ext/snmp/tests/bug64159.phpt]
IPv6 support [ext/snmp/tests/ipv6.phpt]
OO API: getErrno & getError methods [ext/snmp/tests/snmp-object-errno-errstr.phpt]
OO API [ext/snmp/tests/snmp-object.phpt]
Function snmp2_get [ext/snmp/tests/snmp2_get.phpt]
Function snmp2_getnext [ext/snmp/tests/snmp2_getnext.phpt]
Function snmp2_real_walk [ext/snmp/tests/snmp2_real_walk.phpt]
Function snmp2_set (without MIBs loading) [ext/snmp/tests/snmp2_set-nomib.phpt]
Function snmp2_set [ext/snmp/tests/snmp2_set.phpt]
Function snmp2_walk [ext/snmp/tests/snmp2_walk.phpt]
SNMPv3 Support (errors) [ext/snmp/tests/snmp3-error.phpt]
SNMPv3 Support [ext/snmp/tests/snmp3.phpt]
Function snmp_getvalue [ext/snmp/tests/snmp_getvalue.phpt]
Function snmpget [ext/snmp/tests/snmpget.phpt]
Function snmpgetnext [ext/snmp/tests/snmpgetnext.phpt]
Function snmprealwalk [ext/snmp/tests/snmprealwalk.phpt]
Function snmpset (without MIBs loading) [ext/snmp/tests/snmpset-nomib.phpt]
Function snmpset [ext/snmp/tests/snmpset.phpt]
Function snmpwalk [ext/snmp/tests/snmpwalk.phpt]
Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using UTF-* [ext/xml/tests/bug32001.phpt]
=====================================================================

=====================================================================
WARNED TEST SUMMARY
---------------------------------------------------------------------
zend multibyte (2) [ext/mbstring/tests/zend_multibyte-02.phpt] (warn: XFAIL section but test passes)
zend multibyte (6) [ext/mbstring/tests/zend_multibyte-06.phpt] (warn: XFAIL section but test passes)
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]:

# make install

[root@austin php-5.4.31]# make install
Installing PHP CLI binary:        /usr/local/php540-cgi/bin/
Installing PHP CLI man page:      /usr/local/php540-cgi/php/man/man1/
Installing PHP CGI binary:        /usr/local/php540-cgi/bin/
Installing PHP CGI man page:      /usr/local/php540-cgi/php/man/man1/
Installing build environment:     /usr/local/php540-cgi/lib/php/build/
Installing header files:          /usr/local/php540-cgi/include/php/
Installing helper programs:       /usr/local/php540-cgi/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php540-cgi/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php540-cgi/pear/
[PEAR] Archive_Tar    - installed: 1.3.11
[PEAR] Console_Getopt - installed: 1.3.1
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.3
[PEAR] PEAR           - installed: 1.9.5
Wrote PEAR system config file at: /usr/local/php540-cgi/etc/pear.conf
You may want to add: /usr/local/php540-cgi/pear to your php.ini include_path
/usr/local/src/php540/php-5.4.31/build/shtool install -c ext/phar/phar.phar /usr/local/php540-cgi/bin
ln -s -f /usr/local/php540-cgi/bin/phar.phar /usr/local/php540-cgi/bin/phar
Installing PDO headers:          /usr/local/php540-cgi/include/php/ext/pdo/

# cp php.ini-development /usr/local/php540-cgi/etc/php.ini
# /usr/local/psa/bin/php_handler --add -displayname 5.4.31-custom -path /usr/local/php540-cgi/bin/ -phpini /usr/local/php540-cgi/etc/php.ini -type fastcgi -id php-5.4.31
ini -type fastcgi -id php-5.4.31
[2014-08-15 21:38:16] ERR [util_exec] proc_close() failed
Unable to register the PHP handler: can not get version from /usr/local/php540-cgi/bin/

Changed the path to – /usr/local/php540-cgi/bin/php-cgi

/usr/local/psa/bin/php_handler --add -displayname 5.4.31-custom -path /usr/local/php540-cgi/bin/php-cgi -phpini /usr/local/php540-cgi/etc/php.ini -type fastcgi -id 5.4.31-custom
The new PHP handler with the id "5.4.31-custom" was successfully registered.

The – login to plesk and thenew php is regsitered and can be selected.

new-php-plesk

There is also a great article for Plesk and the REMI Repo install. http://kb.sp.parallels.com/en/115833