Giter Site home page Giter Site logo

blog's People

Contributors

etaf avatar

Watchers

 avatar  avatar

blog's Issues

linux cmd backup

To see etaf belongs to which group:

groups etaf 

Change etaf's default group to new_group:

usermod -g new_group etaf

find all the core file and remove them

find ~ -regex ".*core\.[0-9]*" | xargs rm

redirect stderr to file

cmd 2> stderr.txt

redirect stdout and stderr to file

cmd >file 2>&1
##first redirect stderr to stdout , then redirect stdout to file 
``

vim replace

:%s/origin_pattern/new_string/cig

kill multi process with one line

kill $(ps aux | grep '[p]ython csp_build.py' | awk '{print $2}')
Details on its workings are as follows:

first try kill -15 $(....)
if not help try kill -9

  • The ps gives you the list of all the processes.
  • The grep filters that based on your search string, [p] is a trick to stop you picking up the actual grep process itself.
  • The awk just gives you the second field of each line, which is the PID.
  • The $(x) construct means to execute x then take its output and put it on the command line. The output of that ps pipeline inside that construct above is the list of process IDs so you end up with a command like kill 1234 1122 7654.

run command without shell

nohup command &

format code

indent -linux x.cpp
or:
clang-format -i -style=xxx *.cpp

arp scan

sudo arp-scan -I eth0 -l

find excutabe file

find -type f -perm /u=x -exec ls -l {} \;

find ip of a ASUS server which has open port 80;

sudo arp-scan -l | grep ASUS | awk '{print $1}' | xargs nmap -p 80 | grep -A 1 -B 3 "open"

Compile latest vim in debian/ubuntu

$ sudo apt-get install xclip clang
$ hg clone https://code.google.com/p/vim/
$ cd vim

##Note: python-config-dir should be set according to real situation.


$./configure -with-features=huge --enable-rubyinterp=yes --enable-pythoninterp=yes --enable-perlinterp=yes  --enable-luainterp=yes  --enable-sniff --enable-multibyte --enable-xim --enable-fontset --enable-gtk2-check --enable-gnome-check --enable-gui=auto --enable-cscope --with-python-config-dir=/usr/lib/python2.7/config --with-x --prefix=/usr > configure_output.txt
$ make
$ sudo make install

CentOS 7 find windows 7 boot

sodo install ntfs-3g
grub2-mkconfig -o /boot/grub2/grub.conf
sudo grub2-set-default "windows 7 (loader) (on /dev/sda1)"

create tcl file in ns2

i need to create tcl file that include 4 wireless node (n0 , n1 , n2 , n3) zigbee. n1 is authenticated to n0 and n2 request to authenticate to n0 throw n1. n3 has other job dont need now

usage of scp

usage of scp

scp is a tool like cp in linux.The different is,scp copy file between PCs.

copy a file1 from A to B:

A~:  scp -p file1 username@B's IP : ~/file1
eg:
scp -p test.txt [email protected]:~/tset.txt

here -p measn to preserve the modify time ,access time,mode from original file.

copy a directory from A to B

A~:  scp -pr dir1 username@B's IP : ~/dir1
eg:
scp -p test_dir [email protected]:~/tset_dir

here -r means copy a directory

other option see :

man scp

scp without password

on the above step,each scp need you offer the password of the target PC.
Now there is a way to avoid the password step: by ssh certification.

A -> B whithou password

in PC A:
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub [email protected]:~/.ssh/authorized_keys

the same for B->A

centos share gtk between python2.6 and python2.7

*gtk on python 2.6

$ ls /usr/lib64/python2.6/site-packages | grep gtk

image

copy all this to /usr/local/lib/python2.7/site-packages/

$ ls /usr/local/lib/python2.7/site-packages | grep gtk

image

gtk need packages cairo , install pycairo or copy it from python2.6

$ /usr/lib64/python2.6/site-packages/cairo /usr/local/lib/python2.7/site-packages -r

now try to import gtk in python2.7.

centos deploy spark

# please run as root
#install jdk
yum install java-1.7.0-openjdk-devel.x86_64
#install scala
tar -xf scala-2.11.2.tgz 
cd scala-2.11.2
cp scala-2.11.2 /usr/local/share/scala -r
echo "export SCALA_HOME=/usr/local/share/scala\nexport PATH=\$PATH:\$SCALA_HOME/bin\n" >> /etc/profile
source /etc/profile
scala -version
#install spark
wget "http://d3kbcqa49mib13.cloudfront.net/spark-1.1.0-bin-hadoop2.4.tgz"
echo "export SPARK_HOME=/home/etaf/software/spark\nexport PATH=\$PATH:\$SPARK_HOME/bin" >> /etc/profile
source /etc/profile

git cmd

push local code to new created repo

$ git init
$ vim .gitignore
$ git add -A
$ git commit -m "init"
$ git remote add origin https://etaf@github.... 
$ git push origin master

remote file from git repo

$ git rm file
$ git rm -r dir

added but not commit, rm file added:

$ git rm --cached file

force replace local code with server code:

$ git reset --hard
$ git pull origin master

cheate a new branch and switch to it:

$ git checkout -b branch-name

push local branch to remote server:

$ git push origin branch-name

fetch remote branch from remote server:

$ git fetch origin

replace local branch with server branch:

$ git reset --hard HEAD~3         # HEAD~3 means rollback 3 commit versions
$ git pull

if you make a mistake when using: git reset --hard , then the commits before it would lose(see git log), how to recover them ?

$ git reflog
$ git reset --hard  <sha>

latest vim with youcomplete

sudo apt-get install xclip clang
hg clone https://code.google.com/p/vim/
cd vim

##Note: python-config-dir should be set according to real situation.
./configure -with-features=huge --enable-rubyinterp=yes --enable-pythoninterp=yes --enable-perlinterp=yes  --enable-luainterp=yes  --enable-sniff --enable-multibyte --enable-xim --enable-fontset --enable-gtk2-check --enable-gnome-check --enable-gui=auto --enable-cscope --with-python-config-dir=/usr/lib/python2.7/config --with-x --prefix=/usr > configure_output.txt
make -j 8
sudo make install
##__Do not use vundle to install it__

git clone https://github.com/Valloric/YouCompleteMe.git
git submodule update --init --recursive
./install.sh --clang-completer --system-libclang              ( _on centos_ )
./install.sh --clang-completer                                          ( _on ubuntu_ )
cp third_party/ycmd/cpp ./ -rf

#now test !

install ns2

./install

...

set env:

#ns2 
export PATH="$PATH:home/etaf/software/ns-allinone-2.35/bin:/home/etaf/software/ns-allinone-2.35/tcl8.5.10/unix:/home/etaf/software/ns-allinone-2.35/tk8.5.10/unix"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/etaf/software/ns-allinone-2.35/otcl-1.14:/home/etaf/software/ns-allinone-2.35/lib"
export TCL_LIBRARY="/home/etaf/software/ns-allinone-2.35/tcl8.5.10/library:/home/etaf/software/ns-allinone-2.35/tk8.5.10/library"

enable/disable core dump

enable

ulimit -c ulimited
ulimit -c 12345 (12345 is the size of core file)

disable

ulimit -c 0

centos install protobuf

get src

$ ./configure --prefix=/usr
$ make
$ make install

sudo vim /etc/profile

add content:
PKG_CONFIG_PATH="/usr/lib/pkgconfig/:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH

centos certificate not work

error: Peer's certificate issuer has been marked as not trusted by the user. while accessing https://github.com

Solution:

sudo rm -rf /etc/pki  /etc/ssl
sudo yum reinstall -y openssl ca-certificates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.