Unix shell, gdb, emacs and git 101

Unix shell

grep -n -r “hello world”
kill -9
*quit* ctrl-d

*count line no for a file” wc -l

*list types of files in a folder*  file*
*read binary file* hexdump -C

*copy files* scp me@xx.xxx.xxxx:/mnt/share/wei/filename .

*how to handle “gcc command not find”?*
find /usr -name gcc
*update environment variable*
in .bashrc, add PATH=$PATH:/path/to/gcc/dir, then save and ‘source .bashrc’


gdb helloword.exe <coredump-file>
bt -n

emacs (c: ctrl, m: alt)

*save* c-x c-s
*quit* c-x c-c

*quit partial command” c-g

*undo* c-/

*go to line 100* esc-X goto-line (enter) 100 (enter)

“find a file” c-x c-f

*start a search” c-s

“terminate a search” c-g

*move forward/backward next screen* c-v, m-v
*split window and start a shell*
c-x 2
m-x shell
m-x gdb

*switch window* c-x o
*search a word in the file* m-s w
*match parenthesis” c-m-f (forward) and c-m-b (backward)


*add everything* git add .
*commit everything* git commit . -m “all”
*push to repo” git push

*search commit log” git log –all –grep=”513x”

*revert to the last commit, ^ means parent” git reset HEAD^ –hard

*clone the repo* git clone
*check the git history* git log
*useful for merge*
git commit . -i
git stash
git stash pop

Leave a Reply

Your email address will not be published. Required fields are marked *