15 October 2016

Linux Tips

Network Transfers
Copying files from one machine to another machine using stdin/stdout tar -cf - /backup/dir | ssh <remotehost> "cat -> backupfile.tar"

LVM/Block devices
dd if=/dev/blkdevice | ssh <remotehost> dd of=/dev/blkdevice

Without SSH
Reciever;
nc -l -p 5000 > /path/backupfile.tar
Sender;
tar -cf - /backup/dir | nc remotehost 5000




Disk Performance
Test disk read / write performance

hdparm -Tt /dev/sda

dd if=/dev/urandom of=/var/tmp/testout conv=fdatasync bs=8k count=10k; rm -f /var/tmp/testout
/dev/urandom performs badly, but gives a better measure for SSD performance. If disk speed > urandom, pre-load a file (in RAM) with urandom.

dd if=/dev/zero of=/var/tmp/testout conv=fdatasync bs=8k count=10k; rm -f /var/tmp/testout

Monitor disk read/write utilisation

sar -dp 1 3
iotop





Oracle Java.. (Replace OpenJDK)

Easy Method
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/java-8-debian.list

 

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer
apt-get install oracle-java8-set-default

Manual method
apt-get purge openjdk*

Download JRK/JDK onto the server
http://www.oracle.com/technetwork/java/javase/downloads/index.html

mkdir -p /usr/local/java

cp ./jdk-8u102-linux-x64.tar.gz /usr/local/java
cd /usr/local/java/
tar -zxvf jdk-8u102-linux-x64.tar.gz
chown root:root jdk1.8.0_102 * -R
cd jdk1.8.0_102

echo "JAVA_HOME=`pwd`" >> ~/.profile
echo "PATH=$PATH:$HOME/bin:$JAVA_HOME/bin" >> ~/.profile
echo "export JAVA_HOME" >> ~/.profile
echo "export PATH" >> ~/.profile
source ~/.profile

update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_102/bin/java" 1

update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_102/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_102/bin/javaws" 1 <- NB; javaws does not exist in server java package

update-alternatives --set java /usr/local/java/jdk1.8.0_102/bin/java

update-alternatives --set javac /usr/local/java/jdk1.8.0_102/bin/javac
update-alternatives --set javaws /usr/local/java/jdk1.8.0_102/bin/javaws

reboot


Verify with 
java -version


Multiple Architectures (i386/i686 & 64)
Their is still a significant amount of software out there that is compiled as only 32bit! :(
This means you need to install 32bit libraries onto your 64bit Kernel and OS.

Debian/Ubuntu;
dpkg --print-architecture
dpkg --print-foreign-architectures

If NULL, enable multi-arch with;
dpkg --add-architecture i386
apt-get update





(To be finished)..


No comments:

Post a Comment