Category: Centos

            • Authentication Token Manipulation Error

              You may get an error, such as Authentication Token Manipulation Error, while trying to change passwords for a user. For example:

              #passwd user
              Authentication Token Manipulation Error
              #

              This error is being produced because you are using shadowed password files and the shadow doesn’t have entry for this user. i.e, passwd file has an entry for this user, but shadow file doesn’t.

              In order to resolve this, you can either add the entry manually or recreate the shadow file. You can use pwconv to recreate the shadow file. See the manpage for more details on this.

            • How to enable Status in apache

              Add this to your httpd.conf file:

              ExtendedStatus On

              <Location /server-status>
              SetHandler server-status
              Order Deny,Allow
              Deny from all
              Allow from 127.0.0.1
              </Location>

            • How to clear SWAP

              It happens for swap to be used from time to time :

              root@servcorp:~# free -m
              total used free shared buffers cached
              Mem: 4011 759 3252 0 4 53
              -/+ buffers/cache: 702 3309
              Swap: 8191 15 8176

              To clear the swap run :

              root@servcorp:~# swapoff -a && swapon -a

              And free shows :

              root@servcorp:~# free -m
              total used free shared buffers cached
              Mem: 4011 746 3265 0 4 55
              -/+ buffers/cache: 686 3325
              Swap: 8191 0 8191

            • How to clear cached RAM

              sync; echo 3 > /proc/sys/vm/drop_caches; echo 0 > /proc/sys/vm/drop_caches; sync

            • Install ruby on cPanel

              Under cPanel 11 you can install Ruby by running /scripts/installruby. This will install both ruby and rubygems.

              root@main [~]# ruby -v
              ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux]

              root@main [~]# gem list

              *** LOCAL GEMS ***

              actionmailer (2.3.11)
              actionpack (2.3.11)
              activerecord (2.3.11)
              activeresource (2.3.11)
              activesupport (2.3.11)
              cgi_multipart_eof_fix (2.5.0)
              daemons (1.1.4)
              fastthread (1.0.7)
              gem_plugin (0.2.3)
              mongrel (1.1.5)
              rack (1.1.2)
              rails (2.3.11)
              rake (0.9.2)
              rubygems-update (1.8.5)

            • Installing mod_suphp

              Usually if you add a simple VirtualHost and set the DocumentRoot into on /home/ then its possible for some files not to be owned by that (e.g: uploaded images via web interface, php sessions..etc).

              A solution for this problem is to install mod_suphp which will make Apache to write in /home/ with permissions. To install mod_suphp :

              Download http://www.suphp.org/download/suphp-0.7.1.tar.gz
              tar zxvf suphp-0.7.1.tar.gz
              cd suphp-0.7.1
              yum install httpd-devel
              ./configure --with-apxs=/usr/sbin/apxs --with-apache-user=httpd --with-logfile=/var/log/httpd/suphp.log --with-setid-mode=paranoid --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-php=/usr/bin/php-cgi --enable-SUPHP_USE_USERGROUP=yes
              make
              make install
              cd /etc/httpd/conf.d/
              mv php.conf php.conf.bk

              Then create suphp.conf and put in it:

              LoadModule suphp_module modules/mod_suphp.so
              suPHP_Engine on
              AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml

              suPHP_AddHandler application/x-httpd-php5

              Then create /etc/suphp.conf and put in it:

              ; This file is parse anew by suPHP for each request
              ; rather than being loaded once.

              [global]
              ;Path to logfile
              logfile=/var/log/httpd/suphp.log

              ;Loglevel
              loglevel=info

              ;User Apache is running as
              ; MANDATORY
              webserver_user=apache

              ; Path all scripts have to be in
              ; This works as a prefix when a trailing slash is not specified.
              ; e.g. /home will match /home /home2 /home3 etc While /home/ will only match /home/
              ;
              ; Changing this to a more specific path will improve security
              docroot=/

              ;Path to chroot() to before executing script
              ;chroot=/home

              ; Security options
              allow_file_group_writeable=true
              allow_file_others_writeable=true
              allow_directory_group_writeable=true
              allow_directory_others_writeable=true

              ; Check whether script is within DOCUMENT_ROOT
              ; Does NOT perform this check on included scripts.
              ; i.e. include_once("/test3.php"); works even though it's in the root directory
              ;
              ; Changing this to true will improve security but make all php userdir requests fail
              check_vhost_docroot=false

              ; Allow the user and group specified by a ~userdir request to override the
              ; suPHP_UserGroup directive inside the source virtualhost
              ;
              ; Changing this to false will improve security but make some types of php userdir
              ; requests fail
              ;userdir_overrides_usergroup=true

              ; suPHP Paranoid mode checks that the target script UID and GID match
              ; the UID and GID of the user running the script. To disable these
              ; checks change the following values to false. Without these checks, mod_suphp
              ; is effectively running in "Force" mode.
              ;paranoid_uid_check=true
              ;paranoid_gid_check=true

              ;Send minor error messages to browser
              errors_to_browser=false

              ;PATH environment variable
              env_path="/bin:/usr/bin"

              ;Umask to set, specify in octal notation
              umask=0022

              ; Minimum UID
              ;min_uid=100

              ; Minimum GID
              ;min_gid=100

              ; Normally suPHP only displays the PHP binary in process lists (ps aux).
              ; Setting this option to 'true' will cause suPHP to display both the
              ; PHP binary and the script filename.
              ;full_php_process_display=true

              [handlers]
              ;Handler for php-scripts
              application/x-httpd-php="php:/usr/bin/php-cgi"
              application/x-httpd-php4="php:/usr/php4/bin/php-cgi"
              application/x-httpd-php5="php:/usr/bin/php-cgi"

              ;Handler for CGI-scripts
              ;x-suphp-cgi="execute:!self"

              [phprc_paths]
              ;Uncommenting these will force all requests to that handler to use the php.ini
              ;in the specified directory regardless of suPHP_ConfigPath settings.
              ;application/x-httpd-php=/usr/local/lib/
              ;application/x-httpd-php4=/usr/local/php4/lib/
              ;application/x-httpd-php5=/usr/local/lib/

              After this make sure that the VirtualHost contains :



              suPHP_UserGroup user user


              SuexecUserGroup user user

              Also /etc/httpd/conf/httpd.conf should contain:

              DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html

              Finally do a service httpd restart

              Check /var/log/httpd/suphp.log and error_log for possible errors. In my case I noticed this:

              “[Fri Apr 22 14:36:55 2011] [warn] Mismatch between target UID (501) and UID (48) of file “/home/arpart/public_html/index.php”

              Which means that some files were not owned by . Use chown -R user.user /home/user to fix the problem.

            • Yum and RPM Tricks

              This applies to Centos 5.6 but most likely it works on any rpm based distro.

              1. It happened many times to mess the permissions of a file and services not to work properly. In order to get fixed I run :

              rpm -qf /path/to/file

              rpm -ql Lists all files from a package.

              This should show the package that contains the modified file. Then I run :

              rpm --setperms

              Also this command should show a list of modified files within a package:

              rpm -V

              2. To view the Changelog:

              rpm -q --changelog | less

              3. View package based on repo:

              rpm -qa release="*rf*"

              4. Extract just one File:

              rpm2cpio logrotate-1.0-1.i386.rpm |cpio -ivd etc/logrotate.conf

              5. Query Package Install Order and Dates

              rpm -qa --last >~/RPMS_by_Install_Date

              6. Query Available Packages from a Repo