Skip to main content

Posts

Showing posts from January, 2015

Fix the permission and ownership

Usage ./scripts user1 user2 user3 You can also run a server-wide loop like this: for i in `ls -A /var/cpanel/users` ; do ./scripts $i ; done  code =========== #!/bin/bash if [ "$#" -lt "1" ];then echo "Must specify user" exit; fi USER=$@ for user in $USER do HOMEDIR=$(egrep "^${user}:" /etc/passwd | cut -d: -f6) if [ ! -f /var/cpanel/users/$user ]; then echo "$user user file missing, likely an invalid user" elif [ "$HOMEDIR" == "" ];then echo "Couldn't determine home directory for $user" else echo "Setting ownership for user $user" chown -R $user:$user $HOMEDIR chmod 711 $HOMEDIR chown $user:nobody $HOMEDIR/public_html $HOMEDIR/.htpasswds chown $user:mail $HOMEDIR/etc $HOMEDIR/etc/*/shadow $HOMEDIR/etc/*/passwd echo "Setting permissions for user $USER" find $HOMEDIR -type f -exec chmod 644 {} \; -print find $HOMEDIR -type d -exec chmod 755 {} \; -print find $HOMEDIR ...

mysql upgrade through script

You can download the script to execute mysql upgrade ./scriptfilename versionreq --posteasybuild (run easyapache after upgrade) ./scriptfilename versionreq (only do mysql upgrade) if [ " $( id -u ) " ! = " 0 " ] ; then echo " You must be root to run this script " exit 1 fi #overall backup mysqldump -A > /root/mysqlbackup.sql CPANEL_VERSION= $( cat /usr/local/cpanel/version | cut -d. -f2 ) CURRENT_VERSION= $( mysql -V | awk ' {print $5} ' | cut -d. -f1,2 ) # Get the target version if [ -z $1 ] || [[ $1 != ' 5.0 ' && $1 != ' 5.1 ' && $1 != ' 5.5 ' && $1 != ' 5.6 ' ]] ; then echo " Please spe...

How to tweak linux server harddisk using hdparm

hdparm switches explained http://manpages.ubuntu.com/manpages/intrepid/man8/hdparm.8.html   First of all you have to install hdparm in linux. apt-get install hdparm #hdparm /dev/sda /dev/sda: readonly = 0 (off) readahead = 120 (on) geometry = 8850/255/63, sectors = 142182912, start = 0 Hard disk Performance Information # hdparm -tT /dev/hda /dev/hdd: Timing cached reads: 496 MB in 2.00 seconds = 247.42 MB/sec Timing buffered disk reads: 60 MB in 3.03 seconds = 19.81 MB/sec Hard drive set to low, slow settings # hdparm -cuda /dev/hda /dev/hda: IO_support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) readahead = 256 (on) Use below tweaks to increase disk read write performance. For sda drive ~]# hdparm -a 2048 /dev/sda /dev/sda: setting fs readahead to 2048 readahead = 2048 (on) For sdb drive [root@439298a ~]# hdparm -a 2048 /dev/sdb /dev/sdb: setting fs readahead to 2048 readahead = 2048 (on) ]# echo “anticipatory” >...

Kill restore process in new cpanel

You may close this window and view the transfer on the command line: /usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro Access your server via SSH and run that command (the transfer name will be different on your server): /usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro As an example, you might see output like this: Transfer running with pid: paused [795 ][MASTER ]: Start Session [795 ][MASTER ]: Version: 1.9 You will note that the master PID for this transfer is xxx. If the process still exists, and the transfer has failed, then you can kill that process: kill -9 xxx The next step requires you to change the entry for this transfer in the whmxfer.sessions table in MySQL . Find the entry with the session ID for your migration. In the example we have been using, it’s ‘ 1071601843quick20141013154952IAZhRro .’ It will look like this: mysql -e “select * from whmxfer.sessions where sessionid=’1071601843quick20141013152...

Secure the server

