Linux Tips(2)

TurnToJPG -->


1. XenCenter Installation

Just use your windows’s browser point to your XenServer IP Address, Download the XenCenter, and install it.

Update Some tools on XenServer:

$ vim /etc/yum.repos.d/CentOS-Base.repo
...
enabled=1
...
$ yum install -y lm_sensors

After installation of lm_sensors you could see more detailed information on XenServer.

2. Disable Specified Repository

Since citrix have no data in its repository, simply disable it.

$ yum update --disablerepo=citrix

3. Yum Shell

yum shell
remove ffmpeg-libpostproc
remove ffmpeg
install ffmpeg-compat
run

4. Install lm_sensors In XenServer

The default lm_sensors could not be insalled due to dependency errors, so we download the source code from lm_sensors website and manually build and install it:

$ wget http://dl.lm-sensors.org/lm-sensors/releases/lm_sensors-3.4.0.tar.bz2
$ tar xzvf lm_sensors-3.4.0.tar.bz2
$ cd lm_sensors
$ yum install -y gcc make flex bison 
$ make && make install
$ export PATH=/usr/local/bin:$PATH
$ sensors-detect
$ sensors

In 79 machine, sensors won’t printout cpu fan, solved by:

$ modprobe it87 force_id=0x8728

Or configure the modprobe.d:

[root:/etc/modprobe.d]# cat it87.conf 
options it87 force_id=0x8603

[root:/etc/modprobe.d]# pwd
/etc/modprobe.d

5. Detect an AMD Chipset

First using sensors-detect for detecting the sensors, the result is listed as:

Now follows a summary of the probes I have just done.

Driver `w83627ehf':
  * ISA bus, address 0x290
    Chip `Nuvoton W83677HG-I (NCT5572D/NCT6771F/NCT6772F/NCT6775F) Super IO Sensors' (confidence: 9)

Driver `k10temp' (autoloaded):
  * Chip `AMD Family 12h and 14h thermal sensors' (confidence: 9)

Now go to the modules directory for finding out the corresponding driver:

[root@xenserver-WolfHunter 3.10.0+2]# find . | grep -i w83
./kernel/drivers/hwmon/w83795.ko
./kernel/drivers/hwmon/w83627hf.ko
./kernel/drivers/hwmon/w83l786ng.ko
./kernel/drivers/hwmon/w83792d.ko
./kernel/drivers/hwmon/w83l785ts.ko
./kernel/drivers/hwmon/w83791d.ko
./kernel/drivers/hwmon/w83793.ko
./kernel/drivers/hwmon/w83781d.ko
./kernel/drivers/hwmon/w83627ehf.ko
[root@xenserver-WolfHunter 3.10.0+2]# pwd
/lib/modules/3.10.0+2
[root@xenserver-WolfHunter 3.10.0+2]# modprobe w83627ehf.ko

Now you could detect more infos, add to automatically:

[root@xenserver-WolfHunter modprobe.d]# cat w83627ehf.conf
#!/bin/sh 
/sbin/insmod /lib/modules/3.10.0+2/kernel/drivers/hwmon/w83627ehf.ko

6. Headless Ubuntu

Headless Ubuntu, for updating grub.

Add: GRUB_RECORDFAIL_TIMEOUT = 15 in /etc/default/grub, and run "sudo update-grub". You can change the 15 to any arbitrary number of seconds that you like.

7.Joggler Bootloader Configuration

Notice there are 2 systems available on Joggler.

[dash@/run/media/dash/linux-boot]$ cat grub.cfg
loadfont /unicode.pf2
terminal_output gfxterm
set timeout=5
menuentry "Ubuntu 12.04 LTS (Precise) - 3.2.32joggler1" {
  # text mode
  #linux /vmlinuz-3.2.32joggler1 root=LABEL=linux-root 3 ro text pci=routeirq
  # Graphical mode
  linux /vmlinuz-3.2.32joggler1 root=LABEL=linux-root 3 ro pci=routeirq
  initrd /initrd.img-3.2.32joggler1
}
###############Xubuntu#####################3
#menuentry "XUbuntu 12.04 LTS (Precise) - 3.2.32joggler1" {
#  linux /vmlinuz-3.2.32joggler1 root=LABEL=Xubuntu ro quiet splash 
#  initrd /initrd.img-3.2.32joggler1
}

