Skip to content

Instantly share code, notes, and snippets.

@ericbutters
Last active January 3, 2016 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericbutters/8439832 to your computer and use it in GitHub Desktop.
Save ericbutters/8439832 to your computer and use it in GitHub Desktop.
Linux notes
# docker, save to archive
docker save ntg6_sdkbuildenv:20151030_0855 | bzip2 > ntg6_sdkbuildenv_20151030_0855.bz2
# find, ignore directories and special files, create archive
find . -maxdepth 1 -type f \( ! -iname "*.done" \) -print0 | tar -cvzf downloads-yocto.tar.gz --null -T -
# dd - watch progress
watch -n 5 "sudo kill -USR1 30083"
# pandoc
pandoc -s -S -f markdown -o ausgabe.html file.md
# git format patch for one commit or n commit in a single patch file
git format-patch -1 <SHA1>
git format-patch -10 HEAD --stdout > 0001-last-10-commits.patch
# mkimage: convert zImage to uImage
mkimage -A arm -O linux -T kernel -C none -a 0x10008000 -e 0x10008000 -n "Linux kernel" -d zImage uImage
# find: and sort by modification date
find $WHAT -type f -printf '%Tc %p\n' | sort -k1 -n
# git: archive to bz2
git archive master | bzip2 >source-tree.tar.bz2
# sed: find and replace in files
find -name "*.h" -exec sed -i "s/QtCompositor\/private/QtCompositor/g" '{}' \;
# git: list file names to a commit
git show --pretty="format:" --name-only bd61ad98
# grep: exclude files and directories
grep -r --exclude='ChangeLog' --exclude-dir="\.svn" 'EGLImage' .
# cross compile: shared library
arm-linux-gnueabihf-gcc -shared -fPIC -o ml_malloc.so ml_malloc.c -L/path/to/arm-linux-gnueabi/usr/lib/ -L/path/to/arm-linux-gnueabi/lib/ -ldl
# git: cherry-pick
git pull
git branch -a
git checkout vr5.2
git cherry-pick dd81a91c5a263c46823632c471e4b8495e115602
git cherry-pick 7522a59fd167601ecda1721843df89ccceb205fd
git log
git push origin vr5.2
git checkout master
# netcat: copy files
on client side: nc -l -p 1234 > <filename.log>
on host side: cat <filename.log> | nc 10.0.1.40 1234
# dd: cloning sdcard
dd if=/dev/sdb | gzip > name_of_clone.gz
gunzip -c name_of_clone.gz | sudo dd of=/dev/sdb
# date: set date
date --set "2013-11-28 10:53"
# vnc: x11vnc clip
x11vnc -clip 800x480+480+0
# time: messure duration time in c
#include <sys/time.h>
struct timeval s_start, s_end;
#define S_START gettimeofday(&s_start,NULL);
#define S_END gettimeofday(&s_end,NULL); \
printf("%s[%d]:%d \n",__FILE__,__LINE__,(s_end.tv_usec - s_start.tv_usec)/1000);
#endif
# route: add route to host via gateway
sudo route add -host 192.168.21.1 gw 10.0.1.40
# gdb: attach server to running process for remote debugging
gdbserver --attach 10.0.1.40:1234 PID
# tar: exclude directories
tar cvzf name.tgz -X /adir .
# gdb: dump memory to file
gdb --attach <pid>
set height 0
set logging on
x /20xb 0xdeadbeef //20 bytes hex of 0xdeadbeef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment