Linux/Unix commands

Basic file commands

Command [extra params] Description
man command Shows the manual-page for command.
info command Shows the info-page for command(more detailed than man).
cp [-R] from_where to_where Copy files from place to place.
mv from_where to_where Move files from place to place.
rm [-rf] target_file Remove files
du [-sk] disk usage in kilobytes
swapon [-s] swap usage (summary)
free displays free memory and swap resources
dmidecode Dump DMI (SMBIOS) table to human readable format
cardctl PCMCIA card control utility ( e.g. cardctl ident)
top displays the top CPU processes
ln [-s] real_dir_name link_name make hard or symbolic links to files
locate file_name search for files
mount /dev/device /mnt_place [-o uid=user,gid=group,umask=0007] Sets up(mounts) a file system to /mnt_place directory.
umount /dev/device Unmounts the wanted device.
dmesg print or control the kernel ring buffer.

Configuration

Digital Cameras

The best program for this can be found from:
http://www.uni-ulm.de/~eschiehl/

Adding groups and users

Commands adduser and addgroup will deal with this. The settings are saved into /etc/group. For example group root0 where belong ssheikki and www-data is defined like this:
root0:x:102:ssheikki,www-data

groups user_name shows the groups where user_name belongs to.

Mounting devices

Mounts are loaded from /etc/fstab in the startup.
For example line(in /etc/fstab)
/dev/hda1 /c vfat gid=root0,uid=www-data,umask=0007 0 0
mounts the /dev/hda1 to /c with given parameters.

Same can be given also from command-line:
mount /dev/hda1 /c -o gid=root0,uid=www-data,umask=0007

To see all partitions, use:
fdisk -l command
If you want for example remount your read filesystem to rewritable, use;:
mount -o remount,rw /dev/hda2

Mouse Settings

Mouse device is /dev/mouse, a symbolic link(ln -s) to the physical device, such as:
/dev/ttyS0 for COM1
/dev/ttyS1 for COM2
/dev/ttyS2 for COM3
/dev/ttyS3 for COM4

Mouse can be configured using gpmconfig which is config for gpm. The settings for standard ps2 mouse are following:
Set the responsiveness (normally not needed) [1]?
> 10
Repeat protocol (enter 'none' to turn repeating off) [raw]?
>
Do you want to add any additional arguments []?
>
Do you want to test this configuration (y/N)? y
gpm -m /dev/psaux -t imps2 -r 10 -Rraw
Finish testing by typing Ctrl-D

Current configuration: -m /dev/psaux -t imps2 -r 10 -Rraw
Device: /dev/psaux
Type: imps2
Responsiveness: 10
Repeat_Type: raw

Runtime information /proc/

The /proc file system is a pseudo-filesystem that stores relevant informations about the kernel(man 5 proc). For example /proc/interrupts shows how many times each IRQ was used and by whom.

Unix has Different Run Levels

Each run level has own configuration files. In debian they are in /etc/rc#.d/ and in redhat they are /etc/rc.d/rc#.d/ (# means the run level number).

Power Off: Run Level 0(/etc/rc0.d/)
Single User: Run Level 1(/etc/rc1.d/)
Multiuser: Run Level 2(/etc/rc2.d/)
Full Multiuser(2 with NFS): Run Level 3(/etc/rc3.d/)
Unused: Run Level 4(/etc/rc4.d/)
X11(graphical): Run Level 5(/etc/rc5.d/)
Reboot: Run Level 6(/etc/rc6.d/)

To change boot behaviour, modify /etc/inittab. The run levels are also described there.

A script starting with S starts a service. One starting with K stops a service. The number after the `S' or `K' specifies the order in which the scripts are run. For example, S25xdm will start before S35xdm.

Stop/Start/Restart scripts

Subdirectory /etc/init.d/ (or in redhat /etc/rc.d/init.d) contains all startup scripts that may be used to stop/start/restart the related process. For example /ec/init.d/gpm stop will stop the mouse and /ec/init.d/gpm start will start it again.

Installing kernel

/usr/src/linux/README tells what to do. First download the latest source. Then everything starts with "make menuconfig". If you don't have ncurses-dev installed please find it from the web or in debian just use "apt-get install ncurses-dev".

As simplest, the following steps should be taken(with 2.4.x kernel):
make menuconfig
make dep
make bzImage
make modules
make modules_install
make install

or using with make-kpkg:
make-kpkg --targets
make-kpkg buildpackage

Things to remember in menuconfig


To select modules for different kernels in /etc/modules

Write following to /etc/modules:
if `kernelversion` == 2.4
  uhci
  emu10k1
  ...
elseif `kernelversion` == 2.6
  uhci-hcd
  snd-emu10k1
  ...
endif

Window managers

To handle logging I recommend; wdm(WINGs Display Manager).
For actual managers you should try;

Test if your port X is open


To resolve net-addresses

Use nmap, host and dig programs.

Misc

lspci, Shows info about your pci cards(replaces /proc/pci)
tune2fs, from ext2 -> ext3 for example.

[1] Linux Administration Guide
http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/admin/lxadmgde.html

To setup a new disk

Partition the disk: cfdisk.
Make it ext3: mke2fs -j /dev/hdXX
Set parameters, turn ext2, etc: tune2fs -m 0 /dev/hda1
Remember to put DMA on: hdparm -c /dev/hdb, hdparm -c 1 /dev/hdb
Good configure for hdparm is for example:
/dev/hda:
 multcount    = 16 (on)
 I/O support  =  1 (32-bit)
 unmaskirq    =  1 (on)
 using_dma    =  1 (on)
 keepsettings =  0 (off)
 nowerr       =  0 (off)
 readonly     =  0 (off)
 readahead    =  8 (on)
 geometry     = 19457/255/63, sectors = 312581808, start = 0
 busstate     =  1 (on)
and acceptable speed for example:
ssheikki:~# hdparm -Tt /dev/hda

/dev/hda:
 Timing buffer-cache reads:   128 MB in  0.43 seconds =297.67 MB/sec
 Timing buffered disk reads:  64 MB in  1.17 seconds = 54.70 MB/sec
If you get "HDIO_SET_DMA failed: Invalid argument", when setting hdparm -d1 /dev/hda then your kernel is missing VIA module. Select it from:
ATA/IDE/MFM/RLL support  --->  
  IDE, ATA and ATAPI Block devices  --->
    <*>     VIA82CXXX chipset support 
For real world tests:
Writing speed:
time dd if=/dev/zero of=test bs=1048576 count=1024
Reading speed:
time dd if=test of=/dev/null bs=1048576 count=1024

In the end you can umount your file system and do fsck(filesystem check):
For ext2 in is done: e2fsck -c -c -C 0 -f -v /dev/hdXX

Helvetin skandit

You can try these and hope that it will work! :)
1. loadkeys fi-latin1
2. add to /etc/locale.gen following
fi_FI ISO-8859-1
fi_FI@euro ISO-8859-15
And the run locale-gen.
3. http://www.arska.org/finnish-howto/html/
4. xorg.conf keyboard should look about like this for Finns:
Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "keyboard"
        Option      "XkbRules" "xorg"
        Option      "XkbModel" "pc105"           # pc105 is finnish
        Option      "XkbLayout" "fi"
EndSection

/dev/null breaks

rm the old and create new with:
mknod -m 666 /dev/null c 1 3
The break might cause for example sshd fail to start(sshd[756]: fatal: daemon() failed: Success).

Change finger information

Use chfn command.

Setting up libraries

