Linux Tips 3

TurnToJPG -->

1. Tips on Cloud-Init

2. Access CloudStack VR

Get the VR IP address from the CloudStack Web Interface:


Then get the ssh connection via(On Agent Node):

[root@csmgmt ~]# ssh -i .ssh/ -p3922  
Linux r-9-VM 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u2 x86_64

3. Cloudmonkey issue

Couldnot start cloudmonkey, use virtualenv for starting:

$ yum install -y python-virtualenv
$ virtualenv venv --python=python2.6
$ . venv/bin/activate
$ pip install cloudmonkey

Then you could start cloudmonkey in venv environment.

4. Cloud Performance Testing

Cloud Performance testing URL.

5. Installation Of VBox Ext Packs

When installing the ext packages:


The reason is because the installation program need the root priviledge while the awesome desktop didn’t support it. By installing the gksu packages from pacman you could solve it.

More tips on uninstalling ext and re-installing ext:

$ VBoxManage extpack install
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to install
VBoxManage: error: Extension pack 'Oracle VM VirtualBox Extension Pack' is
already installed. In case of a reinstallation, please uninstall it first
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component
ExtPackManagerWrap, interface IExtPackManager
VBoxManage: error: Context: "RTEXITCODE handleExtPack(HandlerArg*)" at line
1158 of file VBoxManageMisc.cpp
$ VBoxManage list extpacks
Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      5.0.0
Revision:     101573
Description:  USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox
RDP, PXE ROM, Disk Encryption.
VRDE Module:  VBoxVRDP
Usable:       true 
Why unusable: 
$ VBoxManage extpack uninstall 'Oracle VM
VirtualBox Extension Pack'
Successfully uninstalled "Oracle VM VirtualBox Extension Pack".
$ VBoxManage extpack install
Successfully installed "Oracle VM VirtualBox Extension Pack".

Now you got the newest ext packages installed for VirtualBox.

6. Change Cursor In Awesome

Download the theme from:

Extract it to your ~/.icon/, and add following items into your configuration file:

$ cat ~/.xinitrc
etroot -cursor_name Neutral_Plus
$ cat ~/.Xdefaults
Xcursor.theme: Neutral_Plus

Now restart your X you could got Neutral_Plus working. The same method could be done to aero mouse or more, but the background image is a big issue.

7. CloudStack Chinese Docs

8. Iptables forward

Added at the first:

sudo iptables -t filter -I FORWARD -j ACCEPT

9. preseed using local repository

Using the local repository for installation.

d-i mirror/country string manual
d-i mirror/http/hostname string
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
d-i apt-setup/backports boolean true
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string
d-i apt-setup/security_path string /ubuntu

Change the repository after installation:

d-i preseed/late_command string wget -O

10. Static IP Configuration For Cloud-Init

On Cloud-Init Configuration of Static IP.

11. Forwarding SSH Access To Inner

This will forward the connection to 10003 to’s 22 port, thus you will access the inner machine via ssh -p 10003 xxxx@

# iptables -t nat -A PREROUTING -d -p tcp --dport 10003 -j DNAT \
# iptables-save >/etc/sysconfig/iptables

12. On Perforce Monitor Tools

graphite and collectd:

13. More tips for Performance Monitor

14. Log System

15. Discussion on monitor

16. Simulation

Online simulation for electronics:

17. Website Generator


18. Install Collectd On CentOS6


19. View CentOS Version

# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

20. Get Collectd Packages

# wget -O /etc/yum.repos.d/epel.repo
# yum install --downloadonly --downloaddir=/root/Collectd collectd*

21. Vagrant Verification

# mkdir collectdtest
# cd collectdtest/
# vagrant box list
centos66        (virtualbox, 0)
vagrant_machine (virtualbox, 0)
# vagrant init centos66
# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...

22. Cockpit

Cockpit由红帽公司开发,旨在让服务器管理起来更容易。借助这个基于Web的GUI,你就能处理众多任务,比如管理存储资源、检查日志、启动/终止服务以及监控多台服务器。Cockpi可以在Fedora Server、Arch Linux、CentOS Atomic、Fedora Atomic和红帽企业级Linux(RHEL)上运行。


