Linux Quick-Ref -------------------------------------------------------------------------------- things I always forget -------------------------------------------------------------------------------- config xwindows XF86Setup kernel compiling cd /usr/src/linux make xconfig or menuconfig, config make clean (cp fl.35 fl.o) make dep make zImage or zdisk ... 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 system mke2fs -m 0 /dev/fd0 create ext2 file system on floppy disk mount mount -t ext2 /dev/fd0 /mnt/floppy umount /mnt/floppy 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 file /lib/libname lib loader (Qmagic=a.out=ld.so, ELF=ld-linux.so) 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 manpage man cmd/fie apropos keyword printing man -t mount | lpr -Pps manpage printing enscript textfile dir list ls -lt long sort by time ls -ltru list last uaccess time revers order ps ps x x also shows deamons screendump cat /dev/vcs1 dumps tty1 find find / -iname fnam* start in / ignore case 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 tar –czvf file.tgz dir/* compress dir tar –xzvpf file.tgz dir extract dir verbose zcat < file.tgz | star extract 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/hosts ip.ip.ip.adr fqhostname.domain.where alias nickname /etc/resolf.conf DNS1 DNS2 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 -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 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) *~