Linux Quick-Ref
things I always forget     last update 21-jan-08
config xwindows
XF86Setup
/etc/XF86Config     config file
kernel compiling
cd /usr/src/linux
make xconfig     or menuconfig, config
make clean     (cp fl.35 fl.o)
make dep
make zImage     or zdisk     or bzImage
...         (modules, modules_install)
make mrproper     deletes zImage...
modify Kernel image
rdev zImage /dev/fd0     set root device
rdev -r zImage 32768
    value = bit 0-10 Offset in 1024 bytes of ramdisk
    bit 14 load ramdisk
    bit 15 prompt before loading root file system
make file systemmke2fs -m 0 /dev/fd0     create ext2 file system on floppy disk
mountmount -t ext2 /dev/fd0 /mnt/floppy
umount /mnt/floppy
mount -t proc proc /proc     mount proc file system
mount -o remount,ro /     remount root as readonly
loopdevice
insmod loop.o
dd if=/dev/fd0 of=fdisk.img     make floppy-disk image
losetup /dev/loop0 fdisk.img     link fdisk.img to /dev/loop0
mount -t msdos /dev/loop0 /mnt/loop     mount image
dd if=/dev/zero of=file.img bs=1k count=360     make ext2 image
mke2fs -m 0 file.img     create fs on it
mount -o loop file.img /mnt/loop     mount it
rmmod loop.o
check dependencies
ldd /bin/execute     show dependencies
file /lib/libname     lib loader (Qmagic=a.out=ld.so, ELF=ld-linux.so)
nm -C -u -g fname     show symbols of lib obj bin (undefined gexternals)
copy
cp -a src1 src2 dstfiles
cp -arv /src/* /dstdir     (recursive verbose)
objcopy --strip-all xsrc xdest     strip xecutes
objcopy --strip-debug lsrc ldeststripedexe
link
ln src hardlink     points to physical place
ln -s src softlink     points to src path
ln -s /proc/self/fd0 /dev/stdin
ln -s /proc/self/fd1 /dev/stdout
ln -s /proc/self/fd2 /dev/stderr
manpageman cmd/fieapropos keyword
printingman -t mount | lpr -Pps     manpage printing
enscript textfile
dir listls -al     show all long
ls -ltru     list last uaccess time revers order
psps x     x also shows deamons
dumpcat /dev/vcs1     screendump tty1
dmesg     dump kernel messages
findfind / -iname fnam*     find filename ignore case, start in /
grep -i -n string fnam*     find string in files / ignore case
compare diff file1 file2
comm -3 file1 file2     compare file1 - file2 3show differance
diff -Naur olddir newdir >name.patch
cd oldir; patch -p1 < name.patch
diff -U2 -r -N olddir newdir >pathfile.diff
patch -p1 -d destdir < patchfile.diff     p1 strip leading dir
compressing
gzip -v9 -c f1 f2 >file.gz     compress file f1 f2
gzip -v9 -c f3 >>file.gz     add file f3
gzip -l -c file.gz     -d (decompress)
tar -tzf file.tgz     list files/dir compr file z=gzip j=bzip2
tar -czvf file.tgz dir/*     compress dir
tar -xzvpf file.tgz dir     extract dir verbose
zcat < file.tgz | star     extract
bunzip2 file
Shell scripts (ash)
#!/bin/sh
. /path/take_commands_from_this_file
cd() { command cd $@; PS1="`pwd`# "; }
cmd >file_stdout
cmd 2>file_stderr
VAR=`cat /file`
[ $VAR = 12 ] &&     only_if_true
[ $VAR = 12 ] ||     only_if_false
if test -x cmd; then     exec cmd
else echo -n     cmd not executable
fi
for $ITEM in "A B C"; do list; done
while exp; do list; break; continue; done
case "AL AB CD" in
A|B) list;;
C?) list;;
esac
Linux Boot
lilo / loadlin -> decompress & start kernel
mount root device (decompress rootimg.gz)
/linuxrc
/sbin/init-> /etc/inittab -> /etc/rc.. -> getty -> login -> sh -> profile(s)
lilo.conf
boot=/dev/fd0
install=/boot/boob.b
map=/boot/map
read-write
compact
prompt
image=/zImage
label=Linux
root=/dev/fd0
lilo installlilo -v -C lilo.conf -r /mnt/floppy
loadlin.exe zImage initrd=fdroot.gz root=/dev/ram
Linux Network config
ifconfig lo inet 127.0.0.1 netmask 255.0.0.0
ifconfig eth0 inet 204.204.204.13 netmask 255.255.255.0
route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
route add -net 204.204.204.0 netmaks 255.255.255.0 dev eth0
route add default gw 204.204.204.100
/etc/hostsip.ip.ip.adr fqhostname.domain.where alias nickname
/etc/resolf.confDNS1DNS2
Linux GCC
compiling
gcc -m386 -O2 -Wall -o execname src1.cc src2.cc
-o execname (a.out)     -c compile only
-O0 no optimalisation     -S generate asm source     -fverbose-asm
-g enable debugging     -l libname
default file ext src.c src.cc asm.s obj.o arch.a lib.a
debugging
gdb execname -tty=/dev/tty8
run arguments ctrl-c
list fie     break
next     step     continue     finish
print varname     set varname=value
backtrace     quit     print /x
gdb execname core     (coredump)
gproff execname gmon.out     (compile with option -pg)
Makefile
LDFLAGS=
LIBRARIES=
CC= gcc
CFLAGS= -Wall -m386 -o2
mySRC= src1.c src2.c
OBJECTS= $(patsubst %.c, %.o, $(mySRC))
all: execname $(LINKS)
execname: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o execname $(OBJECTS) $(LIBRARIES)
objcopy --strip -all execname execstrip
clean:
- rm -f $(OBJECTS) *~