8. Use Joggler As a DigitalFrame

#!/bin/sh
#
# Script to run Digital Picture Frame using Feh
# drware@thewares.net
#

# Change number below to the duration, in seconds
# for each photo to be displayed
DELAY="5"

# hide the cursor after 15 seconds
#/usr/bin/unclutter -idle 15 &

# Start slide show
# /usr/bin/feh --quiet --recursive --randomize --full-screen \ --slideshow-delay $DELAY /home/dash/800480/
/usr/bin/feh --hide-pointer -D $DELAY --quiet --recursive --randomize --full-screen \ --slideshow-delay $DELAY /home/dash/800480 &

# Phone home and sync
# /home/dsl/frame/rsync.sh

exit 0

9. Resolving git conflicts

Once you installed meld or other tools, using following commands.

$ git mergetool

10. Enlarge Volume

Enlarge the qemu disk via:

$ sudo qemu-img resize abc.qcow2 +200GB

Enlarge the disk via following command:

[root@fuel ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/os-root   9.6G  976M  8.1G  11% /
/dev/mapper/os-var     27G  5.4G   20G  22% /var
[root@fuel ~]# lvs
  LV           VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root         os   -wi-ao----  9.78g                                                    
  swap         os   -wi-ao----  2.94g                                                    
  var          os   -wi-ao---- 26.66g       
 

Use gparted livecd for enlarge the disk, now you could enjoy the whole 300GiB disk size.

Resize the var partition:

Disk /dev/mapper/os-var: 28.6 GB, 28621930496 bytes
255 heads, 63 sectors/track, 3479 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@fuel ~]# lvextend -L+50G /dev/mapper/os-var
  Size of logical volume os/var changed from 26.66 GiB (853 extents) to 76.66 GiB (2453 extents).
  Logical volume var successfully resized
######Reboot to gdisk iso, and resize2fs.   
# resize2fs /dev/mapper/os-var

11. gpg Generation

$ apt-get install -y rng-tools
$ rngd -r /dev/urandom
$ gpg --gen-key
$ gpg --list-secret-keys
$ gpg-agent --homedir /home/dash/.gnupg --use-standard-socket --daemon
$ sudo apt-get install gnupg

Redirect bash script’s output to syslogd:
http://urbanautomaton.com/blog/2014/09/09/redirecting-bash-script-output-to-syslog/

Then limit the syslogd activity:

via logrotate, syslogd don’t care about the log file size.

So in the end the top portion of my /etc/logrotate.conf file looks like this:

size 250M
rotate 2
create
#compress
include /etc/logrotate.d

13. Brake

http://www.miroslavnovak.com/qemu-brake_en.php

14. install specified pip version

$ sudo pip install "PyOpenSSL>=0.13"

15. Tips for using vFense

   57  sudo pip install "PyOpenSSL>=0.13"
   58  apt-cache search libffi
   59  sudo apt-get install -y libffi-dev
dash@fenseServer:~$ sudo mkdir /usr/share/rethinkdb

16. Cgroup error


cloudstack4.5.1 在centos7.1 上的 bug 
此bug 会导致 系统vm state 状态获取不到
在agent的log中获取到的错误信息为
Controller 'cpuacct' is not wanted, but 'cpu' is co-mounted: Invalid argument

解决方法

注释这个文件中的这行 /usr/lib64/python2.7/site-packages/cloudutils/serviceConfig.py
cfo.addEntry("cgroup_controllers", "[\"cpu\"]")
和这个文件中的这行 /etc/libvirt/qemu.conf
cgroup_controllers=["cpu"]
重启libvirtd服务

官网bug连接:https://issues.apache.org/jira/browse/CLOUDSTACK-8443

17. PXE Boot Debian:

Install:   
http://backreference.org/2013/12/23/diskless-iscsi-boot-with-pxe-howto/
iscsi:    
http://www.sysprobs.com/guide-how-to-create-iscsi-storage-disks-freenas-08
Trouble Shooting: Use the latest version!!!
https://www.howtoforge.com/community/threads/debian-boot-over-iscsi-problem.67536/#post-321516
iscsi and kvm:
https://www.berrange.com/posts/2010/05/05/provisioning-kvm-virtual-machines-on-iscsi-the-hard-way-part-2-of-2/

