2017年12月15日 星期五
“adb devices” command won't detect any android devices
Step 1. Find vendor ID by using "lsusb"
Step 2. Add vendor Id to ~/.android/adb_usb.ini
Step 3. Restart adb
Step 4. Test. Open a terminal to run "sudo adb logcat". Open another terminal to run "sudo adb devices"
2017年11月20日 星期一
Vim Plugin Howto: NERDTree
1. NERDTree
a. ":NERDTree" to open NERD Tree in vim
b. "Up" : to move up cursor
c. "Down" : to move down cursor
d. "Enter" : to open a directory
e. "o": to open a file
e. "H" :to show or hide hidden files
f. "R" : Refresh the tree, useful if files change outside of Vim
h. "m" : show the NERD Tree menu
i. "?" : NERD Tree quick help
j. ":q" : exit
Refer to:
https://medium.com/usevim/nerd-tree-guide-bb22c803dcd2
2. CScope
1. Run cscope
cscope -R -b
2.
Ctrl-]
:
split horizontal pane (editing new buffer)Ctrl-w s
or ":spit" : split horizontal pane (editing current buffer) Ctrl-w v
or ":vsplit" :
split vertical pane (editing current buffer)
Refer to:
1. https://a0gustinus.wordpress.com/2013/06/01/browsing-source-code-in-linux-vimcscope/
2. https://dougblack.io/words/a-good-vimrc.html
2. https://dougblack.io/words/a-good-vimrc.html
2017年11月17日 星期五
vim plugin manager : vim-plug
1. Automatic Installation (load plug.vim to ~/.vim/autoload/plug.vim )
Place the following code in your .vimrc before
plug#begin()
callif empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
Note that
2. Migrating from other plugin managers
Refer to:
https://github.com/junegunn/vim-plug/wiki/faq
--sync
flag is used to block the execution until the installer finishes.2. Migrating from other plugin managers
Download plug.vim in
autoload
directorycurl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
and update your .vimrc as needed.
With Vundle.vim | Equivalent vim-plug configuration |
---|---|
filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'junegunn/seoul256.vim' Plugin 'junegunn/goyo.vim' Plugin 'junegunn/limelight.vim' call vundle#end() filetype plugin indent on syntax enable | call plug#begin('~/.vim/plugged') Plug 'junegunn/seoul256.vim' Plug 'junegunn/goyo.vim' Plug 'junegunn/limelight.vim' call plug#end() |
vim-plug does not require any extra statement other than
plug#begin()
and plug#end()
. You can remove filetype off
, filetype plugin indent on
and syntax on
from your .vimrc
as they are automatically handled by plug#begin()
and plug#end()
.Refer to:
https://github.com/junegunn/vim-plug/wiki/faq
Split windows in Vim
1. Splitting panes
Ctrl-w n
:
split horizontal pane (editing new buffer)Ctrl-w s
or ":spit" : split horizontal pane (editing current buffer) Ctrl-w v
or ":vsplit" :
split vertical pane (editing current buffer)2. Closing panes
Ctrl-w c
or ":q": close pane Ctrl-w o
:
close all panes, only current pane opened3. Navigating panes
Ctrl-w w
: switch to next pane Ctrl-w p
:
switch to previous paneCtrl-w Up
: switch to up pane Ctrl-w Down
:
switch to down paneCtrl-w Left
: switch to left pane Ctrl-w Right
:
switch to right paneRefer to
http://codeincomplete.com/posts/split-windows-and-tabs-in-vim/
tmux installation & easy guide
For Ubuntu
tmux installation
3. Splitting panes
6. Closing panes / window
Refer to
http://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/
tmux installation
sudo apt-get install tmux
Easy Guide
1. Run tmux
tmux
2.
All commands in tmux are triggered by a prefix key followed by a command key (quite similar to emacs). By default, tmux uses Ctrl-b
as prefix key. Thus Ctrl-b
simply means press the Ctrl
and b
keys at the same time.3. Splitting panes
Ctrl-b %
:
split horizontal paneCtrl-b "
: split vertical pane
4. Navigating panes
Ctrl-b Left
:
switch to left paneCtrl-b Right
: switch to right pane Ctrl-b Up
:
switch to up paneCtrl-b Down
: switch to down pane Ctrl-b p
:
switch to previous pane Ctrl-b n
:
switch to next pane
5. Adjust pane size
Ctrl-b Ctrl-Left
:
resize horizontal paneCtrl-b Ctrl-Right
: resize horizontal pane Ctrl-b Ctrl-Up
:
resize vertical paneCtrl-b Ctrl-Down
: resize vertical paneCtrl-b z
: make a pane go full screen or to shrink it back to its previous size6. Closing panes / window
Ctrl-b d
or exit :
close pane or windowhttp://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/
2017年11月15日 星期三
Git, remote: error: inflate: data stream error (incorrect data check)
1. Find a local repository that cloned from a corrupted repository
2. To create a new repository in remote side
3. The best thing I can think of would be to pull a local copy, change the origin to the new server, and then push:
4. Run "git fsck --full" at remote side. Tar and remove bad_repo if everything is ok. Finally, rename new_repo to bad_repo.
Refer to:
https://stackoverflow.com/questions/11565882/how-to-move-git-repositories-from-github-to-local-server-running-gitolite/37254780
2. To create a new repository in remote side
git init --bare <new repo>
git pull --all
git remote rm origin
git remote add origin <new repo address>
git push --all --repo=origin
4. Run "git fsck --full" at remote side. Tar and remove bad_repo if everything is ok. Finally, rename new_repo to bad_repo.
git fsck --full
tar -zcvf bad_repo.tar.gz bad_repo
rm -rf bad_repo
mv new_repo bad_repo
https://stackoverflow.com/questions/11565882/how-to-move-git-repositories-from-github-to-local-server-running-gitolite/37254780
2017年11月14日 星期二
My favorite Git Setting
For Ubuntu
Install git-core & bash-completion
vim ~/.bash_profile & add
For CentOS
Refer to:
1: https://ihower.tw/blog/archives/5436
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));
hours_since_last_commit=$((minutes_since_last_commit/60));
minutes_since_last_commit=$((minutes_since_last_commit%60));
echo "${hours_since_last_commit}h${minutes_since_last_commit}m ";
}
PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(git_since_last_commit)\[\033[0m\]$ "
Install git-core & bash-completion
sudo apt-get install -y git-core bash-completion
vim ~/.bash_profile & add
# for bash-completion
#[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
For CentOS
Refer to:
1: https://ihower.tw/blog/archives/5436
2017年11月13日 星期一
Can ping internet and local network, but not gateway
Method:
1. netstate -rn
2. ifconfig -a
3. ping local_machine_ip
4. pint www.google.com
5. ping gateway ip
6. nslookup
Refer to:
https://www.centos.org/forums/viewtopic.php?t=39617
2017年11月12日 星期日
Install Chrome for Ubuntu 16
Goto https://www.google.com.tw/chrome/browser/desktop/index.html and Open it
PS: It only supports 64-bit.
PS: It only supports 64-bit.
2017年11月8日 星期三
Missing Icons on Ubuntu
1. System Settings / Appearance
2. Select Wallpapers & Theme, Icons and background of terminal will come back
How to Fix VMware Bridged Network have no Internet Access!
Symptom:
1. Bridged Network have no Internet Access
2. NAT Network Manual mode have no Internet Access
3. NAT Network DHCP mode have Internet Access
Steps to solve --------
1. VMware / Edit / Virtual Network Editor
2. VMnet0 disappeared
3. Change Settings & Restore Defaults, VMnet0 come out again
Refer to:
https://www.youtube.com/watch?v=BUdLvzIB9Ag
2017年11月7日 星期二
Disable / Remove thinclient_drives
sudo vim /etc/xrdp/sesman.ini
[SessionVariables]
PULSE_SCRIPT=/etc/xrdp/pulse/default.pa
CHANSRV_LOG_PATH=/tmp
2017年11月3日 星期五
VirtualBox Error: creating process for virtual machine (gui/qt)
很可惜無法確認是哪個步驟有效, 只最後將 host 重新開機, 然後, 開 VM Guest OS 就沒有相關的訊息.
------------------------------------
Kernel driver not installed (rc=1908)
2017年11月2日 星期四
How to mount a NTFS drive on CentOS 7
1. Install NTFS related stuffs
2. Run GUI => Applications / Utilities / Disks
Select NTFS drive and play it. It will create a mount point automatically.
3. List disks & partitions
Refer to:
1. https://www.phpini.com/linux/rhel-centos-fedora-mount-ntfs-partition
sudo yum install ntfs-3g
sudo yum install fuse
sudo modprobe fuse
2. Run GUI => Applications / Utilities / Disks
Select NTFS drive and play it. It will create a mount point automatically.
3. List disks & partitions
sudo lsblk -f
Refer to:
1. https://www.phpini.com/linux/rhel-centos-fedora-mount-ntfs-partition
2017年10月27日 星期五
Transfer Files/Folders in Linux Using SCP command
scp -Cpr Source Destination
ex: scp -Cpr jmt-lab91 tonychung@192.168.0.124:/home/tonychung/Backup88-old/jmt/.VirtualBox/
You can use “-v” parameter to print debug information into the screen. It can help you debugging connection, authentication and configuration problems.
The “-p” parameter will help you on this. An estimated time and the connection speed will appear on the screen.
The “-C” parameter will compress your files on the go. The unique thing is the compression is only happen in the network. When the file is arrived to the destination server, it will returning into the original size as before the compression happen.
Sometimes we need to copy directory and all files / directories inside it. It will be better if we can do it in 1 command. SCP support that scenario using “-r” parameter.
If you choose not to see progress meter and warning / diagnostic messages from SCP, you may disable it using “-q” parameter.
2017年10月25日 星期三
Install Remote Desktop (XRDP)
For Ubuntu 20.04
Install mate desktop
https://linuxconfig.org/how-to-install-mate-desktop-on-ubuntu-20-04-focal-fossa-linux
Install Mate Xrdp
Refer to https://www.hiroom2.com/ubuntu-2004-xrdp-mate-en
For Ubuntu
Install XFCE4 desktop (bad method, gray screen)
sudo apt-get update
sudo apt-get install xrdp
sudo apt-get install xfce4
echo “xfce4-session” > ~/.xsession
sudo /etc/init.d/xrdp start
sudo /etc/init.d/xrdp status
Install Mate-desktop
sudo apt-get update
sudo apt-get install xrdp
sudo apt-get install mate-core mate-desktop-environment mate-notification-daemon
sudo /etc/init.d/xrdp start
sudo /etc/init.d/xrdp status
Configuring XRDP to use your desktop environment
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n mate-session \n' /etc/xrdp/startwm.sh
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
vim /etc/yum.repos.d/xrdp.repo
[xrdp]
name=xrdp
baseurl=http://li.nux.ro/download/nux/dextop/el7/x86_64/
enabled=1
gpgcheck=0
Install xrdp and tigervnc-server, then start xrdp service
yum -y install xrdp tigervnc-server
systemctl start xrdp.service
Check xrdp service
netstat -antup | grep xrdp
Enable service at system startup
systemctl enable xrdp.service
Edit /usr/lib/firewalld/services/xrdp.xml for XRDP (add port 3389) PS: xrdp.xml will add a "xrdp" item on firewalld GUI
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>xrdp</short>
<description>This option allows you to access Remote Desktop Service.</description>
<port protocol="udp" port="3389"/>
<port protocol="tcp" port="3389"/>
</service>
Add xrdpservice for firewalld and reload firewalld
sudo firewall-cmd --permanent --add-service=xrdp
sudo firewall-cmd --reload
sudo systemctl status firewalld
Configure SELinux
sudo chcon --type=bin_t /usr/sbin/xrdp
sudo chcon --type=bin_t /usr/sbin/xrdp-sesman
Refer to:
1. http://c-nergy.be/blog/?p=8952
2. https://www.interserver.net/tips/kb/install-xrdp-ubuntu-server-xfce-template/
3. http://www.itzgeek.com/how-tos/linux/centos-how-tos/install-xrdp-on-centos-7-rhel-7.html
Reinstall VirtualBox on Ubuntu & CentOS
For Ubuntu
To remove virtualbox
sudo dpkg --list virtualbox-*
sudo apt autoremove --purge virtualbox*
dpkg -l virtualbox* | grep ^i
mkdir ~/apt-tmp
sudo mv /etc/apt/sources.list.d/* ~/apt-tmp
Make sure there is nothing except official repositories sources in
/etc/sources.list
.
And update your sources:
sudo apt update
Now we can search to see which versions are available to install:
apt-cache madison virtualbox | grep -iv sources
Which produces an output like this:
virtualbox | 5.0.32-dfsg-0ubuntu1.16.04.2 | http://mirrors.kernel.org/ubuntu xenial-updates/multiverse amd64 Packages
virtualbox | 5.0.18-dfsg-2build1 | http://mirrors.kernel.org/ubuntu xenial/multiverse amd64 Packages
Then I would install the last version mentioned in
xenial-updates
:sudo apt install virtualbox=5.0.32-dfsg-0ubuntu1.16.04.2
And after all, check that the correct version is installed.
From command line:
dpkg -l virtualbox* | grep ^i
ii virtualbox 5.0.32-dfsg-0ubuntu1.16.04.2 amd64 x86 virtualization solution - base binaries
ii virtualbox-dkms 5.0.32-dfsg-0ubuntu1.16.04.2 all x86 virtualization solution - kernel module sources for dkms
ii virtualbox-qt 5.0.32-dfsg-0ubuntu1.16.04.2 amd64 x86 virtualization solution - Qt based user interface
From GUI: to make sure correct version is running.
Install virtualbox extension pack
sudo /sbin/vboxconfig
sudo apt install virtualbox-ext-pack
For CentOS
1. Display VirtualBox installed
sudo yum update
sudo yum list installed | grep -i VirtualBox
2. Remove VirtualBox-5.1
sudo yum remove VirtualBox-5.1
3. Add Required Yum Repositories
cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
4. Install Required Packages
yum install gcc make patch dkms qt libgomp
yum install kernel-headers kernel-devel fontforge binutils glibc-headers glibc-devel
5. Reboot ans start with newest kernel
reboot
6. Reboot ans start with newest kernel
export KERN_DIR=/usr/src/kernels/`uname -r`
7. Install Oracle VirtualBox and Setup
yum install VirtualBox-5.2
8. List vbox modules (vboxpci, vboxnetadp, vboxnetflt, vboxdrv)
lsmod | grep -i vbox
9. Goto https://www.virtualbox.org/wiki/Downloads and run VirtualBox Extension pack for CentOS
Oracle_VM_VirtualBox_Extension_Pack-5.2.0-118431.vbox-extpack
cat /etc/group | grep -i vboxusers
sudo usermod -a -G vboxusers $user_name
11. /var/log/vbox-install.log
Change UUID for VirtualBox
sudo VBoxManage internalcommands sethduuid <file.vdi or file.vmdk>
Refer to:
1. https://askubuntu.com/questions/900794/virtualbox-rtr3initex-failed-with-rc-1912-rc-1912
2. https://www.if-not-true-then-false.com/2010/install-virtualbox-with-yum-on-fedora-centos-red-hat-rhel/
訂閱:
文章 (Atom)