Linux Tips(4)

TurnToJPG -->

1. Run ansible commands

Run commands in all hosts:

# ansible all -i inventory.ini -m command -u root --args "uptime"

2. mesos introduction

3. Limit ansible run hosts

# ansible-playbook -i inventory_mesos_cluster changehostname.yml -u root -k
-vvvv --list-hosts

playbook: changehostname.yml

  play #1 (master1): host count=1

#  ansible-playbook -i
inventory_mesos_cluster changehostname.yml -u root -k -vvvv --limit="master1"

4. Configure the dhcp configuration of libvirtd

First edit the net configuration:

# virsh net-edit xxxxx


5. Copy items into clipboard in vim

Hit Ctrl+v to visual model, then select the items you want to copy, after select them, click "*y will copy whatever you selected into your clipbard.

Copy from clipboard—- simply hit p in command mode.

6. mesos.cli

When you meet no module named mesos, install it via pip:

$ pip install mesos.cli

7. Startdict In Command Line

$ sudo apt-get install -y sdcv
$ wget
$ sudo mkdir -p /usr/share/stardict/dic/
$ sudo tar xjvf stardict-dictd_www.dict.org_gcide-2.4.2.tar.bz2 -C /usr/share/stardict/dic 

8. Golden Dict

Golden Dict.

9. Latest Info On OpenStack

10. Quickly Configure vagrant machine

Via following you could get outside world:

ip route del default gw dev enp0s3
ip a del dev enp0s8
ip a add dev enp0s8
ip route add default via dev enp0s8

11. Change the default gateway On CentOS 7

Default gateway should go here:

$ cat /etc/sysconfig/network
# Created by anaconda

And remove the origin default gateway by adding following definitions :

$ cat /etc/sysconfig/network-scripts/ifcfg-enp0s3 
# Generated by dracut initrd
# This one is not the default gw
# Do not override the dns

Thus the default gateway won’t go from enp0s3, but from enp0s8, won’t configure the dns address to 10.0.x.x.

12. On VPNs

MMC snap-in:

13. Use iptables On CentOS7

Use following steps for disable firewalld and use iptables.

$ systemctl stop firewalld
$ systemctl mask firewalld
$ yum install iptables-services
$ systemctl enable iptables
$ systemctl start iptables

14. Quickly Goes kernel configuration

When you want to configure the newer kernel source tree using your old kernel configuration, simply do following:

# yes "" | make oldconfig

15. iptables problem

After installing the newest kernel, I cannot use iptables, showing can't initialize iptables : table does not exist.

Solution: compile the modules again, select nat.


Selecting from:
Networking Support
Network Options
Network packet filtering framework(Netfilter)
IP: Netfilter Configuration

Then you should make modules_install under your kernel source building directory.

16. DistCC For Building Kernel DEB

On configurating distcc:

On building Linux kernel deb files:


Actual command:

$ time sudo make -j12 CC=distcc
$ sudo MAKEFLAGS="CC=distcc" make-kpkg --rootcmd fakeroot --initrd --append-to-version=-suspend2 kernel-image kernel-headers kernel-source -j16

Really takes long time for building the kernel out, but the iptables won’t works.

17. dmenu On Ubuntu

dmenu is in the package of suckless-tools.

$ sudo apt-get install suckless-tools

18. Virtio-GPU How-to

20. Use Latest Dev Kernel On Fedora

Refers to

$ curl -s | sudo tee /etc/yum.repos.d/kernel-vanilla.repo
$ sudo dnf --enablerepo=kernel-vanilla-mainline update

Fall back to the stable one:

$ sudo dnf --enablerepo=kernel-vanilla-stable update

21. Install grub on usb disk/ArchLinux

# chattr -i /boot/grub/i386-pc/core.img 
# grub-install --target=i386-pc --recheck --debug --force /dev/sdb
# chattr +i /boot/grub/i386-pc/core.img 

22. fcitx-gtk3

Since now firefox using gtk3, so if you want to input chinese in firefox, simply install fcitx-gtk3 then you get fcitx working.

23. Polkit And Virt-manager