18. Quickly Connect to RDP

# ssh -L 2333:10.0.0.2:3389 192.168.10.187 -l root
# rdesktop -u YourUseName -p YourPassword localhost:2333 -g 1400x800

On CentOS 7, do following:

$ sudo vim /etc/nginx/nginx.conf
http {
        disable_symlinks off;
}

server {
        root         /var/www/html;

        location / {
                        autoindex on;
        }

Restart the nginx service now you could get the local directory avaiable in browser.

20. Get Back the passwd

In Grub, add single at the linux /boot/vmlinuz-……

Press F10, and now you can do whatever you want to do.

21. Enable Nested KVM

# virsh edit VM_NAME
<vcpu placement='static' cpuset='0-3'>4</vcpu>
Also change the cpu model.  
<cpu>
....
</cpu> 
remove the tsc related item.   

22. Restart Windows Under CMD

Specify the timeout(5 seconds) under the cmd line:

# shutdown /r /t 5

23. Cleanup Windows7 Disk

Right click the disk, and select Disk Cleanup, then select Clean up system files, then your winsxs directory will be cleaned, thus saved your partition volumn.

24. vim spell checking

: set spell spelllang=en_us

25. Startup Synergy At System Startup

# vim /etc/lightdm/lightdm.conf
greeter-setup-script=/usr/bin/synergys --config /home/dash/mysynergy.conf

26. Install Cobbler On Ubuntu

# wget -qO - http://download.opensuse.org/repositories/home:/libertas-ict:/cobbler26/xUbuntu_14.04/Release.key | sudo apt-key add -
OK
# sudo add-apt-repository "deb http://download.opensuse.org/repositories/home:/libertas-ict:/cobbler26/xUbuntu_14.04/ ./"
# apt-get update

27. Install restricted extra packages

Install it via:

 # sudo apt-get install ubuntu-restricted-extras

28. View Allocated DHCP Address

$ more /var/lib/dhcpd/dhcpd.leases

29. apt-mirror for launchpad

The steps are the same as the ordinary repository.

# vim  /etc/apt/mirror.list
 deb http://ppa.launchpad.net/landscape/15.01/ubuntu trusty main
# apt-mirror

30. Specify architecture of sources.list

Only include amd64:

$ sudo vim /etc/apt.sources.list
deb [arch=amd64] http://192.168.0.79/landscape/15.01/ubuntu/ trusty main

31. Use Cobbler Repository

[root@localhost yum.repos.d]# cat cobbler.repo 
[core-0]
name=core-0
baseurl=http://10.9.10.1/ks_mirror/CentOS-6.5-x86_64
enabled=1
gpgcheck=0
priority=1

32. Jenkins Worktips

Worktips:

# visudo
jenkins ALL=(ALL) NOPASSWD:ALL

33. Query packages

$ yum whatprovides "*/mkpasswd"
-or-
$ repoquery -q --file */mkpasswd

34. Encrypt kickstart used passwd

# perl -e "print crypt('engine123','sa')"
saWbOtynpFXBA%

35. Disable ssh -X warning

Problem:

Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-*

Solution:

# vim ~/.bashrc
export NO_AT_BRIDGE=1

36. Manually add gpg key

# wget http://download.opensuse.org/repositories/home:/libertas-ict:/cobbler26/xUbuntu_15.04/Release.key
# cat Release.key |sudo apt-key add -

37. Quick Setup the CentOS7 Network

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Generated by dracut initrd
DEVICE="eth0"
ONBOOT=yes
NETBOOT=yes
UUID="99c6b60e-1932-46f9-a86a-d9836f42cecb"
IPV6INIT=yes
BOOTPROTO=static
IPADDR=10.9.10.100
GATEWAY=10.9.10.1
TYPE=Ethernet
NAME="eth0"
DNS1=223.5.5.5
DNS2=180.76.76.76

38. GPG Key Error

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
GPG key retrieval failed: [Errno 14] curl#37 - "Couldn't open file
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7"

Solution:

# wget http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
# rpm --import RPM-GPG-KEY-EPEL-7 

39. Sync REpository

[root@SpaceWalker ~]# spacewalk-repo-sync -c centos7-x86_64 --url=file:///var/distro-trees/centos7_64/
======================================
| Channel: centos7-x86_64
======================================

Repo URL: file:///var/distro-trees/centos7_64/
Packages in repo:              8652
No new packages to sync.
Repo file:///var/distro-trees/centos7_64/ has comps file 0e6e90965f55146ba5025ea450f822d1bb0267d0299ef64dd4365825e6bad995-c7-x86_64-comps.xml.gz.
Repo file:///var/distro-trees/centos7_64/ has 0 errata.
Sync completed.
Total time: 0:01:58

40. Resuming until you success

# cat ./abc.sh
until sudo xxxxxxx
do
	do something
done
# ./abc.sh

41. pacman/yaourt

Ignore the pacman PGP check:

$ sudo vim /etc/pacman.conf
SigLevel = Never

yaourt use disable PGP options:

yaourt --m-arg "--skipchecksums --skippgpcheck" -S xxxxxx

42. Install pandoc

Add 3rd-party repository

# vim /etc/pacman.conf
[haskell-core]
Server = http://xsounds.org/~haskell/core/x86_64/

With the above ignore PGP settting, run proxychains pacman -Sy.

Then you type-in proxychain pacman -S haskell-pandoc for installing the pandoc.

43. Change Docker Image Save Directory

Only works under CentOS:

# cat /etc/sysconfig/docker
other_args='-g /home/xxxxxxx/dockerimage'

44. Define locale under CentOS

# localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

45. Install nethogs in CentOS 7

# yum install libpcap-devel -y
# rpm -ivh http://cdn.kanachan.me.uk/dl/rpms/nethogs/nethogs-0.8.0-1.el6.x86_64.rpm
[root@spacewalkercs7 zones]# cat db.spacewalkercs7
;
;
$TTL 604800
@       IN      SOA     spacewalkercs7. root.spacewalker.cs. (
                                3               ;Serial
                                604800          ;Refresh
                                86400           ;Retry
                                2419200         ;Expire
                                604800 )        ;Negative Cache TTL
;
; name servers - NS records
      IN      NS      spacewalkercs7.

; name servers  - A records
spacewalkercs7.         IN      A       10.9.10.12
[root@spacewalkercs7 zones]# pwd
/etc/named/zones
[root@spacewalkercs7 zones]# cat /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
        listen-on port 53 { 127.0.0.1; 10.9.10.12; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { localhost; 10.9.10.0/24;};
        allow-transfer     { localhost; 10.9.10.0/24;};

        /* 
         - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
         - If you are building a RECURSIVE (caching) DNS server, you need to enable 
           recursion. 
         - If your recursive DNS server has a public IP address, you MUST enable access 
           control to limit queries to your legitimate users. Failing to do so will
           cause your server to become part of large scale DNS amplification 
           attacks. Implementing BCP38 within your network would greatly
           reduce such attack surface 
        */
        recursion yes;

        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";

        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
        type hint;
        file "named.ca";
};


zone "spacewalkercs7" {
        type master;
        file "/etc/named/zones/db.spacewalkercs7";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";


[root@spacewalkercs7 zones]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#
option domain-name "server.world";
# specify name server's hostname or IP address
option domain-name-servers dlp.server.world;
# default lease time
default-lease-time 600;
# max lease time
max-lease-time 7200;
# this DHCP server to be declared valid
authoritative;
# specify network address and subnet mask
subnet 10.9.10.0 netmask 255.255.255.0 {
    # specify the range of lease IP address
    range dynamic-bootp 10.9.10.200 10.9.10.254;
    # specify broadcast address
    option broadcast-address 10.9.10.255;
    # specify default gateway
    option routers 10.9.10.1;
    # Specify default dns server
    option domain-name-servers 10.9.10.12;
}


47. On DNS Server

http://www.unixmen.com/setting-dns-server-centos-7/
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7

48. Install X windows under CentOS

# yum groupinstall 'X Window System' -y

49. Quickly Create/Start KVM Machine

# virsh dumpxml VM_A>A.xml
# vim A.xml
Change its name/uuid/disk file
# virsh start vmname

50. View io statistics

# iostat -m 1
# iotop

51. Traffic Control

http://lartc.org/LARTC-zh_CN.GB2312.pdf

52. system-config-kickstart Start Error

Problem:

# system-config-kickstart
RuntimeError: Could not read video driver database

Solution:

# apt-get remove hwdata
# wget ftp://mirror.ovh.net/mirrors/ftp.debian.org/debian/pool/main/h/hwdata/hwdata_0.234-1_all.deb
# dpkg -i hwdata_0.267-1_all.deb

53. Query Configuration file of yum

Use rpm -qc for querying the configuration files of specified software.

$ rpm -qc xxxxx

54. ShellShock

# export foo='() { :; }; echo Hello World'
# env x='() { :;}; echo vulnerable'  bash -c "echo this is a test"
# 

Detailed info:
http://www.cnblogs.com/chenyueyi/p/4520375.html

55. Install Wine1.7

Do the following changes:

$ sudo vim /etc/apt/sources.list
deb [arch=amd64,i386]  http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb [arch=amd64,i386]  http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb [arch=amd64,i386]  http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb [arch=amd64,i386]  http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb [arch=amd64,i386]  http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
$ sudo dpkg --add-architecture i386
$ sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade
$ sudo aptitude --full-resolver -f install wine1.7
6) 	wine1.7 [Not Installed]
7) 	wine1.7-amd64 [Not Installed]
8) 	wine1.7-i386:i386 [Not Installed]