23. OpenWRT DHCP Pool Configuration

By Luci is very hard to find, so directly edit it under terminal.

# vi /etc/config/dhcp
config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'

24. Read-Only System In CentOS 6

Enter root’s password, and then remount the filesystem via following command:

#  mount -o remount,rw /

Now you could edit your filesystem and configure its configuration files.

25. ArchLinux nf_conntrack limitation

# vim /etc/sysctl.d/99-sysctl.conf
net.netfilter.nf_conntrack_max = 1048576
# sysctl --system

26. Conntrack调优

27. Qemu With OpenVswitch;a=blob_plain;f=INSTALL.KVM;hb=HEAD

28. Ubuntu ffmpeg

$ axel
$ sudo apt-get install yasm
$ sudo apt-get install -y libx264-142 libx264-dev
$ sudo apt-get install -y libfaac0 libfaac-dev
$ sudo apt-get install -y libmp3lame-dev libmp3lame0
$ sudo apt-get install libtheora-dev libtheora0
$ sudo apt-get install libvorbis-dev
$ sudo apt-get install libxvidcore-dev
$ tar xjvf ffmpeg-2.8.1.tar.bz2
$ cd ffmpeg-2.8.1
$ ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc
--enable-pthreads --enable-libfaac  --enable-libmp3lame --enable-libtheora
--enable-libx264 --enable-libxvid --enable-x11grab --enable-libvorbis --prefix=/usr
$ make -j4 
$ sudo make install

29. Use pdftk For Splitting PDF

$ sudo apt-get install -y pdftk
$ pdftk A=book.pdf cat A75-84 output Cut.pdf 

On Ubuntu14.04 Server, install lightdm and fluxbox:

# apt-get install -y lightdm fluxbox sakura
# vim /usr/share/xsessions/lightdm-xsession.desktop
[Desktop Entry]
Name=Default Xsession

Now you could select fluxbox for using at the startup screen.

Auto-login into fluxbox:

# vim /etc/lightdm/lightdm.conf

Install teamviewer, first download the teamviewer’s deb from its official website, then install it via:
Remember to manually resolve the dependencies.

# dpkg --add-architecture i386
# apt-get update
# dpkg -i teamviewer_11.0.50678_i386.deb
# apt-get -f install

Be sure to turn off the ufw to allow the connection:

# sudo ufw disable

Automatically save your screen via adding following definition:

$ vim ~/.config/.fluxbox/startup
+ xscreensaver&

31. Monitor Docker filesystem

32. Socat Connection

Reuse the ports:

vps# socat TCP4-LISTEN:2222,reuseaddr,fork TCP4:localhost:3322

33. Office 2013

activate the serial no together with your office installation.

34. Linux And Music

35. ia32-libs

To install ia32-libs, using raring repository, after installation , remove this repository:

sudo apt-get install libc6:i386
sudo -i
cd /etc/apt/sources.list.d
echo "deb raring main restricted
universe multiverse" >ia32-libs-raring.list
apt-get update
apt-get install ia32-libs
rm /etc/apt/sources.list.d/ia32-libs-raring.list
apt-get update
sudo apt-get install gcc-multilib

36. Install libc6 in Debian

The newer version.

    Add the following line to the file /etc/apt/sources.list:
    deb experimental main
    Update your package database:
    apt-get update
    Install the eglibc package:
    apt-get -t experimental install libc6-amd64 libc6-dev libc6-dbg

37. Teamviewer connection

In order to connect the remote machine, close the ufw, then you could directly connect to

teamViewer? Open 80, 443 and 5938-5939 port.
# ufw disable

38. Pygment Error

When you encounter following error:

Error:  Pygments can't parse unknown language: </p>

Then edit plugins/pygments_code.rb:

rescue MentosError
   raise "Pygments can't parse unknown language: #{lang}#{code}."

Now rake generate again, you will see the error hints, modify the corresponding markdown page.

39. Install rhc

For installing rhc on your machine, while your machine is Ubuntu14.04, you could only use gem for installing, while in vivid or later you could directly apt-get install rhc:

$ sudo gem install rhc
$ rhc setup

