-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseful-command.txt
More file actions
86 lines (69 loc) · 3.78 KB
/
useful-command.txt
File metadata and controls
86 lines (69 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
This document is used to record some useful commands for me
#Run man to see detailed info.
pkg-config - Return metainformation about installed libraries.
ps -f - list full list
ctrl+alt+F1 - change to command line
ctrl+alt+F7(tty7) - change to tty7. usually X is tty7
alt+print screen + k - restart X
pkill X - kill X
pdflatex -shell-escape myfile.tex
#solve the issue of pdflatex cannot find the eps-to-pdf file in subfolders
#awk
#judge if a duplicate field exist in a file; if an item in first column appears more than once
awk -F '[ \t]' 'FNR==NR {if($1 in a) a[$1]=a[$1]+1; else a[$1]=1;next} ($1 in a && a[$1]>1){print $1}' mem-layout.dat mem-layout.dat
##perf & trace##
strace: trace the system call.
pstack: trace the stack of user-level program
##git##
how to set git without pasword
#https://help.github.com/articles/set-up-git
git config --global credential.helper 'cache --timeout=3600' #timeout 3600sec
#set user name
git config --global user.name "Your Name Here"
#set email
git config --global user.email "your_email@example.com"
#grep a specific feature, such as sedf
git-grep -i sedf
#How to apply several commit points from repo 1 to repo 2.
This same question is raised in stackoverflow: http://stackoverflow.com/questions/3816040/git-apply-changes-introduced-by-commit-in-one-repo-to-another-repo
You probably want to use git format-patch and then git am to apply that patch to your repository.
/path/to/repo1 $ git format-patch sha1^..sha1
/path/to/repo1 $ cd /path/to/repo2
/path/to/repo2 $ git am /path/to/repo1/0001-*.patch # this apply patch 0001 to the repo2; You can use *.patch to apply all patchse automatically, but sometimes it may not be able to apply automatically.
When git am reports error, it is usually because the head of repo1 and head of repo2 diverge on some point. You need to use 3-way merge to solve it. So you should use command 'git am -3 /path/to/repo1/0001-*.patch' to use 3-way merge to apply the patch, and solve the conflicts when 'git am' reports errors.
##git repository locally##
How to create a git repository locally
http://treeleaf.be/blog/2011/03/creating-a-new-git-repository-on-a-local-file-system/
Step 1) create remote repo.
mkdir /path/to/remote/repo/
cd /path/to/remote/repo/
git init --bare # bare measn it is remote repo
Step 2) create the local/working repo, which can be an existing project
cd /path/to/local/working/repo
git init
git remote add origin url:/path/to/remote/repo
#then you can use git add/commit/push to push to remote repo.
##shell##
find -path "path/you/want/" -o -print #find the files under the path
find -path "path/to/ignore/" -prune -o -print #ignore the path when do find
#grep the keyword in all .h and .c files under current dir but exclude some directories
find . -type d \( -path "./stubdom/*" -o -path "./dist/*" \) -prune -o -regex '.*\.\(h\|c\)$' -print | xargs grep map_foreign_range
#the following cmd also works; it avoid the problem when the path/filename has whitespace; In addition, it's more efficient because of appending "{} +"
find . -type d \( -path "./stubdom/" -o -path "./dist/" \) -prune -o -name '*.[ch]' -exec grep map_foreign_range {} +
##Xen##
#show the dependence of libraries
ldd `which xl`
#if some program's dependent lib is not detected but it's installed( you can check if it's there by `whereis lib-name`)
/sbin/ldconfig
###Mac###
How to scroll up and down in vim on Mac?
1) set the .vimrc with set mouse=a in Mac and the sshed machine;
2) Ctrl + F (Forward) to scrool down;
3) Ctrl + B (Backward) to scrool up.
###Virtual Box###
How to ssh to the virtual box?
1) Add a second network Adapter with Host Only configuration;
2) In virtual machine, set the ip address to static address
###Manual cause kernel panic in Linux###
echo 1 > /proc/sys/kernel/sysrq
echo c > /proc/sysrq-trigger