Accept this solution? [Y/n/q/?] 6
Action "6": Removing wine1.7
Accept this solution? [Y/n/q/?] r 6
.....

Then you will get wine1.7 installed in your system.

55. Quickly Remove the know hosts

ssh-keygen -f "/home/xxxx/.ssh/known_hosts" -R 10.9.10.2

56. Install mirrordir from rpmforge

Import rpmforge and install mirrordir.

$ rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
$ yum search mirrordir
$ yum install mirrordir

57. Convert recorded videos into gif

From the ogv into the gif.

#  mplayer -ao null ./chromium.ogv -vo jpeg:outdir=output
#  ls output
#  convert output/* output.gif

58. Clear BIOS Password In Linux

http://www.cgsecurity.org/wiki/CmosPwd#CmosPwd_Download

# sudo ./cmospwd /k
....
1 - Kill cmos
2 - Kill cmos (try to keep date and time)
0 - Abort
# 2

Reboot and see CMOS.

59. MATE On CentOS7

First you should switches to the epel and official, then install via groupinstall:

$  yum groupinstall "MATE Desktop" -y

I don’t know why I can install it from my own repository.

To change the runlevel of the CentOS Server, use following command:

Graphical:

# systemctl set-default  graphical.target

Multi-User:

# systemctl set-default  multi-user.target
Tips for monitor of centos7: 
https://mrkmg.com/posts/changing-the-login-screen-resolution-in-centos-7-for-gnome-3/
https://jaketremper.com/?p=23

