lundi 27 octobre 2008

Find usage

Dans répertoire courant,
Lister les fichiers modifiés il y a MOINS de 20 jours :
$ find . -type f -mtime -20 -exec ls {} \;
Lister les fichiers modifiés il y a PLUS de 20 jours :
$ find . -type f -mtime +20 -exec ls {} \;
Effacer les fichiers modifiés il y a PLUS de 20 jours :
$ find . -type f -mtime +20 -exec rm -rf {} \;
Déplacer les fichiers modifiés il y a PLUS de 20 jours dans /home/tmp :
$ find . -type f -mtime +20 -exec mv {} /home/tmp/. \;
Plus généralement avec une commande :
$ find . -type f -mtime +20 -exec my_command {} /home/tmp/. \;
Trouver les fichiers de plus de 100M :
$ find . -type f -size +100M -exec ls {} \;
Trouver les fichiers avec une permission de 644 :
$ find . -perm 644
Trouver les fichiers dans le répertoire courant avec un filtre par fichier xargs :
$ find . -type f | xargs grep "toto@titi.com"
Trouver des fichiers et rediriger dans un TAR :
$ find . -type f -print0 | tar -czvf backup.tar.gz --null -T -
Exclure des répertoires courants :
$ find . -type f -print0 -not -path "." -not -path ".." | xargs -0 ...votre_commande...
Copier les fichiers (ex: csv) en préservant la structure des répertoires :
$ find . -name '*.csv' -exec cp --parents \{\} /target \;

vendredi 17 octobre 2008

Figer un paquet (debian-like)

Demander à figer un paquet :
# echo "nom_du_paquet hold" | dpkg --set-selections
Marquer un paquet pour installation :
# echo "nom_du_paquet install" | dpkg --set-selections
Voir le statut des paquets :
# dpkg --get-selections

lundi 6 octobre 2008

Vnc Server on display :0 (debian way)

1. Install the "vnc4server" package (universe). This will provide
"/usr/lib/xorg/modules/extensions/libvnc.so" (The vnc.so module for VNC
4.1.2 was changed from vnc.so to libvnc.so.)
2. Add "vnc" to the Module section in /etc/X11/xorg.conf
Section "Module"
...
Load "vnc"
EndSection
3.a.If your VNC server is running in a secure environment, you can
disable authentication with the following configuration:
Section "Screen"
...
Option "SecurityTypes" "None"
EndSection
3.b. If your VNC server is NOT running in a secure environment, you will
need to set a VNC password using the vncpasswd program:
# vncpasswd
Password:
Verify:
Then tell the VNC module where the password is stored in xorg.conf:
Section "Screen"
...
Option "SecurityTypes" "VncAuth"
Option "UserPasswdVerifier" "VncAuth"
Option "PasswordFile" "/root/.vnc/passwd"
EndSection
4. Logout and restart X (Ctrl-Alt Backspace)