tag:blogger.com,1999:blog-86602623732961995342024-02-08T02:03:58.428-08:00Virtual Private Server LifeMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-8660262373296199534.post-30326418010416330742012-05-05T15:56:00.003-07:002012-05-05T15:56:51.326-07:00How to run a unix command as a USER on startup?To run a unix command on startup you may use the command below (add it to the /etc/rc.local file):
su USER -c 'your_command &'Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-21445010249645938292012-05-05T02:29:00.000-07:002012-05-05T02:35:18.443-07:00How to make stable $PATH when using sudo command?To make your sudo commands works with the $PATH of your logged-in user you just type the following command and then close all your terminals and login again:
echo "alias sudo='sudo env PATH=$PATH'" >> ~/.bashrcMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-47580583503594270352012-01-25T04:42:00.000-08:002012-01-25T04:42:30.894-08:00securing memcacheSimply iptables rules can be added to secure memcached server from the out sources.
/sbin/iptables -A INPUT -m tcp -p tcp -s 127.0.0.1 --dport 11221 -j ACCEPT/sbin/iptables -A INPUT -m tcp -p tcp -s CLIENT_IP_2 --dport 11221 -j ACCEPT/sbin/iptables -A INPUT -m tcp -p tcp -s CLIENT_IP_1 --dport 11221 -j ACCEPT/sbin/iptables -A INPUT -m tcp -p tcp --dport 11221 -j DROPTo make it run whenMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-65761644509640067442011-10-16T05:07:00.000-07:002011-10-16T05:07:25.425-07:00Learn path and shell of current user on unixTo find the shell type of current user:
echo $SHELL
To find the paths of current user:
echo $PATHMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-35843096379372279992010-07-09T14:10:00.000-07:002010-07-09T14:19:20.572-07:00Simple SH script to monitor basic connection counts on *nix systemsI wrote near a year ago a sh script to see my traffic information which can be used to see basic connection counts like unix connection count, tcp connection count, http inbound and outgoing request counts and ftp connection count, ssh connection count.
Save as mycons.sh then run the command
chmod +x mycons.shFor short access run
ln mycons.sh /bin/mycons Sample usage after shortcut
mycons -hlHereMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-66411133827714025532010-07-09T13:49:00.000-07:002010-07-09T14:21:33.111-07:00VNSTAT: Network Traffic Monitor for *nix SystemsVnstat is a network stats software, an opensource project for *nix systems and can be downloaded from http://humdi.net/vnstat/. For more than a year I am using Vnstat and it works silently without using too much resources and gives required stats when it is needed.
In details, it is possible to see your network adapters' traffic data based on years, months, weeks, days, hours and even real time Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-9402332467511611402010-02-26T08:33:00.000-08:002010-02-26T08:33:44.296-08:00Anti-DDOS NGINX Server Configuration includes PHP configHere is my NGINX configuration for DDOS Attacks to PHP and my lovely NGINX server:
nginx.conf
user www-data www-data;
worker_processes 10;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
#keepalive_timeout 0;
Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com1tag:blogger.com,1999:blog-8660262373296199534.post-86080732581105572612010-02-01T09:33:00.001-08:002010-02-01T09:33:59.365-08:00Findout Linux Distrubution Name of your Linuxlsb_release -aMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-41408266805534475482010-02-01T05:38:00.000-08:002010-02-01T05:38:04.488-08:00Change the timezone, date time on linuxln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtimeIn this command important part is giving the path of your timezone(bold one in example).Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-88027848204598143732010-01-18T14:26:00.000-08:002010-01-18T14:26:46.813-08:00Change Default Editor on Linux#set | grep EDITOREDITOR=/bin/pico
# which vi/usr/bin/vi
# export EDITOR=/usr/bin/vi# set | grep EDITOREDITOR=/usr/bin/vi
_=EDITORMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-82422196519194890042009-10-21T08:47:00.000-07:002009-10-21T08:47:28.918-07:00Deleting Files Based on Date TimeToday I needed to delete files based on date and time:
Here is the command I used for deleting file last modified on 21 Oct 2009 16:30:
ls -lh | sed -n '/Oct\ 21\ 16:30/p' | awk '{print $9}' >> 1.txt
rm -f `cat 1.txt`
Explanations:
ls -lh (lists all files)
sed -n '/Oct\ 21\ 16:30/p' (find files at given date from list)
awk '{print $9}' (print only file names on list) and >&Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-16694637371130570142009-10-14T07:23:00.000-07:002009-10-14T07:23:47.609-07:00Recursively Download FTPSometimes, you may need to move one server to another. At that time, you may use wget command to move your files without any pain.
Here is the command for recursive download on ftp via wget:
wget -r ftp://username:password@ftp.example.com/
Yes, thats all folks!Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-76604570849619726902009-10-08T09:48:00.001-07:002009-10-08T09:48:56.760-07:00List of users on LinuxTo list the users in linux you may use following command:
cat /etc/passwd | cut -d ":" -f1
Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-12661064068327158382009-09-16T05:47:00.000-07:002009-09-16T09:11:25.413-07:00NGINX, PHP-CGI, SPAWN-FCI, FTP, VHOSTS, MYSQL | centos-fedora-redhatSetup is done under a clean Centos 5.2 32bit serveryum -y updateyum -y upgradePART 0###################################################### start with php-5 setup and mysql setup ######################################################yum -y install mysql-server mysql-clientyum -y install php-cgi php-mysql php-curl php-gd php-idn php-pear php-imagick php-imap php-mcrypt php-memcache php-mhash Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com2tag:blogger.com,1999:blog-8660262373296199534.post-65746315866042931572009-09-16T05:36:00.000-07:002009-09-16T05:46:51.576-07:00Setting Up a secure fast ftp server for linux | VSFTP################################################## setting up a ftp server ## http://vpslife.blogspot.com/ & http://vpswatch.com/#################################################wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.2.0.tar.gztar zxvf vsftpd-2.2.0.tar.gzcd vsftpd-2.2.0makeadduser nobodyadduser: user nobody existsmkdir /var/ftp/useradd -d /var/ftp ftp(the next two are useful Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-22826406886114137172009-04-04T14:14:00.000-07:002009-04-04T14:23:10.146-07:00PHP Upload Progress installation-setupThis article covers installation of PHP Upload Progress extension.#SETUP guide is done by Mustafa TURAN(http://vpslife.blogspot.com/)##SETUP Software:##--PHP 5.2 or more##--Any OS#Downloadwget http://pecl.php.net/get/uploadprogress-*.tgzUntartar zxvf uploadprogress-*.tgzGo to dircd uploadprogress-*Setupphpize./configuremakemake installLearn php ini pathphp --ini;to ini file add these two lines:[Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-22288303510387299942009-04-04T14:08:00.000-07:002009-04-04T14:11:14.189-07:00How to uninstall Webmin?Just run the command/etc/webmin/uninstall.shIf you have installed the RPM version of Webmin, you can also use rpm -e webminOr if you have installed the Solaris package you can use pkgrm WSwebminWebmin FAQ: http://www.webmin.com/faq.htmlMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-7473428554613430462009-04-04T13:48:00.000-07:002009-04-04T14:11:42.520-07:00How to uninstall LAMP?Sometimes, we need to uninstall current Apache Mysql PHP collections and re install them. In this article I will show how to remove a LAMP system(for RHEL,Fedora, CENTOS):Check the existence of LAMP system:rpm -qa | grep -i mysqlrpm -qa | grep -i apacherpm -qa | grep -i httpdrpm -qa | grep -i phpIf you get list then remove via rpmrpm -e "file name"or with "yum -y uninstall"yum remove "file name"Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-55373107601151048282009-03-17T17:02:00.000-07:002009-03-17T17:44:12.195-07:00Mysql Nested Query TweakDo not use mysql nested queries for performance. Here I will share a little database table and two queries and their response times:#Experiment is done by Mustafa TURAN(http://vpslife.blogspot.com/)##Experiment purpose to see how a nested query affects MYSQL Performance ##Experiment Hardware:##--RAM: 1.5GB##--CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4000##Experiment Software:##--MYSQL 5(Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-25379025964178732752009-03-16T14:57:00.000-07:002009-03-16T15:05:47.964-07:00How to learn linux system(hardware) properties?To learn system(hardware,sofware) properties linux has such commands:Operating System Version:uname -rMemory Information:cat /proc/meminfoCPU Information:cat /proc/cpuinfoEasy Way(smart info):uname -rs;less /proc/meminfo grep MemTotal;less /proc/cpuinfo grep"model name"Aktive System Resource Usages:(all users and all activity)top -s(specified user)top -u usernameMustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-91749351787504759602009-03-15T16:42:00.000-07:002009-03-15T16:50:31.254-07:00Change Hostname on Centos 5xOn terminal screen apply the commands:vi /etc/sysconfig/networkThen change HOSTNAME=xxxx.xxx line to HOSTNAME=your_desired_hostnameYou have to save the data and quit(thats all!):wq!Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-42038403306972254722009-03-10T10:02:00.000-07:002009-03-10T10:11:12.473-07:00Copy Remote Database to Local DatabaseRemote mysqldumpRun this one line command as a user:mysqldump --opt --compress --user=REMOTE_DB_USERNAME --password=REMOTE_DB_PASS --host=REMOTE_DB_HOSTNAME REMOTE_DB_NAME mysql --user=LOCAL_DB_USERNAME --password=LOCAL_DB_PASSWORD --host=LOCAL_DB_HOSTNAME -D LOCAL_DB_NAME -C LOCAL_DB_NAME Notes: You have to enable remote mysql on remote computer! (To do this you have to add ip address of local Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-4088891922463676532008-10-07T07:18:00.000-07:002008-10-07T07:27:10.025-07:00How to reset root password on MySql?Pass the root mode on terminal.To stop mysql:# /etc/init.d/mysql stopAccess without privalages to mysql# mysqld_safe --skip-grant-tables &Pass to the mysql# mysql -u root# use mysql;# mysql -u root# mysql>INSERT INTO user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-29053603100142998272008-10-06T09:10:00.000-07:002008-10-06T09:18:56.268-07:00How to fix mysql thread_stack overrun?Today I faced a problem about running my stored procedure code and I got the error message :#1436: Thread stack overrun: 4136 bytes used of a 131072 byte stack, and 131072 bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack.I tried the command mysqld -O thread_stack=# but it did not worked. Then I entered my.cnf file which is at /etc/my.cnf I found the value of thread_stack Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0tag:blogger.com,1999:blog-8660262373296199534.post-51337790966052498912008-10-04T05:51:00.000-07:002008-10-04T06:00:42.227-07:00Low Memory Mysql / Apache configurationsConfigurations will be good for 64Mb - 256Mb RAM If you would like to convert your InnoDB tables to MyISAM, you can use the shell script to automatically convert InnoDB tables to MyISAM. #!/bin/bashMYSQLCMD=mysqlfor db in `echo show databases | $MYSQLCMD | grep -v Database`; do for table in `echo show tables | $MYSQLCMD $db | grep -v Tables_in_`; do TABLE_TYPE=`echo show create Mustafa Turanhttp://www.blogger.com/profile/05943511792734083068noreply@blogger.com0