Chinese Input Method: 
http://blog.csdn.net/maokexu123/article/details/44495395

61. Mount Error Solution

3.2.8内核加载模块错误的临时解决方案

论坛用户反映升级3.2.8内核后出现加载内核模块错误,一般的报错信息如:

ERROR: could not insert 'module-name': Exec format error

原帖在这里,用户cuihao给出了临时的解决方法。

    重命名/lib/modules/extramodules-3.2-ARCH/ (官方内核)或/lib/modules/extramodules-3.2-ck/ (ck内核)下对应的模块文件(.ko.gz),然后重新编译,命令:

    make clean
    make
    make install
    depmod -a

    之后再加载内核模块即可。 

62. Build Fedora Images

https://www.rdoproject.org/Creating_CentOS_and_Fedora_images_ready_for_Openstack

Bug for gpg in Fedora21:

rpmkeys --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-21-x86_64

Error:

Unable to create appliance : Unable to run ['/usr/bin/firewall-offline-cmd', '--disabled']!

63. KickStart Online Generate

https://access.redhat.com/labs/kickstartconfig/

64. Text Based vm Installation

First mount the installation media to /mnt, then run the installtion like following command.

# qemu-system-x86_64 --enable-kvm -m 1024 -smp 2 -hda ./temp_test.qcow2  -cdrom \
/media/opensuse/dash/iso/CentOS-6.6-x86_64-bin-DVD1.iso --nographic -bios \
/usr/share/qemu/bios.bin -append console=ttyS0 -kernel /mnt/isolinux/vmlinuz -initrd \
/mnt/isolinux/initrd.img 

65. Gzip gz file

gzip -c Packages > Packages.gz