1. Process resource monitor plugin PRM (from RFX Networks) monitors the process table on a given system and matches process id’s with set resource limits in the config file or per-process based rules. Process id’s that match or exceed the set limits are logged and killed; includes e-mail alerts, kernel logging routine and more. Install, remove, update and manage this feature in this section wget http://www.rfxn.com/downloads/prm-current.tar.gz      2.Linux Socket Monitor LSM is a bash scripted network socket monitor. It is designed to track changes to Network sockets and Unix domain sockets. Installation Download the tar file usign the below link: wget http://rfxnetworks.com/downloads/lsm-current.tar.gz Untar the file tar -zxvf lsm-current.tar.gz go inside the extracted folder cd lsm-0.* run the below command to install it ./install.sh LSM Testing /usr/local/sbin/lsm -c /usr/local/sbin/lsm -g 3. Install Co...

WiFI connection

    root@kali:~# iw dev root@kali:~# ip link set wlan0 up root@kali:~# iw wlan0 scan root@kali:~# wpa_passphrase blackMOREOps >> /etc/wpa_supplicant.conf root@kali:~# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf root@kali:~# iw wlan0 link root@kali:~# dhclient wlan0 root@kali:~# ping 8.8.8.8 (Where wlan0 is wifi adapter and blackMOREOps is SSID) (Add Routing manually) root@kali:~# ip route add default via 10.0.0.138 dev wlan0    

Chaning the container ID of an openvz vps

host# vzctl chkpnt 101 --dump --dumpfile /tmp/Dump.101 host# mv /etc/vz/conf/101.conf /etc/vz/conf/102.conf host# mv /vz/private/101 /vz/private/102 host# mv /vz/root/101 /vz/root/102 host# vzctl restore 102 --undump --dumpfile /tmp/Dump.101       or  vzctl stop oldveid  mv /vz/root/oldveid /vz/root/newveid  mv /vz/private/oldveid /vz/private/newveid  mv /var/vzquota/quota.oldveid /var/vzquota/quota.newveid  mv /etc/sysconfig/vz-scripts/oldveid.conf /etc/sysconfig/vz-scripts/newveid.conf  vzctl start newveid

ps command switches

watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15'    Every 1.0s: ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15 Mon Jan 12 17:57:24 2015 PID USER CMD %MEM %CPU 1953 rahul /usr/lib/firefox/firefox 18.7 18.4 1751 rahul cinnamon --replace 2.5 3.2 1193 root /usr/bin/X :0 -audit 0 -aut 1.8 3.0 2170 rahul totem /media/rahul/C384-4DE 1.2 0.1 1769 rahul nemo -n 1.0 0.0 1915 rahul python /usr/lib/linuxmint/m 0.8 0.0 4650 rahul gedit /home/Apache bench ma 0.7 0.0 1543 rahul /usr/lib/cinnamon-settings- 0.5 0.0 2256 rahul gnome-terminal 0.5 0.0 1909 rahul cinnamon-screensaver 0.4 0.0 1737 rahul /usr/bin/python /usr/bin/ci 0.4 0.0 1770 rahul nm-applet 0.4 0.0 1768 rahul /usr/lib/cinnamon-settings- 0.4 0...

Apache tuning documentation

Apache bench marking ======================= Things or checklist to be considered before the test     CPU: avoid power-saving mode. cpufreq-set -g performance.     File descriptors: raise the limit to (at least) the number of concurrent connections you wish to handle, using ulimit -n in your shell, or setrlimit(RLIMIT_NOFILE) in your server. Beware, some systems forbid you to raise the limit, you might need to investigate a bit to find how to unlock it.     Disable the logs of your server (you do not want to lose time logging thousands of requests instead of answering them).     Raise /proc/sys/net/somaxconn to the number of concurrent connections you want to handle. To understand why this is necessary, read the technical report or the excellent paper Measuring the Capacity of a Web Server (Banga and Druschel, Usenix 97). More on the fascinating topic of the accept() queue can be found in accept()able Strategies for Im...