$ virsh -c qemu:///system
error: failed to connect to the hypervisor
error: authentication failed: no agent is available to authenticate

Add the configuration for the polkit and restart the service:

$ sudo vim /etc/polkit-1/rules.d/49-org.libvirt.unix.manager.rules
polkit.addRule(function(action, subject) {
    if ( == "org.libvirt.unix.manage" &&
        subject.isInGroup("kvm")) {
            return polkit.Result.YES;

And also you have to add your current user into the group of kvm:

$ sudo usermod -a -G kvm <user name>

Restar the polkit service via:

$ sudo systemctl restart polkit.service

24. Running tasks in byobu

25. GPU Pass-Through

26. yaourt build error

Reason: gpg checking error, solution is:

$ proxychains4 gpg --recv-key  79BE3E4300411886

27. libvirtd and polkit

Bypass the password prompt:

28. virgl repository

29. pass-through howto

30. Control the USB port power

31. On how to reverse usb device,0

32. Set/Unset keyboard LED

Turn on/off the Scroll LED of the keyboard(USB):

xset led 3
xset -led 3

33. USB In a NutShell

34. Arduino USB Tutorial

35. Auduino USB Project

36. Detecting mouse events

Using evtest for detecting mouse events:

$ sudo apt-get install evtest
$ sudo evtest

37. SteelSeries Mouse (RAW) DEMO

38. USB Device Driver

39. Reverse usb device driver

Total Phase USB:

40. v-usb tutorial

41. v-usb and Arduino

42.Set Timezone of the ArchLinux

Change from UTC to Asia/Shanghai:

$ timedatectl set-timezone Asia/Shanghai

43. Empty all of the bash history

Empty the bash history via:

$ rm -f ~/.bash_history

44. Specify qemu-binary in

Edit the json files:

"type": "qemu",
"qemu_binary" : "/usr/libexec/",

45. apprmor.d

I modified /etc/apparmor.d/abstractions/libvirt-qemu to include the
backing store directory

46. Recover UEFI bootloader

After remove the mainline linux kernel, the archlinux is using the default kernel, but the UEFI bootloader didn’t notice this, following are the steps for recover the UEFI bootloader.

grub-install --target=x86_64-efi --efi-directory=/boot/EFI   --bootloader-id=arch_grub --recheck
cat ./EFI/loader/entries/arch.conf

Change the items into initramfs-linux.

If you cannot login to the system, you could start the machine via USB disk or installation media, using arch-chroot /mnt/ /bin/bash for login to the chroot system, then do the above operations.

47. bonding

48. Fix currpted zsh history

history corrupted.

$ mv .zsh_history .zsh_history_bad
$ strings .zsh_history_bad > .zsh_history
$ fc -R .zsh_history

49. pulp

Using pulp for managing the repositories of RPM/Docker, etc.

50. Chromium flash

Install chromium-pepper-flash in aur.

51. Install xfce4 on CentOS

Install xfce in epel repository via:

# yum --enablerepo=epel -y groups install "Xfce" 

52. LED controller

53. Build php envs

54. handle docker changes

55. python detection of usb storage
d-feet for debugging of dbus..

Install gvfp-mtp, then you could get your nautillus have the mtp device support.

Using mtp-detect for detecting the equipments and mtp-connect for connecting the device.

57. Virtualbox Driver Issue

After upgrading the system, the virtualbox won’t start the machine, this is because we didn’t install the kernel header, thus the dkms won’t be run after system upgrading. Install kernel-headers:

$ sudo pacman -S linux-headers
$ sudo /sbin/rcvboxdrv setup

58. Creation tools

59. rvm reinstall issue

openssl load error:

$ rvm pkg install openssl
$ rvm install 2.2.1  --with-openssl-dir=$HOME/.rvm/usr
$ proxychains4 gem update bundler

Then you can continue to use your octopress.

60 Install go on ArchLinux

$ sudo pacman -S go
$ mkdir ~/go
$ vim ~/.zshrc
export GOPATH=~/go
export PATH=$PATH:~/go/bin

61. Packer Development Version

The steps on building packer on Ubuntu:

$ sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
$ sudo apt-get update
$ sudo apt-get install golang
$ mkdir -p $HOME/Documents/golang
$ export GOPATH=$HOME/Documents/golang
$ export PATH=$PATH:$GOPATH/bin
$ go get
$ cd $GOPATH/src/
$ sudo chown -R dash /home/dash/
$ make


62. Install add-apt-repository command

add-apt-repository missing:

$ sudo apt-get install software-properties-common

63. git checkout specified tags

For checkout specified tag:

$ git tag -l
$ git checkout tags/xxyy -b xxyy_local

64. Nested kvm On ArchLinux

Enable the nested kvm for ArchLinux via following steps:

➜  ~ systool -m kvm_intel -v | grep nested
    nested              = "N"
➜  ~ modprobe -r kvm_intel
modprobe: ERROR: could not remove 'kvm_intel': Operation not permitted
➜  ~ sudo modprobe -r kvm_intel
➜  ~ sudo modprobe kvm_intel nested=1
➜  ~ sudo vim /etc/modprobe.d/modprobe.conf
options kvm_intel nested=1
➜  ~ systool -m kvm_intel -v | grep nested
    nested              = "Y"

65. Failed to build rubygem


Unable to install gem - Failed to build gem native extension - cannot load
such file — mkmf (LoadError)

Solved by: sudo apt-get install -y ruby-dev.

66. xe-tools location

Loation for finding xe-tools:

# pwd
# ls
XenCenter.iso  xs-tools-6.5.0-20001.iso  xs-tools-6.5.0.iso

67. Qemu Tunnel Types

68. zsh history

Error message is zsh: corrupt history file /home/myusername/.zsh_history.

Solved by:

➜  ~ mv .zsh_history .zsh_history_bad
➜  ~ strings .zsh_history_bad > .zsh_history
➜  ~ fc -R .zsh_history

69. virsh priviledge In Ubuntu

When met following issue, solved via add current user to libvirtd and kvm, relogin again then issue would be solved:

Error while connecting to libvirt: Error making a connection to libvirt URI
Call to virConnectOpen failed: Failed to connect socket to
'/var/run/libvirt/libvirt-sock': Permission denied

Solution :

$ sudo usermod -a -G kvm dash
$ sudo usermod -a -G libvirtd dash

70. Vagrant ext vars

71. rootpasswd in Kickstart

Formats, and to generate the encrypted format.

rootpw "password here"
rootpw --iscrypted password_hash
$ openssl passwd -1 "password here"

72. On Vagrant Xenserver

To build Xenserver vagrant box in packer:

Possible usable vagrant box(For Xenserver):

Remote provisioning to a xenserver hypervisor:

Ansible and Xen:

Vagrant and XenServer:

73. Tips on Xenserver In Vagrant

Mac address:

# vim /etc/sysconfig/network-scripts/interface-rename-data/static-rules.conf
eth0:mac = "xxxxxxxxx"
# interface-rename --dry-run --reset-to-install

Then you could reset all of your configuration into the initial status.

74. oh-my-vagrant

75. Detect System

Use dmidecode.

76. git remove untracked files

Following commands will remove the untracked files in .gitignore.

$  git rm --cached .vagrant
$  git rm --cached -r .vagrant
$  git rm -r --cached . 
$  git add .
$  git commit -m "Added with gitignored"
$  git push origin master

77. node mcu good example

78. 8723ae issue

Do following to make the rtl8723awe working more effeciently.

$ vim  /etc/modprobe.d/rtl8723ae.conf
options rtl8723ae fwlps=0

79. PDF Chinese

Poppler-data will enable chinese support.

$ sudo pacman -S poppler-data

80. Join multiple lines with comma

abc.txt should remove the end enter and replaced with comma.

$ cat abc.txt | tr '\n' ','

Refers to:

81. Shrink vhd file

In XenServer vms:

$ cat /dev/zero > zero.dat ; sync ; sleep 1 ; sync ; rm zero.dat

82. VHD File Compact

shirinking the vhd file via:

$ VBoxManage clonehd target.vhd cloned.vhd
$ VBoxManage modifyhd cloned.vhd --compact

83. 1602 And RPI

84. CPU Frequency

Install and enable the service of cpupower via:

$ sudo pacman -S cpupower
$ sudo systemctl enable cpupower.service
$ sudo systemctl start cpupower.service

configure the cpupower parameters via:

$  cat /etc/default/cpupower   
# Define CPUs governor
# valid governors: ondemand, performance, powersave, conservative, userspace.

Some useful commands should be like:

$ sudo cpupower frequency-set -f  3.06
$ cpupower frequency-info
$ watch grep \"cpu MHz\" /proc/cpuinfo

85. Gmail Mutt

86. Fake Video

87. Way Of Snappy Extend

88. pl2802 driver

You probably have a counterfeit adapter. It won’t work with the updated driver. You need to find the driver and use it instead. You can find it here

83. collectd On ArchLinux

Install collectd via:

$ sudo pacman -S rrdtool net-snmp liboping collectd

84. gem path

Use gem env for detecting the system variables, some variables should be added into system path.

85. Vagrant and

86 Install latest ansible

Install the latest ansible on Ubuntu:

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible

87. Packer And Ansible

88. Vagrant issue

Problem is:

sudo vagrant up
Bringing machine 'tunirserver' up with 'libvirt' provider...
/usr/share/gems/gems/fog-1.23.0/lib/fog/libvirt/requests/compute/list_volumes.rb:32:in `info': Call to virStorageVolGetInfo failed: Storage volume not found: no storage vol with matching path '/tmp/orbit-kdas' (Libvirt::RetrieveError)

Solved by:

$  sudo virsh pool-list
 Name                 State      Autostart 
 default              active     yes       
 tmp                  active     yes 
Then refreshing each pool manually.

$  sudo virsh pool-refresh tmp
Pool tmp refreshed
$  sudo virsh pool-refresh default
Pool default refreshed

89. apicv tips.

View and modify the parameters.

options kvm_intel nested=1
options kvm_intel enable_shadow_vmcs=1
options kvm_intel enable_apicv=1
options kvm_intel ept=1

By setting enable_apicv=0 the messages are gone
cat /sys/module/kvm_intel/parameters/enable_apicv

90. Disable apic in XenServer

if you look into the /boot/extlinux.conf the safe mode uses acpi=off params  as

label safe
  # XenServer in Safe Mode
  kernel mboot.c32
  append /boot/xen.gz nosmp noreboot noirqbalance acpi=off noapic mem=1024G dom0_max_vcpus=4 dom0_mem=752M,max:752M com1=115200,8n1 console=com1,vga --- /boot/vmlinuz-2.6-xen nousb root=LABEL=root-fxfyhkuc ro console=tty0 xencons=hvc console=hvc0 --- /boot/initrd-2.6-xen.img

91. Quickly devstack

Clone the repository from:

git clone
cd devstack/

Edit localrc via:

For Git Clone

 git clone 

For DevStack

Add GIT_BASE, NOVNC_REPO and SPICE_REPO variables to local.conf file.


# use TryStack git mirror

Here you could go on with

92. find and replace string in one directory

Be sure to use /bin/bash without any colors.

grep -rli '' | xargs -i@ sed -i 's/' @

93. Two IDES

Startup the cloud9 and eclise-orion via:

$ sudo docker run -it -d -p 8888:80 kdelfour/cloud9-docker
$ sudo docker run -it -d -p 8889:8080 fabric8/eclipse-orion  

94. RaspberryPI And WebTop

95. npm china

Use following command for using cnpm for replacing the npm:

$ npm install -g cnpm --registry=

96. Opera Vimemperator issue

1) Install opera extension which allows you to install Google Chrome Web Store
extensions -

2) Install the Vimium extension at

You now have a a great looking Vimium extension working in Opera.

97. OpenStack Issue

For using devstack:

$cd devstack/
$source openrc admin admin # for admin rights
$source openrc demo demo # for demo user

98. tcpdump no buffer

with tcpdump -l, tcpdump will show real-time.

99. Detach runnning process

100. Mirantis Issue