clone debian packages

лесен и удобен начин ако искаме да инсталираме(клонираме) пакети от текущ на нов сървър

server1:

dpkg –get-selections > dump-server1-packages

прехвърляме си файла

server2:

dpkg –set-selections < dump-server1-packages

apt-get update

apt-get -u dselect-upgrade

backup in linux how to, clone hard disk with dd

правенето на резервно копие,клониране или ресторване от имидж става много лесно  с инструмента “dd”

клониране хард диск

dd if=/dev/sda of=/dev/sdb

/dev/sda е хард диска от който ще клонираме /dev/sdb е хард диска върху който ще клонираме

създаване на имидж на твърдия диск

dd if=/dev/sda of=/mnt/hard-drive-backup.img

създаване на имидж на дял(партишън) от твърдия диск

dd if=/dev/sda4 of=/mnt/partition4.img

възстановяване на целия хард диск от имидж

dd if=/mnt/hard-drive-backup.img of=/dev/sda

възстановяване на партишън от имидж

dd if=mnt/partition4.img of=/dev/sda4

 

 

 

access mysql database with perl

Ако сме решили чрез perl  скриптове да манипулираме данни в mysql database сървър, първо ще трябва да си инсталираме следните зависимости

aptitude search perl | grep ‘mysql’
i libclass-dbi-mysql-perl – extensions to Class::DBI for MySQL
p libcrypt-mysql-perl – Perl module to emulate the MySQL PASSWORD(
p libdatetime-format-mysql-perl – Parse and format MySQL dates and times
i libdbd-mysql-perl – Perl5 database interface to the MySQL data
i A libtime-piece-mysql-perl – Time::Piece::MySQL – Adds MySQL-specific m

apt-get install  libdbd-mysql-perl  libclass-dbi-mysql-perl

 

 

sun-java update JRE/JDK 6->7

Сваляме си пакетите от официалния сайт http://www.oracle.com/technetwork/java/javase/downloads/index.html

jdk-7u6-linux-i586.tar.gz

jre-7u6-linux-i586.tar.gz

java -version
java version “1.6.0_26”
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

tar zxvf jdk-7u6-linux-i586.tar.gz
mv jdk1.7.0_06/ /usr/lib/jvm/jdk1.7.0_06
update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/jdk1.7.0_06/bin/java” 1
update-alternatives –install “/usr/bin/javac” “javac” “/usr/lib/jvm/jdk1.7.0_06/bin/javac” 1
update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/lib/jvm/jdk1.7.0_06/bin/javaws” 1
update-alternatives –config java
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-sun/jre/bin/java 63 auto mode
1 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
2 /usr/lib/jvm/jdk1.7.0_06/ 1 manual mode
3 /usr/lib/jvm/jdk1.7.0_06/bin/java 1 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0_06/bin/java to provide /usr/bin/java (java) in manual mode.

java -version
java version “1.7.0_06”
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) Client VM (build 23.2-b09, mixed mode)

update-alternatives –config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-sun/bin/javac 63 auto mode
1 /usr/lib/jvm/java-6-sun/bin/javac 63 manual mode
2 /usr/lib/jvm/jdk1.7.0_06/bin/javac 1 manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.7.0_06/bin/javac to provide /usr/bin/javac (javac) in manual mode.
update-alternatives –config javaws
There are 2 choices for the alternative javaws (providing /usr/bin/javaws).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-sun/jre/bin/javaws 63 auto mode
1 /usr/lib/jvm/java-6-sun/jre/bin/javaws 63 manual mode
2 /usr/lib/jvm/jdk1.7.0_06/bin/javaws 1 manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.7.0_06/bin/javaws to provide /usr/bin/javaws (javaws) in manual mode.

Enable mozilla firefox plugin:

32 bit:
ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/

64 bit:
ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
Depending on your configuration, you might need to update the apparmor profile for firefox (or other browsers) in /etc/apparmor.d/abstractions/ubuntu-browsers.d/java

# Replace the two lines:
# /usr/lib/jvm/java-*-sun-1.*/jre/bin/java{,_vm} cx -> browser_java,
# /usr/lib/jvm/java-*-sun-1.*/jre/lib/*/libnp*.so cx -> browser_java,
# with those (or adapt to your new jdk folder name)
/usr/lib/jvm/jdk*/jre/bin/java{,_vm} cx -> browser_java,
/usr/lib/jvm/jdk*/jre/lib/*/libnp*.so cx -> browser_java,
Then restart apparmor:

sudo /etc/init.d/apparmor restart

стъпките за ъпдейт на jre са идентични.

http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-6-7-jre-or-jdk

http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7

script to install nvdia driver in debian squeeze

#!/bin/bash
# NVIDIA-Installer-Squeeze
# Enrique Molina
#
# GNU Public License V.3
if [ $USER != root ]; then
echo "¡Is necessary be root!"
exit 0
fi
echo "[Add Repository] [Please Wait]"
sleep 2
echo "deb http://ftp.debian.org/debian/ squeeze main contrib non-free" >> /etc/apt/sources.list
echo "[Update Repository]"
sleep 2
aptitude update
aptitude safe-upgrade
echo "[Installing Nvidia-Kernel-Module]"
sleep 2
VERSION=`uname -r`
aptitude install nvidia-kernel-$VERSION nvidia-glx
aptitude install nvidia-xconfig
nvidia-xconfig
echo "[Installing Nvidia-Settings]"
sleep 2
aptitude install nvidia-settings
echo "[Is necessary reboot to apply the changes]"
echo -n "[Do you want reboot now {y/n}]: " ; read var
case $var in
y)
reboot
;;
n)
exit
esac

запазваме скрипта в файл , например nvidia-install-script.sh
chmod +x nvidia-install-script.sh
./nvidia-install-script.sh