flyonok

统计

留言簿(8)

ACE

book

boost

bsd

c study

c++

code download

codeblock

computer clound

Eclipse

embed system

erlang

ET++

gtk

ic card

java

KDE

libevent

linux

linux--MM

mysql

network education

one card

oracle

pcap relation

php

powerbuilder

python

QT

software config

software test

SQL server

UML

wireless

wxwidgets

陈宾

阅读排行榜

评论排行榜

Useful Tips I Learned from Hacking Linux (Some in a Hard Way)

  • Debug kernel module with BUG() or BUG_ON(). In the code, put something like if (impossible cond) BUG(); . This will cause kernel print trace and die, thus you have a chance to find early something bad happened.

    After crash, from console, write down EIP's value, function name, and offset. For example: EIP [e09d76d0] find_min+0x60/0x240. Of course you also want to write down stack trace.

    Now, use objdump -d -S module.ko to disassemble your kernel module. Find the offending function (e.g., find_min), plus the offset (e.g., 0x60), then see which C code cause the problem.

    Another way: e.g., gdb module.ko, use disassemble find_min to show assembly, list *find_min+96 to see source line number, and dir kernel_include_dir to add kernel header path to GDB's search path.

    Read more detailed process: How To Locate An Oops by Denis Vlasenko.

  • SMP spin lock issues: Pretty much everything you need to know can be found in Documentation/spinlocks.txt included in the kernel source.

    Typical use is spin_lock_irqsave() ... spin_unlock_irqrestore(). Local interrupt is disabled so that no local interruptions, spin locks ensure cross processor safety. However, the catch here is cache coherency and speculative execution of CPUs.

    Simply put, spin_lock() is barrier (using lock prefix), but spin_unlock() is not. On x86, write is ordered, but speculative read is possible and could cause problem in the case of spin_unlock() followed by spin_lock().

    See this email for some discussion.

    If a problem occurs, consider smp_mb(), smp_wmb(), and smp_rmb().

  • Print Chinese in Mozilla/Firefox & Chinese support for Ghostview: modify file "CIDFnmap" (typically in /usr/share/ghostscript/7.07/lib) by adding a line like this: (CIDFnmap.mine) .runlibfileifexists. Then create file CIDFnmap.mine in the same directory with these two lines: /SIMSUN (/usr/share/fonts/windows/simsun.ttc); and /SIMHEI (/usr/share/fonts/windows/simhei.ttf);. Assuming you've copied simsun.ttc and simhei.ttf to /usr/share/fonts/windows/. Now test your gv with this file.

  • Set 100Mbps card to work in 10Mbps mode: /sbin/ethtool -s eth0 speed 10 duplex full autoneg off, or try /sbin/mii-tool -F 10baseT-FD eth0 if ethtool doesn't work.

  • Combine multiple PS or PDF files into one PDF file:
    gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf.
    gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf input1.ps input2.ps

  • XCIM conflicts with Acrobat Reader 7.0 (crash before start) in FC3: Put thest two lines: export XMODIFIERS=@im=SCIM, export GTK_IM_MODULE=xim in your ~/.bashrc file.

  • XCIM input for Emacs, Ctrl+Space doesn't work: invoke emacs with "-nw" flag, however this only works for consoles.
  • lftp connects to SSL-enabled ftp server: lftp ftps://username:password@server:port. Note "ftps" not "ftp".
  • User Mode Linux (UML) is merged with the default kernel since 2.6.9. However, the vanilla kernel is simply impossible for me to build a working UML (at least for 2.6.9 & 2.6.10, while 2.6.11-rc5 is OK). I found out that using the bb4 patch can give me a working UML, though the default config is still buggy. Here is the 2.6.9 config I used. Some problems remain:
    • Networking with slirp seems broken.
    • SMP is broken (2.6.11-rc5 SMP version can't run very far during boot).
    • Enable SMP and kernel debug symbol will cause error during last step linking: kernel/profile.c:199 profile_pc undefined.

    Working 2.6.12-rc2 config

  • Network backup using netcat: at server nc -l -p 3000 | tar xvf -, at client tar cvf - files_and_directories | nc server 3000. 3000 is port number used. The idea is to tar everything, send to server, and extract the tar ball at server.

  • CUPS printer daemon saying "printer not ready" even there is no job running.: This rarely happened problem may be caused by configuration problems. Look at /etc/cups/printers.conf and see if "State Stopped" appears instead of the correct "State Idle". Make the the change and restart CUPS daemon.

  • iPod on Linux: Use dmesg to find out the device name of iPod, e.g., mine is sda. eject /dev/sda (if /dev/sda is no good, use /dev/sda2) can be issued as root to get rid of "Do not disconnect" on the iPod screen and returning to normal menu. You can mount sda2 as vfat file system to see structures on your iPod.

  • Grammar check for LaTex files: latex2rtf can convert Tex sources into RTF files, which can then be read by OpenOffice or M$ Office for grammar check. An alternative is to use latex2html, but I have problems with it.

  • Mount remote file systems via SSH (all users): Use SSHFS, simply run sshfs hostname: mountpoint. SSHFS depends on FUSE, which is already included in the main stream Linux since 2.6.14. To unmount, run fusermount -u mountpoint.

  • Latex Related Tips:
    • Make a PDF document: 1) LaTeX (+bibTeX) -> dvips -> ps2pdf. Use "hyperref" package for hyperlinks and remember to add the "breaklinks=true" option to break references that exceed one line, especially for List of Figures/Tables. 2) pdfLaTeX (+bibTeX). Must convert all .eps-graphics into PDF format. Use "epstopdf". See this page for more details.
    • hyperref package causes long URLs not wrapping (breaking into multiple lines): I had this problem for bibliography. My solution is to renew the \url command \renewcommand\url{\begingroup \Url} of the url package, but hyper-links will be missing for URLs.
    • Balances columns on last page in twocolumn mode: use "flushend" package, i.e., \usepackage{flushend}.
    • Controlling LaTeX Floats

  • .avi file editing with mencoder
    • Split: mencoder -ovc copy -oac copy -endpos 0:50:00 -o foo-part1.avi foo.avi split ends at 50 minutes,
      mencoder -ovc copy -oac copy -ss 0:50:00 -o foo-part2.avi foo.avi split starts at 50 minutes.
    • Transcode, see this page, e.g., mencoder foo.avi -o bar.avi -ovc lavc -oac lavc

  • Recovery deleted files or lost partitions: TestDisk and PhotoRec. Both tools are free, work on Linux/Win/Mac, and are said to work for CDs, DVDs, and flash media. It seems both read raw sectors and try to recognize files, so recovery is quite complete if lost files are not overwritten by other data.

  • Display Chinese characters in terminals: Create ~/.i18n file with content:
    LANG=zh_CN.GB2312
    LANGUAGE=en_US.UTF-8
    LC_CTYPE=zh_CN.GB2312
    LC_TIME=en_US.UTF-8

  • 100 Linux tips by Mike Chirico.

