Thursday, September 22, 2016

Linux (CentOS) cannot connect to the Internet

The original post is from
http://ahhafree.blogspot.hk/2013/08/linux-mint-ubuntu.html
I just adjusted it to CentOS, only wired connection is tested.

1.先變身為 root -- 在 debian 系列 (例如 ubuntu) 的版本裡, sudo bash 然後打自己的密碼
2.Linux 有沒有抓到網卡?
  (1)按 Ctrl-Alt-T 開啟終端機,輸入 ifconfig -a 如果只出現 lo 一項, 就是沒偵測到網卡。正常應該至少偵測到 lo, eth0 (有線網卡)……
In centos system "enp3s0"

  (2) 如果沒有偵測到硬體, 就無法往下做了 -- 這時請用您的 linux 版本名稱及網卡晶片名稱上網搜尋。(原來可上網,當然這部分沒問題)
3.如果有偵測到網卡, 但網路卻不通, 請下 route -n 應該要看到至少兩列數字, 類似這樣:
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.3.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
       0.0.0.0         192.168.3.254   0.0.0.0         UG    0      0        0 eth0
  (1)如果有, 表示網路其實已正常連線; 可能只是沒設定 DNS。 請跳到下一節 「設定 DNS」。
  (2)如果沒有出現上方的兩列數字, 那麼請按照您的連線環境, 挑一個方法設定連線:
      ( 結果沒有出現兩列數字)
4.有線網卡, 自動取得 ip---因為租屋的網路,所以挑這個
若您的網路環境是自動取得 ip, 請下 dhclient 網卡名稱
有些版本的指令是 dhcpd 而不是 dhclient; 總之先按 dhc 然後按一兩次 Tab 鍵, 系統會提示。
 (結果出現了 dhclient)
5.在 dhclient 後輸入 eth0 ,按 [Enter]果然網路就通了 ☺
Centos: $ sudo dhclient enp3s0

dhclient is used to get an IP address from a DHCP server.

6. If still not work
Or come out the output:
dhclient is already runing -exiting

# ifdown enp3s0
# ifup enp3s0
### RHEL/CentOS/Fedora specific command ###
# /etc/init.d/network restart

★若您有網路問題,可連結到[網路基本指令(洪朝貴教授的網頁)]查看,加以解決。本文即轉貼自此網頁。
==========
2015補充:
Ⓞ搬新家後,設定了新的光纖網路,結果筆電剛開始有線可以上網,無線都不能;過幾天連有線也不能上網了^^|||。要去設定,發現都無法設定,只好到網路上搜尋解決方法如下:

一、無線網路:
1.如上述檢查網路卡情況
2.用root權限打開 etc/network/interfaces
3.將其他各列都以#註記,只留下以下兩行:
auto lo
iface lo inet loopback


Thursday, September 8, 2016

Vim configuration in CentOS 7

Initialization

1. Build vim from source

https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
Note that

cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp \
            --enable-pythoninterp \
            --with-python-config-dir=/usr/lib64/python2.7/config \
            --enable-python3interp \
            --with-python3-config-dir=/usr/lib64/python3.5/config \
            --enable-perlinterp \
            --enable-luainterp \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr


2. Install vundle


https://github.com/VundleVim/Vundle.vim


3. Install plugin


Youcompleteme
http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/
https://valloric.github.io/YouCompleteMe/#general-usage

NerdTree
http://vimawesome.com/plugin/nerdtree-red

VimAwesome (include a lot plugins)
http://vimawesome.com/


Problem unsolved:

when install plugin
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
check python support in vim
:echo has('python') -> 0


Cheat Sheet
http://vim.rtorr.com/

NerdTree
https://www.cheatography.com/stepk/cheat-sheets/vim-nerdtree/


Tuesday, September 6, 2016

batch process images

find '/home/jwangae/bundleroot/Viewer/public/user_drive2/575fc0536e7a72be4cbd6b68' -name "*.JPG" | while read file; do   convert "$file" -rotate 90 "$file"; done