40. pelican-openshift

41. Show Pop-Up Dialog

Show the message with a dialog.

zenity --info --text="Calculation complete"

Remote show:

ssh -Y xxxx@ 'zenity --info --text="Calculation complete"'
### 42. Git tips
Remove the remote branch:    

git push origin –delete c0de

Check the remote's branch:    

$ git remote show origin


### 43. Add another IP
Add the 10 subnet IP Address.  

ifconfig ovsbr0:10

### 44. Chromebook Using Samba
Install samba client:   

$ sudo apt-get install samba smbclient

Detect the remote samba server's sharing folder:    

$ sudo smbclient -L -U%

But still you could not mount the remote machine. Finally i have to install the plugins
from chromestore which named `File System For Windows`.     

Still, mount with some problems when using samba server of Ubuntu.    

### 45. oh-my-zsh
Install oh-my-zsh via:    

sh -c “$(wget -O


vim ~/.zshrc


Select the theme in konsole for Solarized, then you got pretty good looking for your

### 46. Surface Pro Issue

gpg –keyserver –recv-key 38DBBDC86092693E gpg –keyserver –recv-key 79BE3E4300411886 Marvell:

Good, signature:

### 47. Ceph Example

### 48. Daily Cron
You should edit the following configuration file for customize your own crontab task
for everyday/everyweek/everymonth:    

$ vim /etc/crontab

17 * * * * root cd / && run-parts –report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )

For example, change the `25 6` to `25 12`, thus change the daily crontab task from 6:25
AM to 12:25 AM of the day.    

### 49. SRX Issue

### 50. Quickly For AlsaMixer

$ sudo pacman -S alsa-utils $ amixer sset Master unmute $ mplay *.mp3

### 51. x2x
Synergy could lost connection between client/server, so I have to change to x2x, simply
do following then I could setup the connection between 2 machines and sharing the

Ubuntu As Server

$ sudo apt-get install -y x2x

Arch As Client

$ yaourt x2x …. 2 aur/x2x-git

Then we start sharing the server's keyboard/mouse via:    

$ ssh -X x2x -west -to :0

Todo: while the shortcuts are not OK. You have to use mouse for switching the screen.     

### 48. tips for Nov24
freescale's debugging/ Customize OpenStack. 

### 49. ArchLinux ntp
First setup the timezone of the machine via:    

$ timedatectl list-timezones

timedatectl set-timezone Asia/Shanghai

Enable the openntp service:    

$ sudo pacman -S openntpd $ sudo systemctl enable openntpd $ sudo systemctl start openntpd

### 50. xfs partition
Create xfs parted .      

mkfs.xfs -f /dev/vdb1

### 51. Tips For Ceph


### 52. Boot Linux In 1 Second

### 53. collectd on Ubuntu
Configuration should be activated via:    

<Plugin “sensors"> Sensor “it8712-isa-0290/voltage-in1” IgnoreSelected true

### 54. Bluetooth
How to enable bluetooth PAN?    


### 55. Quickly Using Kernel Configuration

cp /proc/config.gz /mnt/gentoo/usr/src/linux

chroot /mnt/gentoo /bin/bash

cd /usr/src/linux

gunzip config.gz

mv config .config

make && make modules_install

cp arch/构架/bzImage /boot/kernel-xxx

rm -rf /boot/grub/grub.cfg

grub2-mkconfig -o /boot/grub/grub.cfg

### 56. Use pip for installing

$ pip install dbus-python -i –trusted-host

### 57. Python based visualization


### 58. F5 Based

### 59. OVS On CentOS7
The main steps are listed as following, refers to

yum -y install wget openssl-devel gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool

adduser ovs

su - ovs

$ mkdir -p ~/rpmbuild/SOURCES $ wget $ cp openvswitch-2.3.2.tar.gz ~/rpmbuild/SOURCES/ $ tar xfz openvswitch-2.3.2.tar.gz $ sed ‘s/openvswitch-kmod, //g’ openvswitch-2.3.2/rhel/openvswitch.spec > openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec $ rpmbuild -bb –nocheck openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec $ exit

mkdir /etc/openvswitch

yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.3.2-1.x86_64.rpm

systemctl start openvswitch.service

chkconfig openvswitch on

ovs-vsctl -V

### 60. Performance/Monitoring/Testing For Linux

### 61. Git Show Log
Show last 2 commit changes:   

git –no-pager log -p -2

### 62. tessera in production

### 63. Grafana Demo

### 64. Change netmask
Quickly changing the netmask via ifconfig:    

$ sudo ifconfig ovsbr0 netmask

### 65. Disable tomcat6

update-rc.d tomcat6 disable

### 66. Quickly get the alive IP
Using nmap and grep we could get the alive IP lists:    

$ nmap -v -sn | grep “up” -B1

### 67. Run Cloudstack in Virtualbox

### 68. View Freebsd mounted disk
View the freebsd mounted disk:    

$ cat /var/run/dmesg.boot

### 69. Remote ssh

hamachi, haguichi.    


### 70. openxenmanager
Install openxenmanager for managing xenserver.  

### 71. Virtualbox Headless
For X is not stable, I have to use Virtualbox Headless mode for starting the virtualbox

VBoxManage list vms

“systemvm64template” {dda28ddb-1faa-4f6c-bc01-0b48b449a0c9} “Elastistor” {b5292c1b-8645-4f67-922d-863178310ce1} “CloudStack” {f8295ba6-1004-4a4c-bf6d-5c2436723579} “csman” {34e5323c-2a87-45a9-904e-455ff14ce91c} “Xen” {15d2e83d-c719-423a-8168-699056b1efde} “Windows7” {73a7249c-43e1-4885-bf6c-eae774bd7617} “cloudstack-elastistor” {b967708b-6c0e-46f4-8062-a288b3fe21bc}

VBoxManage startvm Xen –type headless

VBoxManage startvm cloudstack-elastistor –type headless

### 72. chrome visit elastistor
using chromiu-browser for visiting elastistor will encounter following issue:    


Solve it via:  

➜ ~ chromium-browser –cipher-suite-blacklist=0x0088,0x0087,0x0039,0x0038,0x0044,0x0045,0x0066,0x0032,0x0033,0x0016,0x0013

### 73. Find which vm use img
For Centos64.img, which vm uses it?    

root@kspc002:/root# cat for i in virsh list --all | sed -n '3~1p' | awk '{print $2}' do virsh dumpxml $i | grep -i “Centos64.img” done

### 74. Build DEB for qemu

### 75. change uuid of the vbox

VBOXMANAGE.EXE internalcommands sethduuid

### 76. SDR

### 77. RaspberryPI's FM

### 78. SDR
Using SDR for listening satellite.    


### 79. Build System VM For CloudStack
Change the Gemfile in tools/appliance:    

$ vim Gemfile gem ‘net-ssh’, ‘=2.9.2’ gem ‘fog-google’, ‘=0.1.0’

### 80. veewee guideline

### 79. XML prettifier

curl -sL “" | xmllint –format -

### 80. CloudStack On RaspberryPI


### 81. CloudStack 4.7 On Ubuntu
When integrating with elastistor, meet following issue:    

root@ubuntucloudstack:/usr/share/cloudstack-management/webapps/client/WEB-INF/classes# ls META-INF resources scripts vms root@ubuntucloudstack:/usr/share/cloudstack-management/webapps/client/WEB-INF/classes#

###  82. Xen Installation On Ubuntu

### 83. LXC Container Template

/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \

-m /mnt/secondary
-h lxc

### 84. Enable the cloudstack Debug info
Change the `INFO` into `DEBUG`:    

[root@csmgmt agent]# pwd /etc/cloudstack/agent [root@csmgmt agent]# ls log4j-cloud.xml log4j-cloud.xml.back

### 85. Detect alive machine in one subnet
Using nmap for detecting alive machine in one subnet.    

for i in nmap -v -sn 2>/dev/null | grep '^Nmap scan' | grep -v ']$' | awk {'print $5'} | grep -v '$' do echo $i done

### 86. Run command in multiply machines
Define the inventory file, and run reboot command via:   

ansible -i inventory_mesos_cluster all -m shell -a “reboot”

### 87. On building mesos