Add library paths in:
/etc/ld.so.conf
See man for the following commands:
ldconfig
ldd program

Gphoto2 & USB settings

You need USB support from kernel(see preferred kernel settings below and/or Linux USB).
You need: libusb
You need: libgphoto2 installed. Remember to see that usb is found by libgphoto2.
Last you need: gphoto2 installed.
How to know that something might work:
less /proc/bus/usb/devices
gphoto2 --list-ports
gphoto2 --auto-detect

Prefered kernel settings for usb:
debian:/usr/src/kernel/linux-2.6.7# grep -i usb .config | grep -v "#"
CONFIG_USB=m
CONFIG_USB_DEVICEFS=y
CONFIG_USB_EHCI_HCD=m
CONFIG_USB_UHCI_HCD=m
CONFIG_USB_HID=m
CONFIG_USB_HIDINPUT=y

Find out who is using some file or socket

fuser -v /resource

Ssh authentication without password

Goto computer FROM where you want to access some computer:
Generate key pares:
ssh-keygen -b 2048 -t dsa
Copy the file to the computer you want to access. If many computers, just append the id_dsa.pub-file to authorized_keys-file.
scp id_dsa.pub user@remotehost:.ssh/authorized_keys
And volaa... do a test:
ssh user@remotehost

Install windows and Linux on different harddrives, Lilo config

Situation example: linux on Master Disk MBR(/dev/hda) and windows on Slave Disk MBR(/dev/hdb). In this situation, linux bootloader(lilo in this example) starts from Master MBR. To add Windows boot you need to add following choice to /etc/lilo.conf.
other=/dev/hdb2
        label="Windows"
        table=/dev/hdb
        map-drive=0x80
                to=0x81
        map-drive=0x81
                to=0x80
It changes the active disk in the boot so Windows will be booted unnoticed.

Where are your cd-roms

To see this, cat:
cat /proc/sys/dev/cdrom/info

Second LoopBack interface/ip for local usage

If you want 193.167.3.129, for example, to point to your own computer, use:
/sbin/ifconfig lo:1 193.167.3.129

Test in local:
ssheikki@jt11-231-2:/$ traceroute 193.167.3.129
traceroute to 193.167.3.129 (193.167.3.129), 30 hops max, 38 byte packets
 1  jt11-231-2 (193.167.3.129)  0.061 ms  0.020 ms  0.014 ms
Test in computer where loopBack adapter isn't used:
ssheikki@jt7-236:~$ traceroute 193.167.3.129
traceroute to 193.167.3.129 (193.167.3.129), 30 hops max, 38 byte packets
 1  trinet-gw (130.233.31.254)  2.303 ms  2.331 ms  3.403 ms
 2  gw-2-v96.hut.fi (130.233.231.19)  0.899 ms  0.634 ms  0.681 ms
 3  u35211.win.hut.fi (193.167.3.129)  0.833 ms  4.314 ms  0.591 ms

Howto setup http over SSL(https)

creating the certificate and config apache
securing the actual webpages

