Tag Archives: Linux

Use mysqldump to create separate files and directories for databases and tables

The script creates separate directory for every database and bz2 files for every table inside that database.

#edit these
echo - Dumping DB structure "$MYSQLDIR"/all.bz2 
$MYSQLDUMP --user=$USER --password=$PASSWORD -d --all-databases | bzip2 > "$MYSQLDIR"/all.bz2 
echo - Dumping tables for each DB
databases=`$MYSQL --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
for db in $databases; do
    echo - Creating "$db" DB
	mkdir $MYSQLDIR/$db
	chmod -R 777 $MYSQLDIR/$db
	for tb in `$MYSQL  --user=$USER --password=$PASSWORD -N -B -e "use $db ;show tables"`
			echo -- Creating table $tb
			$MYSQLDUMP --opt  --delayed-insert --insert-ignore --user=$USER --password=$PASSWORD $db $tb | bzip2 -c > $MYSQLDIR/$db/$tb.sql.bz2

Adding new users and admins to Linux server

Check Installing CentOS 6.2 on VMware post.

Using admin user avoids common mistakes done when logging as root, instead use sudo to run root commands.

mkdir /server
#adding web-server user www
adduser www -d /server -s /sbin/nologin
#adding admins group to use instead of root
groupadd admins
%admins ALL=(ALL)       NOPASSWD: ALL
#add new admin 
adduser admin -g admins
#set password
passwd admin
#add email for user admin
vi /etc/aliases
admin: admin@example.com
#rebuild data

Disabling unneeded services on CentOS

Check Installing CentOS 6.2 on VMware post.

More information about each service can be found here

chkconfig setroubleshoot --levels 345 off;service setroubleshoot stop
chkconfig portmap --levels 345 off;service portmap stop
chkconfig rpcidmapd --levels 345 off;service rpcidmapd stop
chkconfig restorecond --levels 345 off;service restorecond stop
chkconfig pcscd --levels 345 off;service pcscd stop
chkconfig nfslock --levels 345 off;service nfslock stop
chkconfig nfs --levels 345 off;service nfs stop
chkconfig netfs --levels 345 off;service netfs stop
chkconfig mdmonitor --levels 345 off;service mdmonitor stop
chkconfig hidd --levels 345 off;service hidd stop
chkconfig cpuspeed --levels 345 off;service cpuspeed stop
chkconfig cups --levels 345 off;service cups stop
chkconfig cpuspeed --levels 345 off;service cpuspeed stop
chkconfig apmd --levels 345 off;service apmd stop
chkconfig autofs --levels 345 off;service autofs stop
chkconfig atd --levels 345 off;service atd stop
chkconfig apf --levels 345 off;service apf stop
chkconfig yum-updatesd  --levels 345 off;service yum-updatesd  stop
#disable apache if not needed
chkconfig httpd  --levels 345 off;service httpd  stop

mounting partitions with noatime

Check Installing CentOS 6.2 on VMware and increase linux file descriptors posts.

This should help reduce disk IO by telling the system not to update inode access times. more here

vi /etc/fstab
#add noatime to the options of the / file system ex:
/dev/mapper/vg_centos6-lv_root /                       ext4    defaults,noatime         1 1

- remount file system

mount -o remount /
cat /proc/mounts | grep noatime

Change ssh port and enable X11 forwarding

Check Installing CentOS 6.2 on VMware post.

- configure ssh port

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old
vi /etc/ssh/sshd_config
#uncomment port 22 and change to
port 4568

- enable X11 forwarding

#install needed libraries
yum -y install xorg-x11-xauth xorg-x11-fonts-base liberation-fonts
vi /etc/ssh/sshd_config
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

- restart sshd

 /etc/init.d/sshd restart

Now you should connect to

Installing CentOS 6.2 on VMware

This is a step by step tuturial for installing CentOS 6.2 64bit on VMware 7.0.1 build-227600 running on Windows 7

- downoad the iso DVD from CentOS.org ( need only CentOS-6.2-x86_64-bin-DVD1.iso for this installation )


- Open VMware and follow the slide

  • Start new VMware virtual machine

  • Check Linux then choose CentOS 64-bit from menu

  • Check 'Use bridget networking'

  • Now Edit the virtual machine settings we just created

  • Remove the floppy

  • load the iso image file on the DVD drive

  • Add another network adapter

  • Check the 'Host-Only" networking, this will create private network between only the host and virtual machine on the same machine

  • Start the virtual machine to setup CentOS 6.2

Continue reading