Rappels !

tar czf nom_archive repertoire
tar xvzf nom_archive

psnup -4 -r src.ps dst4.ps

dd if=boot.fs of=/dev/fd0a bs=36b

Tuer un processus par son nom sous BSD :
kill -9 $(ps -aux |grep username | awk '{ print $2 }' )

Supprimer les ^M dans un fichier avec vi, vim, gvim :
:%s/[Ctrl-v][entrée]//g

Supprimer les ^M avec strings :
strings fich-src.txt > fich-dst.txt

Voir les fichiers cachés :
ls -a | grep "^\."

Find and replace recursively through an entire directory tree using the following command:
grep -rlZ pattern /some/dir | xargs -r0 perl -pi -e 's/pattern/replacement/g'

Renommer plusieurs fichiers à la fois :
foreach f in ( *.abc )
   mv $f `basename $f .abc`.def
end

Mount a BSD (version > 5.0) file system on Linux :
mount -r -t ufs -o ufstype=ufs2,nodev,nosuid /dev/hda1 mnt

Create a patch
diff -NruF^f old new

Supprimer les fichiers core :
find ./ -name core -exec file {} \; -exec rm -i {} \;

Change permissions only for directories :
find . -type d -exec chmod a+x {} \;

To quickly find out which are the large files in there we could use:
find ./ -xdev -size +1024 -ls | sort -r +b

If you have a multitude of files to move (and keeping the same ownership, permissions, and directory structure) from one directory or filesystem to another, here's a one liner:
find /old_directory -depth | cpio -pdmv /new_directory

To removal only the files (not subdirectories) in the current directory, use the following command
rm `ls -l | grep -v '^d' | awk '{ print $9 }'`

Pour sauvegarder d'une machine à une autre
tar cvzf - / | ssh machine 'cd /repertoire/sauvegarde && tar xzpf -'
ou encore avec rsync :
rsync -azv --delete --rsh="ssh -l root" /home/* server:/sauvegarde

Securely backup a partition across a network using dd, gzip, ssh
The partition to be backed up must be unmounted
dd if=/dev/partition_to_be_backed_up | gzip | ssh user_name@backup.server dd of=name_of_backup_file.gz
To restore a backed-up partition across a network
dd if=name_of_backup_file.gz | gzip -d | ssh user_name@target.server dd of=/dev/target_partition

To do a recursive copy of a directory to another location, preserving the PERMISSIONS and OWNERSHIP of the files :
tar cvf - . | ( cd \!* ; tar xvf - )

Sendmail et file d'attente
mailq : pour voir la file d'attente
sendmail -q : pour la vider

Use Ghostscript to combine PDF files
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf

Listing files by size
ls -l | grep ^- | sort -nr -k 5 | more

BASH HOTKEYS
ctrl-l -- clear screen.
ctrl-r -- does a search in the previously given commands so that you don't have to repeat long command.
ctrl-u -- clears the typing before the hotkey.
ctrl-a -- takes you to the begining of the command you are currently typing.
ctrl-e -- takes you to the end of the command you are currently typing in.
esc-b -- takes you back by one word while typing a command. i
ctrl-c -- kills the current command or process.
ctrl-d -- kills the shell.
ctrl-h -- deletes one letter at a time from the command you are typing in.
ctrl-z -- puts the currently running process in background, the process can be brought back to run state by using fg command.
esc-p -- like ctrl-r lets you search through the previously given commands.
esc-. -- gives the last command you typed.

Moyenne progressive en AWK
#!/bin/sh
awk 'BEGIN{moy=0;som=0;nb=0}{nb += 1;som += $2; moy = som/nb; print $1" "$2" "moy}' $1 > resultat

Commenter des lignes sous vi
:.,+N-1 s/^/#/g
ou encore après avoir selectionner des lignes avec gvim
:'<,'>s/^/%/