Howto tunnel RMI through HTTP

  • Install Apache 2.x to port 80.
  • Install Tomcat 4.x to port 8080. For windows, use exe-installer.
  • Install Tomcat Web Server Connectors, i.e. get mod_jk_1.2.x.dll(in linux mod_jk_1.2.x.so).
  • Make sure you have following lines in Apache httpd.conf:
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    LoadModule rewrite_module modules/mod_rewrite.so
    
    Options Indexes FollowSymLinks ExecCGI
    
    
        AllowOverride None
        Options +ExecCGI
        Order allow,deny
        Allow from all
    
    
    RewriteEngine on
    RewriteLog C:/tomcat/rewrite.log
    RewriteLogLevel 9
    RewriteRule ^/cgi-bin/java\-rmi\.cgi$ http://localhost/examples/servlet/ServletHandler    [P]
    
    
    LoadModule jk_module C:/Winnt/system32/mod_jk_1.2.5_2.0.47.dll
     
    
    JkWorkersFile "C:/tomcat/conf/workers.properties"
    JkLogFile "C:/tomcat/logs/mod_jk.log" 
    
    JkLogLevel info 
    
    JkMount /manager ajp13
    JkMount /manager/* ajp13 
    
    JkMount /examples ajp13
    JkMount /examples/* ajp13 
    
    JkMount /tomcat-docs ajp13
    JkMount /tomcat-docs/* ajp13 
    
    JkMount /webdav ajp13
    JkMount /webdav/* ajp13 
    
    JkMount /*.jsp ajp13 
    
  • tomcat/conf/workers.properties should contain:
    workers.tomcat_home=C:/tomcat
    workers.java_home=C:\j2sdk1.4.2_01
    ps=\ 
    
    worker.list=ajp13, ajp14
    worker.ajp13.port=8009
    worker.ajp13.host=localhost
    worker.ajp13.type=ajp13
    worker.ajp13.lbfactor=1 
    
    worker.loadbalancer.type=lb
    worker.loadbalancer.balanced_workers=ajp13
    worker.inprocess.type=jni
    worker.inprocess.class_path=$(workers.tomcat_home)$(ps)server$(ps)lib$(ps)catalina.jar
    worker.inprocess.cmd_line=start
    worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)server$(ps)jvm.dll
    worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
    worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr 
    
  • Tadaa... you might want to test with: rmiservlethandler.zip.
  • My iteration time for this easy setup was 16h. :I

    Image and video screen capture in Linux

    The software for this is xvidcap.
    To capture in avi format for example:
    xvidcap --file grap.avi --time 100
    Brilliant! :)

    Making thumbnails images

    Use convert:
    convert -resize 15x15% original.gif original_thumb.gif

    It might be usefull to use script:
     for image in *.jpg
       do
       echo "Processing: $image ..."
       convert  -resize 15x15% $image thumbs/$image
       echo "done."
     done
    

    Create animated gifs

    Gifmerge is neat and simple:
    ./gifmerge -l0 -10 animate_this/*.gif > anim.gif

    Sometimes you might to need a script, that selects non-duplicate images and converts them to be in right format and then creates the animation:
    mkdir __tmp
     
    for image in *.gif
      do
      if [ $image_prev ] ; then
         diffout="`diff $image_prev $image | wc -l`"
         if [ $diffout = "0" ] ; then
            echo "Identical images: $image_prev $image, not processed."
         else
            convert  -resize 100x100% $image __tmp/$image
            echo "Image $image processed."
         fi
      else
        convert  -resize 100x100% $image __tmp/$image
        echo "Image $image processed."
      fi
      image_prev=$image
    done
    
    ./gifmerge -l0 -10 __tmp/*.gif > anim.gif
     
    rm -rf __tmp
     
    echo "Output should be here:"
    ls -laF anim.gif
    echo "done."
    

    Shell scripting

    http://vertigo.hsrl.rutgers.edu/ug/shell_help.html

    DVD players

    Install ogle and ogle-gui. Remeber that you also need libdvdcss for all movies to be readable.

    Example run:
    ogle -u gui /dev/hdc

    Howto install foreign packages(rpm, etc.) in debian

    There is program called alien, which converts packages to debian packages which can be then easily installed:
    alien - Convert or install an alien binary package

    alien --to-deb cool-program.rpm
    dpkg -i cool-program.deb

    Howto merge and edit avi-files

    Install avidemux or avimerge.
    Note: Avimerge is easier but has problems with audio and etc.

    Video editors

    avidemux - best with avi files, at least, maybe best in others too.
    cinelerra

    Clock synchronization with NTP

    Network Time Protocol debian packages: ntp, ntp-simple.
    Servers: ntp1.hut.fi, ntp1.funet.fi
    List ntp servers:
    ntpq -p

    Howto capture stream data:

    - to capture rm-stream into wav:
    vsound -t -v -f output.wav RealPlayer8/realplay input.rm
    vsound: digitally record output of an OSS audio program.

    - rip radio streams to mp3 files:
    streamripper URL

    Howto convert sound into mp3/ogg

    - audacity - Graphical cross-platform audio editor.
    Encodes wav to mp3/ogg and lots of more. And use through very usable GUI! Brilliant! Myös Suomen kielen tuki löytyy!

    Timing commands

  • at: input time and wanted commands to execute.
  • crontab input.file: crontab -l list the commands to be executed.

    Where the executed program is on the path and it's man page

    whereis

    Example, where is whereis program:
    root@debian:/# whereis whereis
    whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz
    

    Search files recursively for wanted string, windows and linux

    Linux:
    grep -r search_string *

    Windows(not in XP):
    search search_string

    Wget and for example

    for((i=9201;9300>i;i++)); do wget http://osoite.org/292_$i.jpg ;done

    Converting video formats, e.g. vro to avi/mpeg/etc

    Use memcoder, which is part of the mplayer:
    mencoder source.vro -o output.avi -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1800 -oac copy
    Notes: -ovc defines video codec.
    Notes 2: msmpeg4 codec works in Windows

    Converting mov -> avi

    mencoder *.MOV -o koeX.avi -srate 8000 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1800 -oac mp3lame -lameopts vbr=3:br=32

    Update alternative packet

    update-alternatives --config automake

    Display network information

    netstat -a
    Print network connections, routing tables, interface
    statistics, masquerade connections, and multicast memberships.

    Executing X programs as root

    Install sux. Log in as normal user who is allowed to use X programs. Write sux -, behaves just like su but transfers $DISPLAY and the X cookies.

    Securing computer for local-hack

    Disable floppy boot and add-password for lilo: security + howto.

    More sequrity issues: ulimit.

    Bluetooth installation

    Pretty good tutorial is here.

    But basically it's like this:

    Execute images with qemu

    The QEMU System emulator simulates a complete PC!

    Update dynamic libraries

    Configure dynamic linker run-time bindings:
    ldconfig

    Security tools

    Nessus; free, powerful, up-to-date and easy to use remote security scanner.
    tiger; report system security vulnerabilities.

    Neural Network implementations

    Fast Artificial Neural Network Library implements multilayer artificial neural networks in C with support for both fully connected and sparsely connected networks:
    http://fann.sourceforge.net/

    USB hard disk

    - Check that disk is detected, e.g.: less /proc/bus/usb/devices
    - Partition the disk, e.g.: cfdisk /dev/sda
    - Format the partitions, e.g.: mke2fs -j /dev/sdaX
    - Test speed(~27MB/sec) e.g.: hdparm -tT /dev/sda6
    - Mount and enjoy, e.g.: mount -t ext3 /dev/sda6 /usbhd

    Samba

    smbstatus, smbclient, smbmount.

    CVS-howto

    set up: cvs -d CVSROOT init
    import: cvs -dCVSROOT import projektinnimi vendor_tag release_tag
    e.g. cvs -d/private/cvs_repository import peacebot TKK start
    set CVSROOT: export CVSROOT=:ext:ssheikki@kosh.hut.fi:/u/opi/90/ssheikki/cvs_repository

    Benchmarking computers

    LMbench, Tools for Performance Analysis.

    Open connections

    Show all open connections: netstat -a
    Show port numbers: netstat -n -a
    Who is using port: fuser -n tcp
    Verbose who is using port: fuser -n tcp -v

    DNS name server

    apt-get install bind
    To create for exaple alias for jt11-117-3.tky.hut.fi
    master zone tky.hut.fi
    and the name alias jt11-117-3
    
    For easy configuration, please install webmin.
    webmin-bind, webmin-apache, webmin-samba, etc...
    Note that webmin starts it's own http server:
    https://127.0.0.1:10000/

    Analyze X-window connections

    xdpyinfo - display information utility for X
    xev - print contents of X events
    xwininfo - window information utility for X

    Partitioning disk in linux so that windows understands it

    Partion like this,
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        1824    14651248+   c  W95 FAT32 (LBA)
    /dev/sdb2            4256       30401   210017745    5  Extended
    /dev/sdb3            1825        4255    19527007+   c  W95 FAT32 (LBA)
    /dev/sdb5   *        4256        5471     9767488+  83  Linux
    /dev/sdb6            5472       30401   200250193+  83  Linux
    
    Now evetyhing is ok but the Extended type is wrong. Let's change it with fdisk.
    Command (m for help): t
    Partition number (1-6): 2
    Hex code (type L to list codes): L
    Hex code (type L to list codes): f
    Command (m for help): w
    
    Now the table looks like this:
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        1824    14651248+   c  W95 FAT32 (LBA)
    /dev/sdb2            4256       30401   210017745    f  W95 Ext'd (LBA)
    /dev/sdb3            1825        4255    19527007+   c  W95 FAT32 (LBA)
    /dev/sdb5   *        4256        5471     9767488+  83  Linux
    /dev/sdb6            5472       30401   200250193+  83  Linux
    

    Backup whole mysql-database

    Dump all databases with root access:
    mysqldump --all-databases -p -u root | gzip -c > mysql_dump_archive.sql.gz

    To restore the databases, run the console output of gzip through mysql:
    gzip -cd mysql_dump_archive.sql.gz | mysql -u root -p

    Another option is to log as a root into a mysql database:
    mysql -u root -p
    If you do not remember your password, you can reset it using root shell:
    /usr/bin/mysqladmin -u root password 'new_password'
    and then execute
    source mysql_dump_archive.sql;

    Upgrading mysql database from 1.5 to 1.7.1 (Ubuntu)

    Step1: Take backup of the mysql database and save AdminSettings.php and LocalSettings.php files. Install using aptitude the new mediawiki version (do not configure it!!, just install, i.e. aptitude install mediawiki). Copy AdminSettings.php and LocalSettings.php to /var/lib/mediawiki1.7 directory.

    Step2: Sign in the mysql database (mysql -u root -p) and rename your old table to text table. Like this:
    usedb wikidb;
    rename table sm_old to sm_text;
    

    Step3: Go to the /usr/share/mediawiki1.7/maintenance directory and command "php upgrade.php". All should go happily and last print is "Done.". Then command "php refreshLinks.php" to finish. Now the database should work again as before (or better).

    Backuping the mediawiki

    Make a static html page backup with:
    php /usr/share/mediawiki1.7/maintenance/dumpHTML.php -d /destination/dir
    Make an xml dump of the database:
    php dumpBackup.php --full > dumpBackup.xml
    Dump mysql databases:
    mysqldump --all-databases -p -u root | gzip -c > mysql_dump_archive.sql.gz

    GANTT chart - project management tool
    planner

    Irssi

    /set term_charset ISO-8859-15
    /set term_force_colors ON

    sftp/scp connection with chroot

    You can restrict the user to his home directory:
    apt-get install scponly
    Check that /usr/sbin/scponlyc has suid:
    chmod 4755 scponlyc

    Using rdesktop

    Opening a connection with 24bit 80% windows size and with local disk linked to the remote computer:
    rdesktop -a 24 -g 80% -r disk:yebbey=/home/ssheikki/ rondo.tkk.fi

    Opening a connection with 24bit fullscreen and with local disk linked to the remote computer:
    rdesktop -a 24 -f -r disk:yebbey=/home/ssheikki/ rondo.tkk.fi

    Connecting a computer behind firewall:
    If you have a ssh server that you can connect at TKK, just make a ssh tunnel to that computer like this:
    ssh -L 7777:rondo.tkk.fi:3389 username@autlab
    Now you can open remote desktop just by connecting:
    rdesktop -a 24 -f -r disk:localdisk=/home/username/ localhost:7777

    SVN (Subversion) howto

    Checkout:
    svn checkout http://repository.address.com/path

    Status of local files compared to the svn repository:
    svn status [files/dirs]

    Update:
    svn commit [files/dirs]

    Commit:
    svn commit [files/dirs]

    Resolve (my files are good, update them to repository):
    svn resolved [files/dirs]

    Revert (my files are crap, get original ones from repository):
    svn revert [files/dirs]

    Check what is the status of files in current directory:
    svn -v status

    swheikki
    ruuvi.helsinki.fi
    melkinpaasi.cs.helsinki.fi

    subversion howto with https

    List project in repository:
    svn --username ssheikki list https://localhost/svn/

    Import a directory (svnhowto) to repository as svnhowto:
    svn --username ssheikki import svnhowto https://localhost/svn/svnhowto -m "initial import"

    Checkout all from repository :
    svn --username ssheikki checkout https://localhost/svn

    Commit:
    svn commit

    Delete:
    svn delete svnhowto

    subversion howto with ssh

    Same commands as above but you need to give path in the server:
    export SVN_SSH="ssh -l ssheikki"
    svn checkout svn+ssh://aut40/svn_repository/project_name

    subversion howto with local repository

    svn co file:///svn_repository/project_name

    Multiple ssh connections via one ip

    Add in /etc/ssh/ssh_config or in ~/.ssh/config
    Host aut40
            Hostname        yourserver.ftl
            Port            49490
            HostKeyAlias    aut40
            CheckHostIP no
    Host lap
            Hostname        yourserver.ftl
            Port            49491
            HostKeyAlias    lap
            CheckHostIP no
    

    Pasword change with first visit

    After creating the username, set the password to be expired. It requires user the change it when he tries to log in:
    passwd -e

    Howto backup your hard disk

    dump and restore packages

    Tar exclude directory

    tar -cvfX tar-name.tar exclude-file dirtobetarred/

    Find file with full path and date

    find . | grep McCtrl.c > /tmp/lsgreptmp && ll `cat /tmp/lsgreptmp`

    Kernel magic instructions

    List instructions, helps if computer is jammed:
    Alt + Prnt Screen + h

    Display all IRQ:s

    cat /proc/interrupts

    Design programs (open source)

    * Inkscape (http://www.inkscape.org/), Open Source vector graphics editor, with capabilities similar to Illustrator, Freehand, CorelDraw, or Xara X.
    * Dia (http://dia-installer.sourceforge.net/), diagram creation program, inspired by the commercial Windows program 'Visio'.
    * GIMP (http://www.gimp.org/), GNU Image Manipulation Program, for such tasks as photo retouching, image composition and image authoring.

    Programming editors (open source)

    # Code::blocks (http://www.codeblocks.org/) (Windows)
    # devcpp (http://www.bloodshed.net/devcpp.html) (Windows)

    Tell command that parameters end

    Problem, e.g. howto remove --bzip2 file. Answer:
    rm -- "--bzip2"

    Latex

    xdvi - display dvi files
    Create a one big html page from the tex document:
    latex2html -split 0 thesis.tex

    Mplayer and DVD subtitles

    mplayer -sid ID DVDFILE.VIDEO

    Create ssh-tunnel

    Tunnel FROM remote.iki.fi port 10024 TO localhost port 22:
    ssh -N -R 10024:localhost:22 -2 ssheikki@remote.iki.fi

    Ssh forward in case GatewayPorts off

    Computer behind firewall:
    ssh -v -N -R 49490:localhost:22 -2 ssheikki@asrobo.hut.fi
    Computer being forwarder:
    mkfifo in out
    cat out | nc -l -p49491 > in
    cat in | nc localhost 49490 > out

    Dave port:
    ssh -N -L 81:localhost:81 -2 ssheikki@voittoputki.dyndns.org

    CVS HOWTO

    Create a CVS repository where your projects are saved:
    cvs -d /absolut/path/of/your/repository init

    Put your project to the CVS repository:
    cd /directory/where/your/projects/is
    cvs -d /absolut/path/of/your/repository import -m "Name of your Project" modulename_of_your_project vendor_name version_1_0_0

    Get the stuff from CVS:
    cd /new/working/directory/of/you/project
    cvs -d /absolut/path/of/your/repository co modulename_of_your_project

    Update, add and Commit cvs:
    cvs -d /absolut/path/of/your/repository update
    cvs -d /absolut/path/of/your/repository add name_of_file_tobe_added
    cvs -d /absolut/path/of/your/repository commit

    WLAN howto

    Enable internal driver, e.g. for Acer Aspire 5021WLMi:
    1) Download and install acer_acpi:
    make acer_acpi.ko # How to compile the driver for 2.6 kernel
    modprobe acer_acpi
    echo "enabled: 1" >/proc/acpi/acer/wireless
    Install wlan driver, e.g. for Broadcom BCM5700:
    modprobe ndiswrapper
    ndiswrapper -i bcmwl5.inf

    Scan for network interfaces:
    iwlist wlan0 scan
    Connect wlan0 into a network node if found:
    iwconfig wlan0 essid ESSID_OF_FOUND_NETWORK
    ifconfig wlan0 up
    Get connection settings:
    dhclient wlan0

    PPPOE howto

    First time

    Make sure PPP is enabled in the kernel!
    Configure pppoe:
    pppoeconf

    After first time

    Make sure that server is started:
    /etc/init.d/ppp start
    Start pppoe connection:
    pon dsl-provider

    Continue http-download

    wget -c file_cancelled.zip

    Download one page with all it is inline contents, e.g. images

    Download all photos on the page:
    wget -H -p -nd -Ajpg http://www.address.com/

    Emulate 32bit, chroot

    chroot /var/chroot/sid-ia32

    Sending attachment files in linux

    mutt -s "Test" -a Attachment.tar.bz2 address@mail.com < body_message.txt

    Compiling kernel in Debian with make-kpkg

    Configure kernel:
    make menuconfig
    Compile kernel into debian package:
    make-kpkg buildpackage
    If this fails for some reason, you might want to do a clean:
    make-kpkg clean

    Compiling kernel-modules in Debian with make-kpkg

    Copy kernel-module codes into location defined by MODULE_LOC (default is /usr/src/modules). Build modules:
    make-kpkg modules

    Open remote desktop connection

    rdesktop -k fi -d universe -u seppo.heikkila virgo.isunet.edu

    Partition a USB stick with messed partition table

    Create new partition and ignore the one used:
    cfdisk -z /dev/sdb

    Format file system for windows (mkfs.vfat is part of dosfstools package)
    mkfs.vfat /dev/sdb1

    Howto install/update debian packages offline

    Update your package list apt-get --print-uris update | sed s/\'//g
    Download the packes e.g. with wget or apt-zip script. Use bunzip2 or gunzip to extract all source and packages files.
    rename 's/Sources$/Sources.bz2/' *Sources && bunzip2 *.bz2
    rename 's/Packages$/Packages.bz2/' *Packages && bunzip2 *.bz2
    Copy the downloaded files to /var/lib/apt/lists/ and update the package list by running
    apt-get check

    Get packages apt-move and apt-zip:
    apt-get --print-uris install apt-zip
    apt-get --print-uris install apt-move
    and copy them to /var/cache/apt/archives/. Then you can just use apt-get install to install the packages.

    Generate a package download script
    apt-zip-list -m /usbstick -a upgrade
    To do the same in random directory, use the --skip-mount parameter. In UNIX/Linux, run the script to get packages. If you have to use a windows machine, see below.
    Download in windows
    Download unix tools package, e.g. UnxUtils.

    In case proxy servers have to be used, set http_proxy and ftp_proxy.
    export http_proxy=http://proxy.company.com:portnumber/
    export ftp_proxy=http://proxy.company.com:portnumber/

    Modify the script to work in windows:
    - separate parameters
    p1 = `echo $1 | gawk '{print $1}'`
    p2 = `echo $1 | gawk '{print $2}'`
    etc.
    - add wget proxy username and password
    wget --proxy-user=USERNAME --proxy-passwd=PASSWD -t3 -nv -O $2 $1
    Install downloaded packages apt-zip-inst does not seem to work so you can copy the packages directly to /var/cache/apt/archives/. Then just install the packages by running
    apt-get upgrade
    Install new individual packages Get urls of your_package update urls:
    apt-get -y --print-uris install your_package | grep deb | cut -f1 "-d " | sed s/\'//g
    Download your package, copy it to /var/cache/apt/archives/ and install it normally using apt-get install
    apt-get install your_package

    Autofs removable devices

    Get autofs packet:
    apt-get install autofs

    Create a /etc/auto.master file with this content
    /var/autofs/removable /etc/auto.removable --timeout=2
    The timeout defines when you can pull the device out.

    Create auto.removable file
    usbstick        -fstype=vfat,rw,gid=100,umask=002       :/dev/sda1
    cdrom           -fstype=iso9660,ro,sync,nodev,nosuid    :/dev/hdc
    
    Create symbol links to this paths
    ln -s /var/autofs/removable/usbstick /usbstick
    ln -s /var/autofs/removable/cdrom /cdrom

    Restart autofs:
    /etc/init.d/autofs

    Use the device, e.g.
    ln -laF /usbstick
    You can pull the device out after "timeout" seconds has passed.

    Connect to vnc server

    For example realvnc compatible is
    vncviewer address:display

    Add apt-get pgp-key

    After getting verification error while apt-get update, take the last 8 digits of the key and
    gpg --keyserver pgp.mit.edu --recv-keys 2D230C5F
    gpg --armor --export 2D230C5F | apt-key add -

    Who or what is using file

    fuser used_file_or_device

    Transfer file using serial cable

    Send file:
    cat file > /dev/ttyS0
    Read file:
    cat /dev/ttyS0

    How can you see contents of debian package

    dpkg --contents package.deb

    Howto encrypt yout harddisk

    Make sure that you have these modules in your kernel:
    dm_mod, dm_crypt, sha512, aes

    Format a device as luksDevice which is standard for hard disk encryption (Linux Unified Key Setup). Enter password when asked:
    cryptsetup -c aes-cbc-essiv:sha256 luksFormat /dev/sda1

    Create mapping to the drive:
    cryptsetup luksOpen /dev/sda1 sda1

    Now you can access your device in address /dev/mapper/sda1. You can e.g. format it with mkfs.ext2 and mount it.

    Encrypt with truecrypt

    Good encryption algorithms:
    Hash algorithm: Whirlpool
    Encryption algorithm: AES

    Create a ext2 partition on the disk:
    truecrypt -v -c /dev/sda1
    truecrypt -N 1 /dev/sda1
    mkfs.ext2 /dev/mapper/truecrypt1
    mkfs.ext2 mkfs.ext2 -m0 -T largefile4 /dev/mapper/truecrypt1 # for large files, inode size 4MB instead of 8kB
    tune2fs -l /dev/mapper/truecrypt1 # Check what was done, e.g. inode size on 128B

    To mount into directory mnt
    truecrypt /dev/sda1 mnt
    To unmount directory mnt
    truecrypt -d sda1

    Change keyboard variant

    Change X-keyboard layout
    xkeycaps
    Change X settings on the fly
    setxkbmap -layout fi -variant nodeadkeys

    Download files from link page

    wget -O - http://www.linkpage.com/ | wget -i -

    Encode CD to ogg/mp3

    Install mp3c package and rip+encode with the menu interface. Could not be easier!

    Webcam Logitech for Notebooks Pro (ID 046d:08cb), 2006/2007 model

    Kernel module:
    uvcvideo

    Programs:
    lucview
    ekiga

    Webcam Logitech Quickam Connect (ID 046d:08d9)

    Kernel module:
    gspca

    Programs:
    gqcam -v /dev/video1
    xawtv -geometry 640x480
    ekiga

    Subversion on localhost or over ssh

    Create the subversion repository to localhost:
    svnadmin create /var/svn/my_project

    On localhost start the subversion daemon:
    svnserve -d

    Checkout the project:
    svn co svn://localhost/var/svn/my_project

    In order to be able to add and commit stuff, you have to edit the /var/svn/my_project/conf/svnserve.conf and maybe add "anon-access = write" or create password database.

    To use the project in remote computer, run:
    svn co svn+ssh://server_address/var/svn/my_project
    To connect to a server with different port than 22, e.g. this in .ssh/config helps:
    Host lap
            Hostname        asrobo.hut.fi
            Port            49491
            HostKeyAlias    lap
            CheckHostIP no
    

    Update sources.list packages

    Deciding which mirror is the best to include in the sources.list file:
    netselect, netselect-apt
    Debian worldwide mirror sites:
    http://www.debian.org/mirror/mirrors_full
    Generate fastest sources.list selection for sid:
    netselect-apt sid

    Howto find out which package a given file belongs to

    dpkg -S stdio.h
    and/or
    apt-file search filename
    To see all the files that package contains:
    apt-file list packagename

    List installed packages

    COLUMNS=132 dpkg -l

    Install packages on demand

    auto-apt run ./configure

    Compile deb package sources

    Get package:
    apt-get source packagename
    Compile package:
    apt-get -b source packagename
    Install then package:
    dpkg -i file.deb

    Reference tutorial: [1].

    Find out what traffic is hammering your computer

    See ports and bytes with
    iptraf
    Iptraf e.g. in the open WLAN network shows all the traffic so it might be necessary to add filters e.g. to show only traffic to/from your computer. Watch the detailed traffic with
    wireshark.

    Is your DNS lookup not working

    It is configured in:
    /etc/resolv.conf
    You might need to fix that for chroot:ed versions especially.

    Firefox to work in chroot

    First install some sound packages and flash:
    apt-get install alsa-base alsa-oss alsa-utils flashplugin-nonfree
    Then make sure that your /etc/iceweasel/iceweaselrc file has either line ICEWEASEL_DSP="auto" or ICEWEASEL_DSP="aoss". Then it should work.

    Configure firefox options

    Write about:config to the address bar and be happy.

    Firefox save as... not working

    Try to delete this file from your local firefox settings.
    downloads.rdf

    Lossless jpeg manipulation

    apt-get install libjpeg-progs
    For example rotation:
    jpegtran -rot 90 -trim foo.jpg > foo90.jpg

    Compare directories

    To see what files differ in the given directories, command:
    diff -r --brief dir1 dir2

    Take screenshot of the desktop

    After installing ImageMagick:
    import screenshot.jpg

    Check last logins to the system

    As a root:
    last

    Controlling X-server connection rights

    xhost - server access control program for X
    Grant rights to all hosts:
    xhost +

    Howto configure network to work manually

    You need to know IP, MASK, GATEWAY, DNS, HOSTNAME and DOMAIN:
    ifconfig eth0 IP netmask MASK up
    route add -net default gw GATEWAY netmask 0.0.0.0 eth0
    hostname HOSTNAME
    echo ``domain DOMAIN'' >/etc/resolv.conf
    echo "nameserver DNS" >>/etc/resolv.conf
    

    Tools to check ethernet speed

    mii-tool, ethtool, iperf
    :~# mii-tool -v eth0
    eth0: negotiated 100baseTx-FD flow-control, link ok
      product info: vendor 00:07:32, model 17 rev 3
      basic mode:   autonegotiation enabled
      basic status: autonegotiation complete, link ok
      capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
      advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
      link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
    
    :~# ethtool eth0
    Settings for eth0:
            Supported ports: [ TP ]
            Supported link modes:   10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Full 
            Supports auto-negotiation: Yes
            Advertised link modes:  10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Full 
            Advertised auto-negotiation: Yes
            Speed: 100Mb/s
            Duplex: Full
            Port: Twisted Pair
            PHYAD: 0
            Transceiver: internal
            Auto-negotiation: on
            Supports Wake-on: pumbg
            Wake-on: g
            Current message level: 0x00000033 (51)
            Link detected: yes
    
    ipref measures the traffic between two comptures. Other computer is server and the other computer is client.

    To find out what libraries program needs

    Check by running:
    ldd programname
    To add a new dynamic library:
    ldconfig -n /path/of/new/lib
    For more info, man ld.so

    Which user I am and which groups do I belong

    Use this command:
    id

    Creating a CD

    AUDIO:
    To put on an audio CD all the *.wav files which are in the current directory:
    cdrecord dev=x,y,z -pad speed=0 -audio *.wav

    DATA:
    mkisofs -o cd.iso -J -R /tmp/mycd
    cdrecord -scanbus
    cdrecord dev=x,y,z -multi speed=0 -data cd.iso
    

    CD to wav

    Whole CD:
    cdparanoia -B
    Just one track:
    cdparanoia -w track_number file.wav

    wav to mp3 or ogg

    lame file.wav file.mp3
    oggenc file.wav -o file.ogg

    Split a file to several floppies

    Split:
    split -b1m file
    Reassemble
    cat x* >file

    Converting text files from DOS, Windows, Mac...

    Adopted from: http://www.pallier.org/ressources/linux_howtos/linux_howto.html
    Texts files under unix, mac, dos and windows use differents codes for end-of-lines and accentuated characters. Linux typically uses the Latin-1 character encoding. The ``recode'' program converts from one format to the other (info recode).
     To convert file.txt coming
    from a Macintosh: recode mac..latin1 file.txt
    
    To convert from DOS codepage 850 to unix latin1:
    recode 850..latin1 file.txt
    
    To just remove ^ M:
    recode l1/crlf..l1 file.txt
    
    To convert from Windows codepage 1250 to unix latin 1 (iso-8859-1): 
    recode ms-ee..l1 file.txt
    

    Printing

    To put the 'file.ps' into the printing queue of the printer known as 'printername':
    lpr -P printername file.ps

    The printers can be attached to the local system via a parallel, serial, or USB port, or available over the network. To get a list of available printers:
    lpstat -p -d

    To check the status of all printers:

    lpstat -a

    To remove a printing job:
    lprm job-id

    Vector graphics

    Maybe use 'xfig' to construct complex graphics. Yet the
    ergonomy of xfig is very different from what users expect nowadays.
    
    You can try 'sketch', 'dia' or OpenOffice draw. Or inkscape.
    
    For mathematical plots, bar plots..., I use the data analysis package
    R. For simple things, gnuplot may also help.
    

    Scan for badblocks

    This is destructive, so do it only for empty partitions:
    badblocks -v -w -p 3 -o /root/badblocks.list.txt /dev/sda1

    md5 check file for files in directory

    To create md5 check file, execute:
    find . -type f 2>/dev/null -exec md5sum {} \; >test.md5
    Check the directory:
    md5sum -c ../picsall.test.md5
    source: http://www.brunolinux.com/

    Need a secure kernel

    http://www.grsecurity.net/

    Ping HW address

    iputils-arping
    arping
    Usage example:
    ~# arping 00:0D:F0:14:B8:22
    ARPING 00:0D:F0:14:B8:22
    60 bytes from 192.168.1.1 (00:0d:f0:14:b8:22): icmp_seq=0 time=434.160 usec
    60 bytes from 192.168.1.1 (00:0d:f0:14:b8:22): icmp_seq=1 time=425.100 usec
    

    WLAN WEP in Linux

    iwconfig wlan0 essid myHost
    iwconfig wlan0 key s:passphrase
    iwconfig wlan0 up
    dhclient wlan0

    And all should work.

    WLAN WPA in linux

    WPA is more secure than WEP and should be prefered.
    Install wpasupplicant package:
    wpasupplicant - Client support for WPA and WPA2 (IEEE 802.11i)

    Manual configuration:
    1) Generate passphrase:
    wpa_passphrase myHost myPassPhrase
    network={
            ssid="myHost"
            #psk="myPassPhrase"
            psk=0d0800c35ab28ba9ed417863ade1ddc3ec38b9490ed633f99081cae4ac65c39e
    }
    
    Insert it into /etc/wpa_supplicant/wpa_supplicant.conf. 2) Run these commands:
    iwconfig wlan0 essid YebbeY
    ifup wlan0
    wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
    3) Connection is established so get a IP address:
    dhclient wlan0

    Automatic configuration:
    1) Add these to /etc/network/interfaces
    auto wlan0
    iface wlan0 inet dhcp
    up wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -Bw
    down killall wpa_supplic
    

    Which distribution are you running?

    lsb_release -a

    Logical volume management

    Check lvm.

    Check that all files are unique, no duplicates

    fdupes -r /dir

    Check WLAN signal strength or quality

    wavemon

    Update GRUB menu

    update-grub

    Open remote desktop connection

    rdesktop -f -a 24 -r disk:homedir=/home/ssheikki rondo.tkk.fi

    Remove default gw from eth0 to enable connection through wlan0

    List routes:
    route -n
    Delete route that you do not want to use:
    route del default gw 130.233.120.254

    Howto grip owner of other user screen

    Check what is your console:
    w
    Change full rights to the console:
    chmod 777 /dev/pts/32
    Change to the user with su:
    su username
    Get the screen:
    screen -DDRR

    Howto mount disk image with partitions

    Check the number of cylinders from the original disk (e.g. with cfdisk) and check the image properities:
    fdisk -l -u -C <#cylinders> dd.image

    Mount the image with right byte-offset:
    mount -o loop,offset= dd.image mnt

    Howto monitor ip-traffic

    iptraf

    Adding firewall (or anyother script) to start automatically

    ln -s ../init.d/connect_router rc2.d/S20connect_router
    Do the same for levels 2-5. S means Start so you might want to have also 0-1 and 6 run levels a script with K20connect_router (to Kill).

    This is of course wrong way to do it. How it should be done:
    update-rc.d connect_router defaults
    update-rc.d connect_router start 99 2 3 4 5 . stop 99 0 1 6 .
    To test the script, you can use:
    invoke-rc.d

    Playing with network interfaces

    apt-cache show netenv

    How to change default route? In the ifconfig there is defined what to do before and after interface is put down, e.g. postdown etc.

    Search files from packages

    How to findout in which package file belongs to:
    dpkg -S filename

    How to findout which files belong to a packet:
    dpkg -L packetname

    Usb2serial configuration

    apt-get install usrp
    To test:
    cat /dev/ttyUSB0

    aclocal: not found

    Install automake.
    autoconf -- to get autoheader,autoconf
    libtool -- to get libtool, libtoolize 
    

    Matlab is missing a function

    file exchange toolbox: fxsearch

    Howto find out what application is using your port

    Who is using port XXX:
    fuser -n tcp XXX
    List all ports being used:
    netstat -nlp

    IRC in ipv6 with irssi

    Set the ipv6 hostname that you have:
    /set hostname pikku.giraf.fi
    Connect to the server that supports ipv6:
    /server -6 irc.cc.tut.fi

    SMART IDE hard disk info

    aptitude install smartmontools
    Show device info (does not work for USB disks):
    smartctl -a /dev/sda

    Joomla transfer to new server

    1) Download latest stable version of joomla and install it
    2) Load the mysqldump of your old site to the new database.
    3) Copy files that you are missing from the old system (modules/mod_header_image*, images/*, templates/?*)

    Installing kernel from ubuntu/debian package

    Install kernel:
    apt-get source linux-image-2.6.20-16-386
    Install sources (needed e.g. to compile truecrypt):
    apt-get source linux-image-2.6.20-16-386

    hostname change

    Edit
    /etc/hostname
    and set
    hostname [new_hostname]

    Inventory computers

    Install these packages:
    aptitude install dmidecode libio-zlib-perl libxml-simple-perl libnet-ip-perl libnet-ssleay-perl libwww-perl
    Install:
    OCSNG_LINUX_AGENT_1.01_with_require.tar.gz
    http://www.ocsinventory-ng.org/

    Look strings inside binary file (e.g. jpg)

    strings kuva.jpg | less

    charset data for locale

    luit searches locales from:
    /usr/lib/X11/locale
    but they are actually located in:
    /usr/share/X11/locale

    xterm encoding

    xterm -en iso-8859-15

    change sender in pine

    Select SETUP and C (Config). Customize the line:
    customized-hdrs=From: email.address@somewhere.the

    Check web sites links validity

    linkchecker --no-warnings http://www.spacemaster.se/

    Using dump/restore

    First edit /etc/fstab to include "1" to the places that you want to backup. Otherwise keep/set to zero the column dump.

    Create a zero level dump first:
    dump 0uf dump_level0.dump /

    You can list the contents of the dump:
    rrestore -tf 2007_08_29_yebbey_l0.dump

    Modify SQL table

    Check current settings:
    describe events;

    Dump/restore one mesql database

    Dump:
    mysqldump [databasename] -p -u root | gzip -c > mysql_dump.gz
    Restore:
    gzip -cd mysql_dump.gz | mysql -u root -p

    Add a new user for mysql table

    Add without DROP/CREATE priviledges:
    grant INSERT,DELETE,UPDATE,SELECT on mydatabasename.* to myusername@localhost;
    Add also password:
    set password for myusername@localhost = password('mysecretpassword');

    Dump just data/structure

    Just structure:
    mysqldump -d --compact -u root -p yourdatabase > dump
    Just data:
    mysqldump -p -u root yourdatabase --no-create-info > dump
    Just data, one insert per row:
    mysqldump -p -u root yourdatabase --extended-insert=FALSE --no-create-info > dump

    Get more info about a file

    Display file or file system status:
    stat filename.end
    Determine file type:
    file filename.end

    php upload site

    Configure /etc/php5/apache2/php.ini:
    1. upload_max_filesize
    2. max_execution_time
    3. max_input_time
    4. post_max_size

    Pairing cellphone and laptop with bluetooth

    hcitool scan
    mknod /dev/rfcomm0 c 216 0
    rfcomm bind 0 1
    passkey-agent --default /etc/bluetooth/feed-bin.sh
    You can try the connection with e.g. konqueror, write:
    bluetooth:///

    Send a sms from a command line

    gnokii --sendsms +358504137550 < message.txt

    Document search engine

    Creates a google type of document search engine, includes pdf:s, docs and text files for example.
    SWISH

    Make password

    makepasswd

    Multipointer operating system

    Use mpx live cd and you will have operating system that supports e.g. two mouse pointers.
    http://wearables.unisa.edu.au/mpx/
    http://wearables.unisa.edu.au/mpx/?q=node/51
    Boots up usually directly and also programs which are not designed for multipointing work at least adequately.

    Load kernel module with specific parameters

    For example acer_acpi module with wireless=1 parameter.
    echo "options acer_acpi wireless=1" > /etc/modprobe.d/acer_acpi

    Automatic wireless wep network setup

    auto wlan0 iface wlan0 inet dhcp wireless-essid wireless-key s: open

    Easy to use firewall using iptables

    Uncomplicated FireWall:
    ufw enable
    ufw logging on
    sudo ufw allow 53/tcp
    sudo ufw allow ssh
    

    Continue partially send scp file

    rsync --partial file.tar.bz2 user@machine.com:

    vmware in ubuntu hardy heron howto

    Packages required:
    aptitude install build-essential linux-kernel-devel linux-headers-generic xinetd
    Run install (with normal settings):
    ./vmware-install.pl
    Copy few files to right places:
    cp /lib/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1
    cp /usr/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0
    Locate your virtual machine and edit the vmx file in this folder and add the following line:
    svga.maxWidth = "1280"
    svga.maxHeight = "800"
    
    You can also try if above does not work:
    sudo gedit ~/vmware/preferences
    - Now where it says:
    pref.autoFitFullScreen = "fitHostToGuest"
    change it to:
    pref.autoFitFullScreen = "fitGuestToHost"
    

    vmware USB enable

    Edit:
    /etc/init.d/mountdevsubfs.sh
    Uncomment lines 42-45 starting with #mkdir p....

    Remove duplicate lines

    Remove duplicate acronyms (-f == ignore case)
    sort -f acronyms_unsorted.tex | uniq > acronyms.tex
    Display duplicate acronyms:
    sort acronyms.tex | uniq -dc

    Install fglrx in ubuntu

    Install restricted modules:
    aptitude install linux-restricted-modules-`uname -r`
    sudo dpkg-reconfigure -phigh linux-restricted-modules-`uname -r`
    sudo insmod /lib/modules/`uname -r`/volatile/fglrx.ko
    

    Boot without password

    At grub-boot loader screen. Select Recovery mode the version of the kernel that you wish to boot and type e for edit. Select the line that starts with kernel and type e to edit the line.

    Go to the end of the line and type init=/bin/bash as a separate one word (press the spacebar and then type init=/bin/bash). Press enter key to exit edit mode.

    Play encrypted dvds

    locate install-css.sh
    sudo install-css.sh
    with vlc, choose disc and dvd and volaa.

    Save your sound mixer settings in reboot

    aptitude install alsa-utils
    alsactl store
    Automatic version:
    # load/unload the volume settings on startup/shutdown install snd-driver-name /sbin/modprobe \ --ignore-install snd-driver-name;/usr/sbin/alsactl restore remove snd-driver-name /usr/sbin/alsactl \ store;/sbin/modprobe --ignore-remove -r snd-driver-name

    for loop in bash

    for i in `seq 1 9`;do wget http://www.picsurl.com/file$i.jpg;done

    Check disk health status

    smartctl -H /dev/hda smartctl -l error /dev/hda,

    Capture video with sound

    Setup the mixer settings e.g. using gnome-alsamixer. Make sure that "Mix" and "Capture, Rec" are selected.
    recordmydesktop -x 100 -y 100 -width 300 -height 300 -o output.ogg
    End the recording by Ctrl+C.
    3D accelerated parts require that --full-shots parameter is used.
    recordmydesktop -x 150 -y 120 -width 700 -height 500 -fps 30 --full-shots -o output.ogg

    Make windows compatible avi

    Does not work as PDF embedded movie:
    mencoder input.avi -o out.avi -ovc lavc -lavcopts vcodec=msmpeg4v2 -oac copy

    Compare two md5sum files

    Return the lines that are mentioned in first file but not in second.
    sort a >aa; sort b >bb; diff aa bb | sed -n '/^ Don't care if file is located in different directory:
    sort a | sed -n 's/\/.*\///p' > aa;sort b | sed -n 's/\/.*\///p' > bb; diff aa bb | sed -n '/^ Also this works instead of 's/\/.*\///p':
    's#\.\?/.*/##'

    Compare just the md5sums:
    sort a | sed -n 's/ .*//p' > aa;sort b | sed -n 's/ .*//p' > bb; diff aa bb | sed -n '/^

    Match lines starting with k and print

    sed -n '/^k/p'

    Add space before string

    ls -1 | sed -n 's/^./ \0/p'

    Kill all processes accessing a mounted partition

    fuser -km /home/ssheikki/mnt

    Debugging functions in matlab/octave

    Add a breakpoint in function "test.m" in line 28:
    dbstop test 28
    Note! Returns the line where the breakpoint was actually set.
    Go to the next line in debug mode:
    dbnext

    Download all packages installed to your system

    dpkg --get-selections | sed -n 's/..install$//p' | perl -pi -e 's/^\s*(\S.*\S)[ \t]*$/$1 /' | perl -p -e 's/\n//' > packages
    Edit aptitude download in the start of the file of packages.
    sh packages

    Replace space with underline in filenames

    rename "s/ /_/g" *

    Add prefix in the front of the name

    rename 's/(.+)/prefix-$1/' *.jpg

    Remove prefix from the front of the name

    for f in prefix-*; do mv "$f" "${f#prefix-}"; done

    Run firefox, etc in 32bit mode

    dchroot -c ia32 -d firefox
    dchroot -c ia32 -d gmplayer

    Sort according to second column

    sort +1 -2 filename.txt

    Install text to speech system

    aptitude install festival
    echo "Speech to text. It works?" | festival --tts
    You might want to install some festvox-* packages:
    echo "Kuka mina olen?" | festival --tts --language spanish
    echo "Kuka mina olen?" | festival --tts --language finnish

    Get info about your soundcard

    Cards recognized:
    aplay -l
    asoundconf list
    Default clock etc. parameters:
    modinfo module_name, e.g. modinfo snd_atiixp

    Compile kernel with initrd

    make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
    See also:
    update-initramfs

    Manage your iPOD in linux

    gtkpod

    Run oss designed program using alsa

    aoss program_name

    arping in debian/ubuntu

    aptitude install arping
    arping 00:0a:e4:e1:04:b9

    Capture mms stream from net

    mplayer mms://example.con/example12a.wmv -dumpstream -dumpfile example12a.wmv

    Remove pages from pdf files

    aptitude install pdftk
    Remove pages 1,2 and 10-14:
    pdftk input.pdf cat 3-9 15-end output output.pdf

    Combine pages from several pdfs into one

    pdftk A=input1.pdf B=input2.pdf cat B1-2 A3-end output combined.pdf

    Compare contents of two directories

    To see differencies in the contents of two directories:
    diff -rq dirA dirB
    Note, the comparison is recursive, so also contents of subdirectories are compared.

    Howto install display drivers

    Get envy.deb
    Install it... and run "envy -t".

    Config alsa

    You might get error like this:
    alsamixer: function snd_ctl_open failed for default: No such device
    alsaconf

    Compile programs faster

    http://ccache.samba.org/

    Display planet as background

    xplanet -latitude 40

    Install Nvidia/ati drivers

    aptitude install envyng-core
    envyng -t

    Trace what system calls a program does

    strace -eopen alsamixer

    Update PCI ID list

    update-pciids

    Missing initram causes kernel panic

    Notice something like VFS mount failed
    update-initramfs -u -k 2.6.27.1

    Change default audio card

    asoundconf-gtk

    Show progress of suspended dd

    kill -SIGUSR1 %1

    Protect yourserver from attacks

    Software:
    - aide (files) - tiger (services) - rootkit (rootkits)

    Loading irssi scripts

    /script load scriptassist
    /scriptassist install morse
    etc.

    Install additional packages to debian-stable - backports

    Add this line to /etc/apt/sources.list:
    deb http://www.backports.org/debian etch-backports main contrib non-free

    John the Ripper

    Check that passwords are strong:
    unshadow /etc/passwd /etc/shadow > johnfile
    john johnfile

    Password strength check in login

    aptitude install libpam-cracklib
    Add to the services you want in /etc/pam.d/(e.g. common-password, ssh and login) this:
    # Be sure to install libpam-cracklib first or you will not be able to log in
    password required         pam_cracklib.so retry=3 minlen=10 difok=3
    password required         pam_unix.so use_authtok nullok md5 remember=3
    

    Convert dos/windows files Unix format

    Basically change the carriage return:
    aptitude install tofrodos
    dos2unix/fromdos and unix2dos/todos commands.
    dos2unix makefile.sh

    Prevent hacker to bombing your computer

    aptitude install fail2ban
    OR
    aptitude install denyhosts
    "Monitors log files (e.g. /var/log/auth.log, /var/log/apache/access.log) and temporarily or persistently bans failure-prone addresses."
    In jail.conf, change:
    # Default action to take: ban & send an e-mail with whois report 
    # and relevant log lines to the destemail.
    action = iptables[name=%(__name__)s, port=%(port)s]
             mail-whois-lines[name=%(__name__)s, dest=%(destemail)s, logpath=%(logpath)s]
    
    and
    [ssh]
    enabled = true
    port    = ssh
    filter  = sshd
    logpath  = /var/log/auth.log
    maxretry = 12
    bantime = 3600
    findtime = 600
    ignoreip = 130.233.120.0/24
    

    You wanna track bugs?

    Install mantis:
    http://www.mantisbt.org/

    Want to send email outside in Linux

    Configure global internet delivery:
    dpkg-reconfigure exim4-config
    Test e.g. with:
    mail -v -s Test name@youremail.com

    Make a package from source code that you can install/deinstall

    aptitude install checkinstall
    checkinstall make install

    Print two(or more) pages per sheet pdf

    psnup -2 koe.ps > output.ps

    Convert audio files (e.g. wav) and adding effects with sox

    aptitude install libsox-fmt-all
    Play file with effect:
    play input.wav chorus 0.5 0.9 50 0.4 0.25 2 -t 60 0.32 0.4 2.3 -t 40 0.3 0.3 1.3 -s Convert file:
    sox input.wav output.wav chorus 0.5 0.9 50 0.4 0.25 2 -t 60 0.32 0.4 2.3 -t 40 0.3 0.3 1.3 -s

    Building and testing software projects automatically

    Hudson, versionin system and cron compatible java based open-source software:
    https://hudson.dev.java.net/

    Creating test cases and plans

    Test Case Management tool:
    http://testlink.org/