home -> Gnu/Linux snippets

GNU/Linux snippets

These are just too easy to lose, I hope you find them useful.

They are in no particular order. I'll add more as I think of them.

List the shared libraries a program/shared library uses

readelf -d some-program | grep NEEDED

The "ldd" command is recursive, the above is not.

Valgrind with kdbg integration

valgrind -v --leak-check=full --show-reachable=yes --db-attach=yes --db-command="kdbg -p %p %f" some-program 2>&1 | tee make.txt

Search packages for files in Debian

sudo apt-get install apt-file
$ sudo apt-file update
$ apt-file search openvg.h

Testing inside a chroot on Debian

sudo mkdir /var/chroot/squeeze32
sudo debootstrap --arch=i386 squeeze /var/chroot/squeeze32 http://ftp.ie.debian.org/debian
< set up bind mounts, edit schroot.conf >
< addgroup -gid GGG yourgroup; adduser -gid GGG -uid UUU youruser >
< inside the chroot as root > apt-get install sudo
< inside the chroot as root > visudo < add yourself! >
< inside the chroot > apt-get install make automake g++ libtool pkg-config less uuid uuid-dev doxygen graphviz mscgen
edit ~/.bashrc to replace "debian_chroot" with "SCHROOT_CHROOT_NAME"

gcc library search path

gcc -print-search-dirs | grep ^libraries | cut -d= -f2- | sed -e 's/:/\
/g' | while read line; do b="$(readlink -q -m "$a")"; readlink -f "$b" || echo "[X] $b"; done

show what groups you're user account is in

groups

or

groups `whoami`

or, for another user

groups >user<

Debian multiarch

Pass the following to your compiler for non-multiarch-aware builds

-B/usr/lib/$arch -I/usr/include/$arch

See clangs built-in definitions

clang -dD -E -xc /dev/null