Free Online Linux Books

My Favoriate FREE Linux Tools

  • Terminals
    • konsole - KDE Terminal
    • screen - console tool
  • X Window Manager
    • KDE - favoriate, more themes/icons/color/etc. can be found here
    • Gnome
    • XCIM - Chinese X input.
  • Document Editor/Reader:
    • vim - classic and great!
    • emacs
    • Acrobat Reader - for PDF file
    • xCHM - viewer for M$ .chm file
  • Media:
    • mplayer - Player for everything! DivX avi, mov, asf, wmv, etc. Included "mencoder" can do transcoding.
    • SopCast GUI - Network TV (using mplayer as backend)
    • xmms - mp3 player, APE plugin can be found here
    • RealPlayer - real media
    • transcode - avi file editing, includes avifix, avisplit, avimerge, avisync
    • GQView - image viewer
    • GIMP - image editor like Photoshop
    • mkgallery, bbgallery - Photo gallery creation, using ImageMagick
    • CD Burning:
      • xcdroast, k3b - great GUI
      • cdrecord - command line tool
      • cdrdao - burn bin/cue file
      • bchunk - convert .bin/.cue files to .iso and .cdr tracks
  • Office:
    • latex - professional documentation package
      • CJK - Chinese Latex support
    • GhostScript and GhostView
    • Graphviz - graph creations
    • bibtex2html - transform bibliography to html
    • Evolution - Email/Calendar/AddressBook groupware
    • OpenOffice - document processing, spreadsheet, and presentation
    • StarDict, sdcv - dictionary
  • Development:
    • ValGrind - very handy memory debugger, profiler; a MUST for serious C/C++ programs.
    • KGDB - Linux kernel debugger
    • OProfile, statistical profiler for both the kernel and user programs.
    • cvs - version control [doc.]
    • Programming Languages: c, c++, tcl/tk, perl, java, shell, sed, awk
    • flex - GNU lexical analyzer
    • bison - GNU Yacc-like parser generator
    • gcc - GNU c/c++ compiler
    • gdb - GNU debugger
    • make, GNU automake, GNU autoconf, libtool
    • MySQL - database
    • libnet - packet injection library
    • libpcap - packet capture library
  • Security:
    • lsof - command, list open files
    • truss - command, trace system calls of a program
    • top - command, resource usage
    • vmstat - command, virtual memory usage
    • w - command, current user
    • nmap - best scanning tool
    • John the Ripper - password cracker
    • tcpdump - network sniffer
    • snort - network intrusion detection system
    • tcpflow - reconstruct end-to-end TCP traffic
    • iptable - firewall
    • tripwire - system integrity check
    • Encryption, Data Signing
      • GnuPG
      • pgp
  • Networking:
    • pine - console based e-mail client
    • Apache web server
    • Samba - File server
    • Proxy Servers:
      • Squid
      • Socks5
    • Web Browsers:
    • QTerm - BBS Client in Linux
    • wget - web/FTP download client
    • ncftp, lftp - command line FTP client
    • VNC - remote desktop
    • stunnel - SSL tunnel for TCP connections
    • Gnutella clients:
    • gaim - integrates IMs such as ICQ, MSN, Yahoo!
    • rdesktop - Windows terminal service client
    • SSH Client/Server:
      • OpenSSH
      • SSH - from www.ssh.com
    • UCD-SNMP - snmp utility
  • File Utility:
    • tar - archive files
    • rar - for rar archive
    • zip/unzip - for .zip file
    • bzip2/bunzip2 - for .bz2 file
    • gzip/gunzip - for .gz file
    • md5sum - generate md5 hash
    • sha1sum - generate SHA-1 hash
    • cksfv - CRC checking, linux couterpart for WinSFV
    • cabextract - extract M$ .cab file

Other Resources

posted on 2008-03-15 17:34 flyonok 阅读(710) 评论(0)  编辑 收藏 引用 所属分类: linux


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理