66. osad problem

Trusty should use saucy debs, try it tomorrow.

67. Quick Configure CentOS7(newly installed)

# cd /etc/yum.repos.d/
# mkdir back && mv * back/
# wget http://192.168.0.79/mrepo7.repo && yum makecache
# vim /etc/sysconfig/network-scripts/ifcfg-****
IPADDR=192.168.0.xxx
NETMASK=255.255.0.0
GATEWAY=192.168.0.xxxx
DNS1=223.5.5.5
DNS2=180.76.76.76
# useradd -m ccccccc
# visudo
# passwd ccccc
# vim /etc/hostname
pc0xxx
# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 pc0xx

Configure the resolution:

# cat /etc/gdm/Init/Default 
# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz 
# Modeline "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync  
xrandr --newmode "1440x900_60.00" 106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync                                                   
xrandr --addmode VGA1 "1440x900_60.00"                                            
xrandr --output VGA1 --mode "1440x900_60.00"

Configure the network:

$ cat /etc/sysconfig/network-scripts/route-enp2s0 
172.xx.0.0/16 via 192.168.0.xxx dev enp2s0
$ sudo  systemctl restart network

68. Systemd tips

View specified PID status.

#  systemctl status systemd-logind.service         
root:~/ # journalctl _PID=403  

69. systemd networkd and resolvd

Configuration files are listed as following:

$ pwd
/etc/systemd/network
$ ls
MyBridge.netdev  MyBridge.network  MyEth.network

$ cat MyBridge.netdev
[NetDev]
Name=br0
MACAddress=xx:xx:xx:xx:xx
Kind=bridge

$ cat MyBridge.network
[Match]
Name=br0

[Network]
DNS=180.76.76.76,223.5.5.5

[Address]
Address=192.168.1.11/24

[Route]
Gateway=192.168.1.1

$ cat MyEth.network
[Match]
Name=enp0s25

[Network]
Bridge=br0

Enable the systemd service:

$ sudo systemctl enable systemd-networkd.service
$ sudo systemctl enable systemd-resolved.service
$ sudo  ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

70. Quickly install vbox extensional

sudo  VBoxManage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack 

71. VNC With Specified Language

# export LANG=zh_CN.utf8
# vncserver

Then your vnc will start with zh support.

72. Proxy With Username/Passwd

# export http_proxy=http://easwy:123456@192.168.1.1:8080

73. Combine DVD files

https://wiki.centos.org/TipsAndTricks/CDtoDVDMedia

74. Nested CPU For CentOS 7

http://www.server-world.info/en/note?os=CentOS_7&p=kvm&f=7

75. Add Tag/Branch For Git

Added tag for the last commit:

# git log
# git tag -a V1.0 0293c397f62e5b2c025a35615c046fb0ecb40a2f
# git push --tags

Create a new branch for name version1:

# git branch version1

View all of the branches, and checkout to the specified branch:

# git branch
# git checkout master

Once you want to delete the branch:

# git branch -d checkout

Commit all of the changes to remote:

# git push --all -u

76. Auto wrap

# vim ~/.vimrc
set textwidth=78
set wrap

For chinese Wrapped:

" Wrap for Chinese
set formatoptions+=mM

77. More Detailed Systemd

Will display more detailed infos via:

# journalctl -r

78. On Build CloudStack

http://giraffeforestg.blog.fc2.com/blog-entry-194.html
http://cloudstack-administration.readthedocs.org/en/latest/templates.html
http://cloudstack-installation.readthedocs.org/en/latest/building_from_source.html#prerequisites-for-building-apache-cloudstack

79. CloudInit

http://shankerbalan.net/blog/cloud-init-supports-cloudstack-as-data-source/
http://www.slideshare.net/shankerbalan/creating-centos-template-for-cloudstack
http://serverfault.com/questions/622707/cloud-init-does-not-grow-the-partition-nor-the-filesystem

80. View VNC Port

[root@csagent ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 2     v-1-VM                         running
 3     s-2-VM                         running
 4     r-7-VM                         running
 6     i-2-9-VM                       running

[root@csagent ~]# virsh vncdisplay i-2-9-VM
192.168.139.3:3

Then you could view it via vncviewer. Get the password for vnc via:

$ virsh edit 6
xxxxxx
$ vncviewer 192.168.139.3:3