Debianuel-Notes on a linux experience - Emmanuel Branlard

Transcription

Debianuel-Notes on a linux experience - Emmanuel Branlard
Debianuel
Notes on a linux experience
Emmanuel Branlard
June 2011
Contents
I
Notes on linux
7
1 Unix commands
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
1.10
1.11
Commands . . . . . . . . . . . . . . . . . . . . . . . . . . .
Vi Vim or gVim . . . . . . . . . . . . . . . . . . . . . . . .
Vim-latex . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Grep - List of my REGEXP . . . . . . . . . . . . . . . . . .
FORLOOPS/ FIND / XARGS and SPACECHARACTERS
TEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TEST - COMPOUND . . . . . . . . . . . . . . . . . . . . .
STANDARD IN, STANDARD OUT . . . . . . . . . . . . .
Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
AWK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DU and DF . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Equalize MP3 using mp3 gain . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xls2csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PDF password - password crack - pdfcrack - bypass - print by keeping CR . . .
Google Earth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
R - Bypass user le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Iceweasel Soud problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Custom letypes in geany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Indexation - Search in pdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCR Text recognition and searchable PDF . . . . . . . . . . . . . . . . . . . .
Antivirus for linux- ClamAV - freshclam . . . . . . . . . . . . . . . . . . . . . .
Install Microsoft Oce 2007 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mount .bin/.cue - convert them to .iso . . . . . . . . . . . . . . . . . . . . . . .
pdf2png - pdftopng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Fuseiso - Monter iso facilement- thunar shortcut . . . . . . . . . . . . . . . . . .
Meld : File/Folder comparison- thunar shortcut . . . . . . . . . . . . . . . . . .
Catsh : Find les- thunar shortcut . . . . . . . . . . . . . . . . . . . . . . . .
Java - iceweasel debian - Network problem . . . . . . . . . . . . . . . . . . . . .
Matlab : Ajouter un repertoire dans la variable PATH . . . . . . . . . . . . . .
Snapshot - Capture d'ecran . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FOR LOOPS/ FIND / XARGS and SPACE CHARACTERS -> Find in PDF .
Iceweasel / Firefox et java plugin . . . . . . . . . . . . . . . . . . . . . . . . . .
VISIO 2003 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Firefox / iceweasel slow, tweak it . . . . . . . . . . . . . . . . . . . . . . . . . .
PDF Croping - suppression d'espace de marges . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2 APPPLICATIONS
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
2.10
2.11
2.12
2.13
2.14
2.15
2.16
2.17
2.18
2.19
2.20
2.21
2.22
2.23
2.24
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8
8
8
10
11
12
12
12
12
12
13
14
15
15
15
15
15
16
16
18
18
18
22
22
23
23
24
24
24
24
25
25
25
26
26
26
27
CONTENTS
2.25
2.26
2.27
2.28
2.29
2.30
2.31
2.32
2.33
2.34
2.35
2.36
2.37
2.38
2.39
2.40
2.41
2.42
2.43
2.44
2.45
2.46
2.47
Renommage massif unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Faire un dictionaire - Compter le nombre de keywords d'une page web . . . . . . .
Aspirer un site avec wget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Modication pdf - Avec le paquet pdftk . . . . . . . . . . . . . . . . . . . . . . . .
Manipulation d'images en masse : image magick . . . . . . . . . . . . . . . . . . .
Evince cannot open any pdf documents anymore . . . . . . . . . . . . . . . . . . .
Audio format conversion : ogg, au, mp3, wav, snd,ai ... . . . . . . . . . . . . . . .
dos2unix : package tofrodos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Vim en color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Listen ou Exaile ou Quod libet ou banshee ou xrmms pour remplacer Amarok . . .
WICD pour remplacer Gnome Netwok Manager . . . . . . . . . . . . . . . . . . . .
Installer un nouveau pager : most . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Gparted equivalent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Congure skype sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logiciels equivalent linux / windows . . . . . . . . . . . . . . . . . . . . . . . . . .
Personaliser xterm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hacker xterm - source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Congurer Geany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Telecharger les jaquettes des pistes de la liste de lecture d'amarok dans leur dossier
Latex et packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Latex et windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RAW photo images nikon .NEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
split view, gestionnaire de fenetre a gauche a droite, avec compiz . . . . . . . . . .
3 Xorg - clavier souris touchpad
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
Bien lire le log Xorg . . . . . . . . . . . . . . . . . . . . . . .
Xorg ou/et HAL . . . . . . . . . . . . . . . . . . . . . . . . .
Numlockx conicting . . . . . . . . . . . . . . . . . . . . . . .
X11 working x11 without hald/dbus . . . . . . . . . . . . . .
Ctrl alt Backspace to restart X server . . . . . . . . . . . . .
QWERTY et accents . . . . . . . . . . . . . . . . . . . . . . .
Get keyboard keycodes . . . . . . . . . . . . . . . . . . . . . .
Cong souris logitech lx8 left handed . . . . . . . . . . . . . .
Mise en veille et hibernation qui chie, avec cartes Nvidia . . .
Monitor going to sleep after 10 minutes - Power management
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Cleaning up Xfce menu - applications wine . . . . . . . . . . . . . . . . . . . .
Understanding Mimetypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Command for Toggle Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . .
Notications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Thunar - User customed actions . . . . . . . . . . . . . . . . . . . . . . . . . .
Astuce XFCE : transparent background for panel . . . . . . . . . . . . . . . .
Astuce XFCE : Handle acpi event for power button, show Xfce logout options
Xubuntu et programme au demarrage de session . . . . . . . . . . . . . . . .
Se passer de keytouch - utiliser xfce . . . . . . . . . . . . . . . . . . . . . . . .
xfce shortcuts are stored in . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Equivalent win split revolution avec wmctrl - raccourcis clavier xfce . . . . . .
Applications pour environnement xfce sans dependances gnome ou kde . . . .
Astuce XFCE : How to include all application while switching windows . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
E. Branlard
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4 XFCE - xfce4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
28
28
29
30
30
31
31
31
31
32
32
32
32
32
33
33
34
34
34
35
35
35
35
36
36
36
37
37
37
38
38
38
39
39
41
41
42
42
42
42
42
43
44
44
44
44
47
47
2
CONTENTS
5 SYSTEM
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13
5.14
5.15
5.16
5.17
5.18
5.19
5.20
5.21
5.22
5.23
5.24
5.25
5.26
5.27
5.28
5.29
5.30
5.31
5.32
5.33
5.34
5.35
5.36
5.37
5.38
5.39
5.40
5.41
Password protect single user mode . . . . . . . . . . . . . . . . .
Turn o php expose . . . . . . . . . . . . . . . . . . . . . . . . .
Heure machine exacted - NTP daemon . . . . . . . . . . . . . . .
Increase password strencgth with PAM cracklib or passwdqc . . .
Init Boot sequence messages in color - [ok] . . . . . . . . . . . . .
Default User directories . . . . . . . . . . . . . . . . . . . . . . .
Nettoyage des log automatique . . . . . . . . . . . . . . . . . . .
Une systeme plus reactif . . . . . . . . . . . . . . . . . . . . . . .
Swappiness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Optimisation - Date de modif . . . . . . . . . . . . . . . . . . . .
Readahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Informations systeme . . . . . . . . . . . . . . . . . . . . . . . . .
Addressse MAC . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Journaux systemes - bootlog . . . . . . . . . . . . . . . . . . . . .
Bootchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Add a path to locate . . . . . . . . . . . . . . . . . . . . . . . . .
ANSI Escape sequences - escape codes for bashrc and login . . .
Geeking around with the login prompt - Customization . . . . . .
A quiet boot with color-coded error messages in Debian . . . . .
Utiliser aptitude . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bien maitriser ses paquets - application a nvidia . . . . . . . . . .
Command to reload fstab . . . . . . . . . . . . . . . . . . . . . .
Changer le nom de votre machine, hostname . . . . . . . . . . . .
Rendre clef USB amorcable - partitions, formatage , bootable . .
Migrer de Ext3 a Ext4 . . . . . . . . . . . . . . . . . . . . . . . .
Comment savoir si on est 32 ou 64bits . . . . . . . . . . . . . . .
Exécuter plusieurs versions de Debian avec chroot . . . . . . . . .
Probleme d'heure . . . . . . . . . . . . . . . . . . . . . . . . . . .
Script automatique au demarrage . . . . . . . . . . . . . . . . . .
Bip systeme - tab - arret systeme . . . . . . . . . . . . . . . . . .
Congurer son reseau a la main . . . . . . . . . . . . . . . . . . .
Conversion UTF8 ISO-8859-1 . . . . . . . . . . . . . . . . . . . .
Initramfs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Restaurer une installation Debian . . . . . . . . . . . . . . . . . .
Accents, caracteres accentues, font terminal amarok . . . . . . . .
Congurer sudoers . . . . . . . . . . . . . . . . . . . . . . . . . .
Eteindre / redemarrer : droits utilisateur . . . . . . . . . . . . .
Son muet au demarrage . . . . . . . . . . . . . . . . . . . . . . .
Demarrage - gestionnaire de connexion - autologin . . . . . . . .
Demarrage - gestionnaire de connexion - auto-startx - autostartx
Autologin, fenetre de connexion sans gdm . . . . . . . . . . . . .
6 FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
6.1
6.2
6.3
6.4
6.5
6.6
6.7
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Les droits d'endossement SetUID et SetGID . . . . . . . . . . . . . . . . . . . . . . . .
Begin:waiting for resume on startup, resume process . . . . . . . . . . . . . . . . . . .
Forcer le montage en ecriture d'une partition ntfs apres un mauvais demontage de windows
Disque externe en lecture seule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Utilisateurs et groupes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Droits partage dossier chiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
org.freedesktop.hal.storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E. Branlard
49
49
49
49
49
49
50
50
51
51
51
52
53
53
53
53
53
53
54
54
55
55
55
56
56
56
58
58
58
59
59
59
60
60
60
61
61
61
61
61
62
62
64
64
66
66
66
67
67
70
3
CONTENTS
7 Grub, dual-boot, MBR
7.1 Grub 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 Installer grub dans le MBR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3 Installer un dual boot avec Vista, sans utiliser le MBR . . . . . . . . . . . . . . . . . .
8 WIFI
8.1
8.2
8.3
8.4
8.5
8.6
Congurer ma carte wi bcm4310, broadcom . . . . . . . . . . .
Fluxbox et wi . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Cracker wi WAP . . . . . . . . . . . . . . . . . . . . . . . . . .
Cracker wi WEP . . . . . . . . . . . . . . . . . . . . . . . . . .
Monitor mode for wi usb key : TL-WN321G chipset Ralink rt73
WIFI, et GESTIONNAIRE DE TROUSSEAU . . . . . . . . . .
9 SERVERS - PHP SQL APACHE SAMBA FTP SSH
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
9.10
9.11
9.12
9.13
9.14
9.15
9.16
9.17
9.18
Free shell servers . . . . . . . . . . . . . . . . . . . . .
Debian Serveur . . . . . . . . . . . . . . . . . . . . . .
Video surveillance - Zone minder . . . . . . . . . . . .
Telnet . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creer une base de donnees sql pour amarok . . . . . .
PHP mysql et apache sous ubuntu . . . . . . . . . . .
Apache - probleme de liens symbolic . . . . . . . . . .
Aide server apache - les bases . . . . . . . . . . . . . .
Aide server apache - l'autoindex et le probleme de php
Aide server apache - protection par mot de passe . . .
iptables . . . . . . . . . . . . . . . . . . . . . . . . . .
Server FTP . . . . . . . . . . . . . . . . . . . . . . . .
DynDNS . . . . . . . . . . . . . . . . . . . . . . . . . .
Voisimage reseau : pyNeighborhood . . . . . . . . . . .
Samba fusesmb pyNeighborhood . . . . . . . . . . . .
Communiquer avec les reseaux microsoft . . . . . . . .
Activation du voisinage réseau Windows dans Thunar
fusemb . . . . . . . . . . . . . . . . . . . . . . . . . . .
10 OTHERS
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10.1 Lire wmv windows media video ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 Java Gcj versus Sun - select defaults JVM . . . . . . . . . . . . . . . . . . . . . . . . .
10.3 Script shell -Command FIND - manipulation album cover le . . . . . . . . . . . . . .
10.4 Connexion ssh avec mot de passe automatique, methode bourrin mot de passe en clair
10.5 Nvidia drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.6 Timidity is not yet congured. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7 Midi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8 FFMPEG et MP3 lame sous debian . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9 Create from template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10Probleme gnome barre verticale - liste de fenetres . . . . . . . . . . . . . . . . . . . . .
10.11Mot de passe mise en veille . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.12NetworkManager - wi au reveil apres mise en veille ou hibernation . . . . . . . . . . .
10.13Histoire de memoire vive detectee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.14Virer le Usplash splash screen demarrage ubuntu . . . . . . . . . . . . . . . . . . . . .
10.15Optimisation - Preload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.16Optimisation - Démarrer les applications plus rapidement avec Prelink . . . . . . . . .
10.17Optimisation - Suppression services . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.18Optimisation - Cong reseau demarrage . . . . . . . . . . . . . . . . . . . . . . . . . .
10.19Optimisation - chargement polices . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E. Branlard
71
71
71
73
74
74
77
77
77
78
79
80
80
80
82
82
82
83
84
84
85
86
86
87
88
88
88
90
90
90
91
91
91
91
91
92
92
92
93
93
93
94
95
95
95
95
95
96
99
99
4
CONTENTS
10.20Open oce optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
10.21Optimisation - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
10.22Debian - conseil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
II
Supplementary notes
11 Conguration Files
11.1
11.2
11.3
11.4
11.5
11.6
11.7
11.8
11.9
/.bashrc . . . . . . .
/.bash_prole . . .
/.xinitrc . . . . . . .
/.xsession . . . . . .
/.Xdefaults . . . . .
/.vimrc . . . . . . .
/.conkyrc . . . . . .
/etc/apt/sources.list
/etc/apt/preferences
12 Shell scripts
.
.
.
.
.
.
.
.
.
101
.
.
.
.
.
.
.
.
.
12.1 pm-inhibit.py . . . . . .
12.2 pdfAutoRename . . . .
12.3 alarmaniac . . . . . . . .
12.4 pdfocr . . . . . . . . . .
12.5 backupSyst . . . . . . .
12.6 shrinkFig2 . . . . . . . .
12.7 topdf . . . . . . . . . . .
12.8 xsetnumlock.c . . . . . .
12.9 ifort-setup . . . . . . . .
12.10convertEnc . . . . . . .
12.11xfce4ToggleDesktop . . .
12.12keywordsSetUp . . . . .
12.13pdfocr-tess . . . . . . . .
12.14GETAPTKEY . . . . .
12.15rhythmboxstart . . . . .
12.16rhythmboxstartlong . . .
12.17showTag . . . . . . . . .
12.184terms . . . . . . . . . .
12.19ECN-RenameByTitle.sh
12.20compilWebVersion . . .
12.21formatWebVersion . . .
12.22audioInfo . . . . . . . .
12.23unix2win . . . . . . . . .
12.24svg2png . . . . . . . . .
12.25toCover . . . . . . . . .
12.26texclean . . . . . . . . .
12.27DEFAULT . . . . . . . .
12.28shrinkFig . . . . . . . .
12.29tomp3 . . . . . . . . . .
12.30pdfBind . . . . . . . . .
12.31DoBootchart . . . . . .
12.32cnx-vjk.expect . . . . . .
12.33pdfAlternRotation . . .
12.34syncStorage . . . . . . .
E. Branlard
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
102
102
104
104
105
105
106
112
116
117
119
119
119
122
122
123
125
125
126
127
127
130
130
131
132
133
133
133
134
134
134
138
138
139
140
142
142
142
143
143
144
145
145
145
146
5
CONTENTS
12.35pdfFind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
13 Debian
148
14 Fluxbox
156
13.1 Install Debian from scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
13.2 Program list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
14.1 Install Debian with Fluxbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
14.2 Notes on Fluxbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
14.3 Tuning Fluxbox Appearence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
15 Languages and programs
15.1
15.2
15.3
15.4
Unix . . . . . .
Awk . . . . . .
Vim . . . . . .
Language C++
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
159
159
160
161
163
16 Makeles
166
17 Kernel compilation
174
16.1 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
16.2 Latex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
E. Branlard
6
Part I
Notes on linux
7
Chapter
1
Unix commands
1.1 Commands
* s o r t S o r t s l i n e s i n a s c e n d i n g , d e s c e n d i n g and unique o r d e r
* grep Searches for r e g u l a r e x p r e s s i o n s in s t r i n g s or f i l e s
* basename S t r i p s t h e path from a path s t r i n g t o l e a v e j u s t t h e
filename
* dirname Removes t h e f i l e from a path s t r i n g t o l e a v e j u s t t h e
*
*
*
*
*
*
*
*
*
*
*
pathname
c u t Chops up a t e x t s t r i n g by c h a r a c t e r s o r f i e l d s
wc Count t h e c h a r a c t e r s , words , o r l i n e s
[ ( test ) ] Predicate or c o n d i t i o n a l p r o c e s s o r
t r ' a ' ' b ' Transform c h a r a c t e r s
expr Simple a r i t h m e t i c p r o c e s s o r
bc B a s i c C a l c u l a t o r
eval E v a l u a t e v a r i a b l e s
echo Output s t r i n g s
date Create date s t r i n g s
nawk Manipulate t e x t s t r i n g s
head | t a i l A c c e s s l i n e s i n f i l e s
1.2 Vi Vim or gVim
%%
%Motions
:
h j k l 0 $
s i m u l t i l i g n e s : u t i l i s e r gk g j g $ g0
n : go t o l i n e
CTRL−B CTRL−F : page backwards page f o r w r d
CTRL−U CTRL−D : h a l f page up h a l f page down
w b : next / p r e v i o u s word
z . : p l a c e c u r s o r i n t h e middle
%%
%
Basic
<C−r> : r e d o ! ! !
u U : undo
%%
%
I n s e r t i o n s ( ne pas s e l i m i t e r a i ! ! ! )
a i o
A I O
8
CHAPTER 1. UNIX COMMANDS
%%
%
Deletion
x
dd
d i } : d e l e t e e v e r y t h i n g t i l l t h e next matching }
dt } : same but d o e s not d e l e t e t h e }
D o r d $ : d e l e t e t i l l end o f l i n e $
%%
%
Programming
% go t o next b r a c e
zo : open f o l d e d code
z f i n v e r b o s e mode t o f o l d
zR : u n f o l d a l l l e v e l s
< > : indent , use . to repeat
>>< << : i n d e n t
] p : l i k e p but a d j u s t s i n d e n t
%%
%
Block s t u f f ( don ' t know p r o p e r term )
v i } : s e l e c t e v e r y t h i n g between b r a c e s ( same a s v i { )
va } : idem but i n c l u d e s b r a c e s
y i } : copy c o n t e n t between b r a c e s
ci }
ct }
%%
%
Remplacement
r
cw : pour c h a n g e r un mot
%%
%
Copy p a s t e c u t
p : put a f t e r
P : put b e f o r e
yy p : copy p a s t e one l i n e
dd p : c u t p a s t e one l i n e
v y P : s e l e c t copy p a s t e
%%
%
Marks ( u s e f u l l when c o p y i n g smthg f a r away )
ma : mark ' a ' , not a command no :
` a : go t o a
%%
%
S e a r c h and r e p l a c e
: s e a r c h , moving with n and N
: s / aa / bb / g : a l l i n c u r r e n t l i n e
:% s / aa / bb / g : i n a l l document
: l 1 , l 2 s / aa / bb / g : a l l between l 1 and l 2
: set h l s e a r c h
: nohlsearch
/
%%
%
Buffers
A l l f i l e s open i n vim a r e l i s t e d a s b u f f e r s . They can be opened , i n tab o r
windows , i t d o e s n t matter . This means t h a t a t any time you can a c c e s s
any b u f f e r and put i t i n a tab o r a window
: ls : list
: bn
: b number : go t o b u f f e r number
E. Branlard
9
CHAPTER 1. UNIX COMMANDS
: bd : c l o s e s c u r r e n t b u f f e r
%%
%
. Vimrc f i l e
: s o % : source t h e f i l e you a r e e d i t i n g .
reloaded automatically
if
i t ' s . vimrc ,
then
config is
%%
%
Windows
: sp : opens i n a s p l i t window
<C−W> s : s p l i t s h o r i z o n t a l l y
<C−W> v : s p l i t s v e r t i c a l l y
<C−W> w : l o o p through windows
<C−W> j k h l : move between windows
<C−W> _ : maximize window
<C−W> c : c l o s e window
%%
%
Tabs
: tabnew : new tab
: t a b e : open a f i l e i n a new tab
: tabc
: tabn o r gT : next tab
: tabN o r g t : p r e v i o u s tab
"+y e t "+gp ou "+gP c o p i e e n t r e documents ? ? ? ?
%%
%
INSERT mode
CTRL+C CTRL+[ o r ESC t o e s c a p e
CTRL+N CTRL+P : Word/ v a r i a b l e /command c o m p l e t i o n ! ! !
CTRL+H : b a c k s p a c e
LOOK a t my vimrc f o r my I n s e r t s e t t i n g s
%%
%
Rec or di ng
qa r e c o r d a macro i n r e c o r d i n g a
q stops recording
@a : r e p e a t r e c o r d i n g
%%
%
Paragraph r e f o r m a t i n g
s e t t e x t w i d t h =80 0 t o c a n c e l
gqap : c u r r e n t paragraph
gggqG : a l l p a r a g r a p h s i n f i l e
J
: j o i n with l i n e below ; whole f i l e : u s e cmd p a s t e
rENTER : s p l i t . .
1.3 Vim-latex
<−−>:
p r e s s CTRL−J t o go t o
Latex i n i n s e r t mode
%e n v i r o n m e n t s
EIF : i n s e r t f i g u r e
EIT : i t e m i z e
then <A−I>
%%
%
for
items
% maths s t u f f s
`/ : frac
E. Branlard
10
CHAPTER 1. UNIX COMMANDS
` I : int
<A−L> a f t e r o f b e f o r e a p a r e n t h e s i s , c o m p l e t e s i t with \ l e f t
%%
%
%%
%
`{
`(
...
R e f e r e n c e s and c i t a t i o n s c o m p l e t i o n with <F9> ! ! !
LATEX VISUAL mode
p u t s \ l e f t { around s e l e c t i o n
%%
%
Bib f i l e s
BBB : new e n t r y
1.4 Grep - List of my REGEXP
Basics options :
−r : r e c u r s i v e i n f o l d e r s
−− c o l o r=auto : f o r b e t t e r d i s p l a y
−I : i g n o r e b i n a r y f i l e s
−E : w i l l i n t e r p r e t t h e p a t t e r n a s an extended r e g e x p
−F : w i l l i n t e r p r e t t h e p a t t e r n a s a f i x e d s t r i n g
− i : i g n o r e c a se
−n : l i n e number
− s : remove e r r o r m ess age s
−I n r s i
−s I r n i
g r e p − r I −− c o l o r=auto p a t t e r n . /*
Geany :
−nHIiF
%%
%
Regexp
Remember :
. : match one unique char , d o e s not depend on what i s b e f o r e
* : z e r o , one o r s e v e r a l times what i s b e f o r e
? : z e r o o r one time
+ : one time o r more
( ) , n} : n times
( ) {m, n} : between m and n
%Dates :
echo " 1 18 19 20 21 1665 1620 1865 1995 2010 2100 " | g r e p −E " ( 1 8 | 1 9 | 2 0 )
[0 − 9]{2} "
%E x t e n s i o n s 3−4 c h a r a c t e r s
echo " s d f . png" | g r e p −E " [ . ] [ a−zA−Z ] { 3 , 4 } $ "
% f i l e name u g l y
echo " s d f l _d s é f − k l k f . ds f s k f j s " | g r e p −E " ^ [ a−Z0 −9\_ − ] * [ . ] "
f i l e n a m e = $ { f %. * }
E. Branlard
11
CHAPTER 1. UNIX COMMANDS
1.5 FORLOOPS/ FIND / XARGS and SPACECHARACTERS
#!
/ b i n / bash
" Looking f o r " $ 1
echo
SAVEIFS=$ IFS
IFS=$ ( echo −en " \n\b" )
i i n ` f i n d −name " * . pdf " − p r i n t f '%h /%f \n '
for
2>
/ dev / n u l l
`
do
"−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
"$ i " ;
echo "−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
p d f t o t e x t $ i − | g r e p −− c o l o r=always
s t r i n g s "$ i " | g r e p $1
echo
echo
#
done ;
$1
IFS=$SAVEIFS
1.6 TEST
Look a t Compound !
%%
%
[ −z
S t r i n g i s empty
$ { var } ]
Conditionnals t e s t s are in bracket [ ]
See man t e s t f o r d e t a i l s , l i k e :
E x p r e s s i o n comparison : ! EX1 −a Ex2 , Ex1 −o Ex2
S t r i n g comp : S1 = S2 , S1 !=S2
I n t comp :
I 1 −ne I 2
IF
if
:
[] ||
WARNING
[]
!!
&&
[] ;
then
...;
elif
[] ;
then
you need s p a c e s around [ and =
...;
else
...;
fi
!!!!!!!!!!
1.7 TEST - COMPOUND
%%
%
S t r i n g matching
[ [ " abc d e f . d , x−−" == a [ abc ] * \ ?d * ] ] ;
echo $ ?
1.8 STANDARD IN, STANDARD OUT
| : PIPE
. / c o m p i l e_a s t r a 2>&1 | t e e l o g . loG
1.9 Shell
E. Branlard
12
CHAPTER 1. UNIX COMMANDS
e x t e n s i o n = $ { f #* . }
f i l e n a m e = $ { f %. * }
%%
%
l o c a t i o n for local s c r i p t s
% i f local p a r t i t i o n
(/usr/local/bin )
% o r i n . bash_ p r o f i l e
PATH=$PATH: /home/manu/ s c r i p t s /
1.10 AWK
i s a p a t t e r n s c a n n i n g and p r o c e s s i n g l a n g u a g e .
By d e f a u l t i t r e a d s s t a n d a r d i n p u t and w r i t e s s t a n d a r d output .
awk
Usage : awk − f p r o g f i l e [ −− ] f i l e
Usage : awk ' program ' f i l e
Usage : . / a w k f s c r i p t
−F ,
: f i e l d s e p a r a t o r comma ( , )
−F " ; "
: f i e l d s e p a r a t o r semicolumn ( ; )
−F " ; | , " : f i e l d s e p a r a t o r semicolumn o r comma ( ; )
#f i r s t 1000 l i n e s
awk 'NR<1000 { p r i n t } ' r a d i a l . i n i >r a d i
#l i g n e s p a i r e s
NR % 2 == 1 { p r i n t
$0
}
#a f f i c h e l e numero de l i g n e
{ p r i n t NR, $ 0 }
# First three f i e l d s
awk −F , 'NR>1 { p r i n t
$1 ,$2 ,$3;}
# Not matching a p a t t e r n
awk ' ! / D i s t r i b u t i o n / { p r i n t
$0
' tab . c s v > tab2
} ' d r i f t . in
# Cut a l i n e e v e r y 20 f i e l d s
awk −F , ' { f o r ( i =1; i<=NF; i=i +1){ i f ( ( i %20)==0
){
p r i n t f $ i " ; " } } p r i n t f " \n"
} ' p . c s v >r . c s v
printf
$i
" ; \ n"
} else {
# p r i n t sum o f f i r s t r e c o r d
awk ' { sum += $ 1 } ; END { p r i n t sum } ' f i l e
awk
−F= 'NR<10 { f o r ( i =1; i<=NF; i ++){ p r i n t f
#p r i n t f "&NEWRUN\n
E. Branlard
$i
"=" } ; p r i n t " " } ' d r i f t . i n
D i s t r i b u t i o n =' $ b u n c h d i r /$ 3 '\ n" | t e e
$2>/ dev / n u l l
13
CHAPTER 1. UNIX COMMANDS
#awk 'BEGIN{IGNORECASE=1; FS=" ,|="}; / d i s t r i b u t i o n / { f o r ( i =1; i <NF; i=i +2){
i f ( $ i ~/ d i s t r i b u t i o n / ) {} e l s e { p r i n t " " , $ i ,"=" , $ ( i +1)} }
} NR>1 &&
/ d i s t r i b u t i o n / { p r i n t } ' $ c a s e d i r /$ 2 > $ t e m p B u f f e r
#c a t $ t e m p B u f f e r | t e e −a $2>/ dev / n u l l
awk
#!
'BEGIN{IGNORECASE=1; FS=" ,|= " } ; / d i s t r i b u t i o n / { f o r ( i =1; i <NF; i=i +2){
( $ i ~/ d i s t r i b u t i o n / ) { s p l i t (ARGV[ 2 ] , a , "=" ) ; p r i n t a [ 1 ] = a [ 2 ; ] } e l s e {
p r i n t " " , $ i , "=" , $ ( i +1)} }
} NR>1 && ! / d i s t r i b u t i o n / { p r i n t } ' $
c a s e d i r /$ 2 D i s t r i b u t i o n =\' $ b u n c h d i r /$ 3\'> $ 2
!
if
/ b i n / awk
BEGIN {
IGNORECASE=1
FS=" ,|= "
s p l i t (ARGV[ 2 ] , a , "=" ) ;
b=t o l o w e r ( a [ 1 ] )
}
$0 ~
b { f o r ( i =1; i <NF; i=i +2){ i f ( $ i ~b ) { s p l i t (ARGV[ 2 ] , a , "=" ) ; p r i n t " " , a
[ 1 ] , "=" , a [ 2 ] ; } e l s e { gsub ( " " , " " , $ i ) ; p r i n t " " , $ i , "=" , $ ( i +1)} }
}
$0 !~ b { p r i n t }
1.11 DU and DF
%%
%DU
du −sh FOLDER/FILE : d i s k u t i l i s a t i o n , r e a d a b l e by human , s : i n c l u d e
subfolders
t h e above w i l l return t h e t o t a l
#l i s t i n g s p a c e used by t h e s u b f o l d e r s i n t h e c u r r e n t f o l d e r
a l i a s duf ='du −−max−depth=1 −h '
%%
%DF
d f −a l : d i s k s p a c e
a l i a s d f =' d f −hT | e g r e p − i " f i l e | ^ / " '
E. Branlard
14
Chapter
2
APPPLICATIONS
2.1 Equalize MP3 using mp3 gain
f i n d . − name ' * . mp3 ' −exec mp3gain − r −k {} \ ;
#But f i r s t , t o h c e c k l e v e l w i t h o u t d o i n g a n y t h i n g run :
f i n d . − name ' * . mp3 ' −exec mp3gain − s s {} \ ;
2.2 xls2csv
command
among o t h e r t o o l from package " c a t d o c "
2.3 PDF password - password crack - pdfcrack - bypass - print by
keeping CR
## E n c r y p t i n g i n f o
pdfinfo
## F i r s t t r y g h o s t s c r i p t ( i f read a c c e s s b u t no modif )
g s −q −dNOPAUSE −dBATCH −sDEVICE=p d f w r i t e − s O u t p u t F i l e=unencrypted . pdf −c
. s e t p d f w r i t e − f c r y p t e d . pdf
## For b r u t e f o r c e c r a c k i n g :
p d f c r a c k f i l e . pdf −o
p d f c r a c k f i l e . pdf −o −c ` c a t a s c i i l i s t . txt `
2.4 Google Earth
sudo a p t i t u d e i n s t a l l g o o g l e e a r t h −package
make− g o o g l e e a r t h −package
sudo dpkg − i g o o g l e e a r t h_4 . 2 . 2 0 5 . 5 7 3 0 + 0 . 5 . 2 − 1_i 3 8 6 . deb
15
CHAPTER 2. APPPLICATIONS
2.5 R - Bypass user le
R −−no− i n i t − f i l e
2.6 Iceweasel Soud problem
%%
%#
Introduction
The problem comes when s e v e r a l a p p l i c a t i o n s t r y t o a c c e s s t h e sound d e v i c e
directly .
I f a mixer i s used i n between t h e a p p l i c a t i o n and t h e hardware , then t h e r e
s h o u l d be no problem
P u l s e a u d i o d o e s t h i s mixing job , and thus , a l l o w p l a y i n g o f s e v e r a l
a p p l i c a t i o n s a t t h e same time .
P u l s e a u d i o , s t a r t s by d e f a u l t , i f c a l l e d p r o p e r l l y by t h e a p p l i c a t i o n .
So l e t ' s t r y with p u l s e a u d i o which i s now d e f a u l t i n d e b i a n and ubuntu .
S e v e r a l p e o p l e remove p u l s e a u d i o and don ' t have t r o u b l e . . . w e l l , l e t ' s
take the c h a l l e n g e .
# Firefox / Iceweasel /Flash player
v l c & rhythmbox t o g e t h e r , no problem , they c a l l p u l s e a u d i o .
The problem comes from i c e w e a s e l o r maybe j u s t t h e f l a s h p l u g i n which t r y
t o a c c e s s t h e sound d e v i c e d i r e c t l y .
I f p u l s e a u d i o i s c a l l e d f i r s t , then i c e w e a s e l d o e s not have a c c e s s t o t h e
c a r d / dev / snd /* .
I f i c e w e a s e l i s c a l l e d f i r s t and then p u l s e a u d i o , i t ' s p u l s e a u d i o t h a t can
' t a c c e s s the card .
To s e e who i s u s i n g what :
l s o f −w | e g r e p ' snd | dsp '
Use t h i s command e x t e n s i v e l y t o debug : i f you s e e t h a t f i r e f o x −b i n u s e s
dev / snd /* then , i t w i l l o b v i o u s l y not work . The o n l y one t h a t s h o u l d
use i t i s pulseaudio !
/
%%
%
The s o l u t i o n t h a t worked f o r me :
#( S t e p 0 : As I was q u i t e u n c e r t a i n o f my l a s t i n s t a l l o f f l a s h p l a y e r , I
d i d a c l e a n i n s t a l l , b u t t h i s i s not n e c e s s a r y
− Purged f l a s h p l u g i n − n o n f r e e *
− Removed ~/ . m o z i l l a / p l u g i n s / f l a s h p l u g i n * . s o ( not s u r e about t h e name
anymore )
− l o c a t e f l a s h p l u g i n * t o s e e i f e v e r u t h i n g was purged c o r r e c t l y
− i n s t a l l f l a s h p l u g i n − n o n f r e e and that ' s a l l
)
#S t e p 1 : i n s t a l l a l l t h e p u l s e a u d i o s t u f f :
sudo a p t i t u d e i n s t a l l p u l s e a u d i o l i b a o 4 l i b p u l s e −mainloop − g l i b 0
p u l s e a u d i o −module− j a c k p u l s e a u d i o −module−h a l p u l s e a u d i o −module−x11
g s t r e a m e r 0 .10 − p u l s e a u d i o p u l s e a u d i o − u t i l s l i b a s o u n d 2 − p l u g i n s l i b p u l s e −
browse0 p u l s e a u d i o −esound −compat l i b p u l s e 0
I f you want t o u s e b l u e t o o t h : p u l s e a u d i o −module− b l u e t o o t h
E. Branlard
16
CHAPTER 2. APPPLICATIONS
I f you want t o u s e some v i s u a l i n t e r f a c e s t u f f : pavumeter p a p r e f s
pavucontrol
! ! ! PAVUCONTROL i s r e a l l y good . For i n s t a n c e , f o r r e c o r d i n g a u d i o c a r d
f l u x . Launch r e c o r d i n g with a u d a c i t y . then i n p a v u c o n t r o l / r e c o r d i n g
change i n t e r n a l t o monitor i n t h e a u d a c i t y l i n e .
#S t e p 2 : T e l l ALSA a p p l i c a t i o n s t o use a " p u l s e " d e v i c e .
C r e a t e / Ed it f i l e ~/ . a s o u n d r c ( o r / e t c / asound . c o n f ) with t h e f o l l o w i n g
content :
pcm . p u l s e {
type p u l s e
}
c t l . pulse {
type p u l s e
}
pcm . ! d e f a u l t {
type p u l s e
}
ctl . ! default {
type p u l s e
}
This w i l l c r e a t e a pseudo − d e v i c e c a l l e d " p u l s e " t h a t w i l l be used by
d e f a u l t by ALSA a p p l i c a t i o n s
#S t e p 3 : Make s u r e you have pcm( mixing ) volume none z e r o
In t e r m i n a l you can u s e a l s a m i x e r ( I had t o u s e t h e o p t i o n −c 0 ) o r
aumixer , o r p r o b a b l y t h e p u l s e a u d i o commandline pacmd .
o r whatever volume mixer i n t e r f a c e l i k e x f c e 4 −mixer , o r t h e p u l s e a u d i o
one i f you i n s t a l l e d i t .
#S t e p 4 : Test
K i l l a l l a p p l i c a t i o n s u s i n g sound , i n c l u d i n g p u l s e a u d i o . The command l s o f
−w | e g r e p ' snd | dsp ' s h o u l d return n o t h i n g .
Do some t e s t i n g . H o p e f u l l y you s h o u l d be a b l e t o have youtube / v l c /
rhythmbox working a l l t o g e t h e r a t t h e same time f o r a good cachophony .
%%
%
In t h e f i l e / e t c / i c e w e a s e l / i c e w e a s e l r c , r e p l a c e t h e l i n e ICEWEASEL_DSP="
none " by ICEWEASEL_DSP=" a o s s "
a o s s i s a s i m p l e wrapper s c r i p t which f a c i l i t a t e s t h e u s e o f t h e ALSA OSS
compatibility library .
To i n s t a l l i t :
r o o t @ l o c a l h o s t : ~#apt − g e t i n s t a l l a l s a −o s s
E. Branlard
17
CHAPTER 2. APPPLICATIONS
Does i t work ??
2.7 Custom letypes in geany
# t o make i t r e a l l y custon , you need t o comnpile one . . .
O t h e r w i s e u s e an e x i s t i n g p a r s e r ( p e r l C, LaTeX) and c u s t o m i z e i t
# First step
l a u n c h Geany , Tool>>C o n f i g u r a t i o n f i l e s >>f i l e t y p e_e x t e n s i o n s . c o n f
Add t h e l i n e
Bib=* . b i b ;
and saved i n
~/ .
c o n f i g / geany / f i l e t y p e_e x t e n s i o n s . c o n f
cp / u s r / s h a r e / geany / f i l e t y p e s
. conf
. latex
/ home /manu/ .
c o n f i g / geany / f i l e t y p e s . b i b
2.8 Indexation - Search in pdf
#
s w i s h++ appear a s a good s o l u t i o n , i t i s c o n f i g u r a b l e v i a a . c o n f f i l e
i n s t e a d o f u s i n g a c o n f f i l e , one can u s e
c o n v e r t a l l pdf t o t x t v i a p d f t o t e x t
then i n d e x them with i n d e x++
then s e a r c h with s e a r c h++
do
i t manually
#
Use t r a c k e r . . . i t ' s e a s i e r and more complete
t r a c k e r −c o n t r o l −s
: To l a u n c h t h e i n d e x i n g :
t r a c k e r −p r e f e r e n c e s
: for options
t r a c k e r −s e a r c h − t o o l
: for g r a p h i c a l i n t e r f a c e
tracker search bla
: command l i n e s e a r c h
t r a c k e r s e a r c h − t b l a : s e a r c h i n documents
2.9 OCR Text recognition and searchable PDF
Idea :
− s p l i t t i n g pdf
− c o n v e r t i n g t o good image format ( 1 bpp )
− u s e an OCR t o o l t o c r e a t e hOCR data ( html OCR)
− u s e h o c r 2 p d f t o put t h e t e x t data i n t o t h e pdf
− combine t h e pdf ( u s i n g p d f j o i n from pdfjam )
%%
%
Step by s t e p t o o l s
# pdftk
# pdf2ppm
# C r e a t i n g hocr f i l e s from images
− t e s s e r a c t ( you need v e r s i o n 3 not 2 . 0 4 a s i n Debian s e e below )
E. Branlard
18
CHAPTER 2. APPPLICATIONS
− cuneiform
c u n e i f o r m − l l a n g u a g e − f h o c r −o output . h o c r i n f i l e . ppm
# h o c r 2 p d f : p u t s hOCR d a t a i n t o t h e p d f ( b e h i n d images )
h o c r 2 p d f comes with e x a c t i m a g e
−i i n p u t f i l e
−o output pdf
−n : no image , a l l o w s t o s k i p t h e image n o r m a l l y shadowing t h e t e x t t o
e i t h e r s a v e s t o r a g e s p a c e o r t a k e a l o o k how e x a c t l y t h e g l y p h s a r e
positioned .
− s : s l o p p y t e x t can improve copy p a s t e t e x t
example :
h o c r 2 p d f − i s c a n . t i f f − s −o
test
. pdf < cunei form −out . h o c r
%%
%
T o o l s / s c r i p t s t o do i t
gkovacs − p d f o c r ( h t t p s : // g i t h u b . com/ g k o v a c s / p d f o c r )
p d f 2 o c r ( h t t p : // b l o g . k o n r a d v o e l k e l . de / 2010 / 01 / l i n u x −ocr −and−pdf −problem −
solved/)
# w a t c h o c r i s a l i n u x d i s t r i b u t i o n a c t i n g as s e r v e r t o do t h i s ( u s i n g
h o c r 2 p d f and cuneiform )
%%
%
S c r i p t 1 − Using T e s s e r a c t 3
#! / b i n / bash
echo " u s a g e : p d f o c r . sh document . pdf \ " a u t h o r \ " \" t i t l e \ " "
# Adapted from h t t p : // b l o g . k o n r a d v o e l k e l . de / 2010 / 01 / l i n u x −ocr −and−pdf −
problem − s o l v e d /
# NOTE: This s c r i p t has been s u b s t a n t i a l l y m o d i f i e d / s i m p l i f i e d from t h e
original .
# This v e r s i o n does not a l l o w r o t a t i o n , l a n g u a g e s e l e c t i o n or c r o p p i n g .
# Those p a r a m e t e r s were a l l r e q u i r e d i n t h e o r i g i n a l , b u t I don ' t r e a l l y
need them .
# I f you can t h i n k o f a way t o make them o p t i o n a l , p l e a s e s h a r e .
# This v e r s i o n a l s o u s e s T e s s e r a c t , which I f i n d t o be s u b s t a n t i a l l y more
# a c c u r a t e than Cuneiform f o r E n g l i s h t e x t .
# u s a g e examples :
p d f t k " $ 1 " b u r s t dont_ask
f o r f i n pg_* . pdf
do
" pre − p r o c e s s i n g $ f . . . "
c o n v e r t − q u i e t − d e n s i t y 300 −depth 8 " $ f " " $ f . t i f "
echo no s p l i t t i n g
echo
done
for
f i n pg_* . t i f
do
" processing $f . . . "
t e s s e r a c t "$ f " "$ f " h o c r
echo " Merging TIFF and hOCR i n t o PDF f i l e a t 150 DPI . . . "
#Downsample t o c u t down on f i l e b l o a t
h o c r 2 p d f − r 150 − i " $ f " −o " $ f −o c r . pdf " <" $ f . t i f . html "
echo
done
echo
E. Branlard
" InfoKey : Author " > i n . i n f o
19
CHAPTER 2. APPPLICATIONS
" I n f o V a l u e : $ 2 " >> i n . i n f o
" InfoKey : T i t l e " >> i n . i n f o
echo " I n f o V a l u e : $ 3 " >> i n . i n f o
echo " InfoKey : C r e a t o r " >> i n . i n f o
echo " I n f o V a l u e : PDF OCR s c a n s c r i p t " >> i n . i n f o
p d f j o i n −− f i t p a p e r −− t i d y −− o u t f i l e " $ 1 . o c r 1 . pdf " "pg_*− o c r . pdf "
rm − f pg_*
p d f t k " $ 1 . o c r 1 . pdf " update_i n f o doc_data . t x t output " $ 1 . o c r 2 . pdf "
p d f t k " $ 1 . o c r 2 . pdf " update_i n f o i n . i n f o output " $1− o c r . pdf "
rm − f " $ 1 . o c r 1 . pdf " " $ 1 . o c r 2 . pdf " doc_data . t x t i n . i n f o
echo
echo
%%
%
Script 2 using cuneiform
#! / b i n / bash
p d f t k " $ 1 " b u r s t dont_ask
f o r f i n pg_* . pdf
do
" pre − p r o c e s s i n g $ f . . . "
c o n v e r t − q u i e t − r o t a t e $ [ 9 0 *$ 2 ] −monochrome − n o r m a l i z e − d e n s i t y 300 " $ f " "
$ f . png"
c o n v e r t − q u i e t − c r o p $ 6x $7+$4+$ 5 " $ f . png" " $ f . png"
i f [ " 1 " = "$3 " ] ;
echo
then
c o n v e r t − q u i e t − c r o p $ [ $ 6 / 2 ] x $7+0+0 " $ f . png" " $ f . 1 . png"
c o n v e r t − q u i e t − c r o p 0x $7+$ [ $ 6 / 2]+0 " $ f . png" " $ f . 2 . png"
rm − f " $ f . png"
else
echo
no s p l i t t i n g
fi
rm
− f "$ f "
done
for
f i n pg_* . png
do
" processing $f . . . "
c o n v e r t " $ f " " $ f . bmp"
c u n e i f o r m − l $ 8 − f h o c r −o " $ f . h o c r " " $ f . bmp"
c o n v e r t − b l u r 0 . 4 " $ f " " $ f . bmp"
h o c r 2 p d f − i " $ f . bmp" − s −o " $ f . pdf " < " $ f . h o c r "
rm − f " $ f " " $ f . bmp" " $ f . h o c r "
echo
done
" InfoKey : Author " > i n . i n f o
" I n f o V a l u e : $ 9 " >> i n . i n f o
echo " InfoKey : T i t l e " >> i n . i n f o
echo " I n f o V a l u e : $ 10 " >> i n . i n f o
echo " InfoKey : C r e a t o r " >> i n . i n f o
echo " I n f o V a l u e : PDF OCR s c a n s c r i p t " >> i n . i n f o
p d f j o i n −− f i t p a p e r −− t i d y −− o u t f i l e " $ 1 . o c r 1 . pdf " "pg_* . png . pdf "
rm − f pg_* . png . pdf
p d f t k " $ 1 . o c r 1 . pdf " update_i n f o doc_data . t x t output " $ 1 . o c r 2 . pdf "
p d f t k " $ 1 . o c r 2 . pdf " update_i n f o i n . i n f o output " $1− o c r . pdf "
rm − f " $ 1 . o c r 1 . pdf " " $ 1 . o c r 2 . pdf " doc_data . t x t i n . i n f o
rm − r f pg_*_ f i l e s
echo
echo
%%
%
p d f t k i n f i l e . pdf b u r s t dont_ask
p d f t k i n f i l e . pdf dump_data
pdftoppm pg_0 0 1 . pdf > pg_0 0 1 .ppm
E. Branlard
20
CHAPTER 2. APPPLICATIONS
c u n e i f o r m − l l a n g u a g e − f h o c r −o out . h o c r f i l e . ppm '
o c r o s c r i p t r e c o g n i z e f i l e . ppm > out . h o c r "
h o c r 2 p d f − i f i l e . ppm − s −o i n f i l e −new . pdf < out . h o c r "
p d f t k i n f i l e *−new . pdf c a t output merged . pdf
p d f t k merged . pdf update_i n f o p d f i n f o . t x t output o u t f i l e . pdf
%%
%
Tesseract 3
sudo apt −g e t i n s t a l l l i b p n g 1 2 −dev
sudo apt −g e t i n s t a l l l i b j p e g 6 2 −dev
sudo apt −g e t i n s t a l l l i b t i f f 4 −dev
sudo apt −g e t i n s t a l l z l i b g −dev
sudo apt −g e t i n s t a l l l e p t o n i c a
svn c h e c k o u t h t t p : // t e s s e r a c t −o c r . g o o g l e c o d e . com/ svn / trunk / t e s s e r a c t −ocr −
read−o n l y
. /runautoconf
./configure
make
sudo make i n s t a l l
#download l a n g u a g e d a t a
cd / u s r / l o c a l / s h a r e / t e s s d a t a
sudo wget h t t p : // t e s s e r a c t −o c r . g o o g l e c o d e . com/ f i l e s / eng . t r a i n e d d a t a . gz
#a c t i v a t e hocr
cd / u s r / l o c a l / s h a r e / t e s s d a t a / c o n f i g s
sudo v i h o c r
You need t o know how t o u s e Vim t o do t h i s b i t
Put t h i s i n : " t e s s e d i t_c r e a t e_h o c r 1 "
Save with " : x"
#u s a g e
Convert − d e n s i t y 300 s c a n p a g e 1 . pdf −depth 8 s c a n p a g e 1 . t i f
Tesseract scanpage1 . t i f outputtext
Tesseract scanpage1 . t i f outputtext hocr
pdftk burst
test
. pdf
c o n v e r t − q u i e t −monochrome − n o r m a l i z e − d e n s i t y 300 pg_0 0 0 1 . pdf pg_0 0 0 1 . png
c o n v e r t pg_0 0 0 1 . png pg_0 0 0 1 .bmp
c o n v e r t − q u i e t − d e n s i t y 300 −depth 8 −monochrome − n o r m a l i z e pg_0 0 0 1 . pdf pg
_0 0 0 1 . t i f
c o n v e r t − q u i e t − d e n s i t y 300 −depth 8 −monochrome − n o r m a l i z e pg_0 0 0 1 . pdf pg
_0 0 0 1 .bpm
t e s s e r a c t pg_0 0 0 1 .bmp pg_0001 h o c r
t e s s e r a c t pg_0 0 0 1 . t i f pg_0002 h o c r
t e s s e r a c t pg_0 0 0 1 . png pg_0003 h o c r
E. Branlard
21
CHAPTER 2. APPPLICATIONS
c u n e i f o r m − f h o c r −o pg_0 0 0 1 . h o c r pg_0 0 0 1 .bmp
c o n v e r t − b l u r 0 . 4 pg_0 0 0 1 . png
h o c r 2 p d f − i pg_0 0 0 1 .bmp −n − s
h o c r 2 p d f − i pg_0 0 0 1 . t i f −n − s
h o c r 2 p d f − i pg_0 0 0 1 . png −n − s
h o c r 2 p d f − i pg_0 0 0 1 . png −n − s
h o c r 2 p d f − i pg_0 0 0 1 . png
pg_0 0 0 4 .bmp
−o out_0 0 0 1 . pdf
−o out_0 0 0 2 . pdf
−o out_0 0 0 3 . pdf
−o out_0 0 0 5 . pdf
<
<
<
<
pg_0 0 0 1 . html
pg_0 0 0 2 . html
pg_0 0 0 3 . html
pg_0 0 0 4 . html
−n − s −o out_0 0 0 4 . pdf < pg_0 0 0 1 . h o c r
#h o c r 2 p d f − i " $ f . bmp" −n − s −o " $ f . p d f " < " $ f . hocr "
#rm − f " $ f " " $ f . bmp" " $ f . hocr "
rm − f " $ f " " $ f . bmp"
2.10 Antivirus for linux- ClamAV - freshclam
a p t i t u d e i n s t a l l clamav
2.11 Install Microsoft Oce 2007
%%
%
For d e b i a n s q u e e z e :
− maybe t h e r e i s a way by u s i n g wine − u n s t a b l e ( wine 1 . 1 . 4 2 )
− O t h e r w i s e ( what I ' ve done ) download t h e . deb f o r wine 1 . 2 f o r ubuntu
jaunty
This w i l l r e q u i r e you t o d e s i n s t a l l t h e p r e v i o u s wine . And i t ' s b e s t i f
you remove your ~/ . wine d i r e c t o r y f i r s t
then do
a winecfg
the i n s t a l l
( i f you can ' t type t h e p r o d u c t key , you p r o b a b l y i n s t a l l e d r i c h e d 2 0
l i b r a i r i e with w i n e t r i c k s , remove i t )
do
%%
%
Minimum , i t worked
get winetricks
w i n e t r i c k s c o r e f o n t s tahoma vcrun2005sp1 w s h 5 6 j s a l l f o n t s
%%
%
Font smoothing
wget h t t p : // f i l e s . p o l o s a t u s . ru / w i n e f o n t s s m o o t h i n g_en . sh
bash w i n e f o n t s s m o o t h i n g_en . sh
%%
%
xls2latex
#1
I manage t o g e t x l s 2 l a t e x working , by adding t h i s macro t o t h e custom
t o o l b a r on top o f t h e r i b b o n
Open x l s 2 l a t e x
E. Branlard
22
CHAPTER 2. APPPLICATIONS
C l i c k on top o f t h e ribbom −> Customize commands −> Macro −> ToLatexTable
#2
I m o d i f i e d t h e VBA code , now i t ' s working . Use t h e F i l e E x c e l 2 L a t e x ? Linux .
Execute CreateCommandBar
I t s h o u l d be i n a d d i n s now
I removed t h e buggy forms
I t copy t h e l a t e x t a b l e i n t h e c l i p b o a r d
%%
%
More ???
. / w i n e t r i c k s msxml3 d o t n e t 2 0 g d i p l u s r i c h e d 2 0 r i c h e d 3 0 vcrun2005sp1
allfonts
2.12 Mount .bin/.cue - convert them to .iso
The e a s i e s t : c o n v e r t them t o i s o with bchunk
sudo a p t i t u d e i n s t a l l bchunk
The s y n t a x from bchunk i s a s f o l l o w s :
bchunk [ − v ] [ − p ] [ − r ] [ −w ] [ − s ]
bchunk image . b i n image . cue image . i s o
Mount t h e i s o :
mount −o l o o p − t i s o 9 6 6 0 image . i s o /mnt/ image
2.13 pdf2png - pdftopng
Best I found :
c o n v e r t − d e n s i t y 300 − format png n p o i n t s 3 . pdf n p o i n t 3 . png
Bof :
c o n v e r t − q u a l i t y 100 n p o i n t s 3 . pdf n p o i n t 3 . png
m o g r i f y − q u a l i t y 100 − format png n p o i n t s 3 . pdf
Ma s o l u t i o n : (NON ACTUALISE)
Compiler l e code source r e d h a t de K r i s t i a n Hogsberg <krh@redhat . com>
( I n f o r m a t i q u e / Programmation /C/ pdf2png )
Chercher c a i r o / t e s t s u r i n t e r n e t
M a k e f i l e . am*
M a k e f i l e . win *
pdf2png . c *
pdf2png . dev *
pdf2png . l a y o u t *
p o p p l e r −a c t i o n . c c *
p o p p l e r −a c t i o n . h*
p o p p l e r −attachment . c c *
poppler . cc*
p o p p l e r −document . h *
p o p p l e r −f e a t u r e s . h . i n *
poppler . g i d l *
E. Branlard
23
CHAPTER 2. APPPLICATIONS
p o p p l e r . h*
p o p p l e r −page . c c *
p o p p l e r −page . h *
p o p p l e r − p r i v a t e . h*
t e s t −p o p p l e r − g l i b . c *
2.14 Fuseiso - Monter iso facilement- thunar shortcut
a d d u s e r manu f u s e
##Mounting command :
f u s e i s o −n −p %f %f . mount
appearance c o n d i t i o n s :
* . i s o ; * . ISO ; * . b i n ; * . BIN ; * . nrg ; * .NRG; * . mdf ; * .MDF
## Unmouting command :
fusermount −u %f
* . mount
2.15 Meld : File/Folder comparison- thunar shortcut
meld %F
2.16 Catsh : Find les- thunar shortcut
c a t f i s h −− f i l e m a n=thunar −−path=%f
( on d i r e c t o r i e s )
2.17 Java - iceweasel debian - Network problem
i n s t a l l i n g java :
a p t i t u d e i n s t a l l sun−java6 − j r e sun−java6 − p l u g i n
update −java − a l t e r n a t i v e s −−s e t java −6−sun
Here i s t h e s o l u t i o n .
open f i l e
/etc/ sysctl
. d / b i n d v 6 o n l y . c o n f and s e t n e t . i p v 6 . b i n d v 6 o n l y =0,
t h e p r o c f s with invoke − r c . d p r o c p s r e s t a r t
then
restart
h e r e a r e t h e c o r r e s p o n d i n g bugs
h t t p : // bugs . d e b i a n . o r g / c g i −b i n / b u g r e p o r t . c g i ? bug =560238
h t t p : // bugs . d e b i a n . o r g / c g i −b i n / b u g r e p o r t . c g i ? bug =560056
This wasted q u i e t some time f o r me , s o I thought I ' d warn you .
I t happens i f you update package n e t b a s e t o 4 . 4 0 and i t can a f f e c t o t h e r
apps too , e s p e c i a l l y i f they a r e not from t h e d e b i a n r e p o s .
A r e a l debian s p e c i a l . . .
E. Branlard
24
CHAPTER 2. APPPLICATIONS
2.18 Matlab : Ajouter un repertoire dans la variable PATH
Unix Systems
On a Unix computer you can s e t t h e MATLABPATH environment v a r i a b l e by
t y p i n g something l i k e t h e f o l l o w i n g a t t h e sytem prompt ( not t h e MATLAB
prompt ) . S i p l u s i e u r s paths , l e s c o n c a t e n e r avec " : " .
export MATLABPATH=/ home / s h a r e / C o n f i g / matlab
I t doesn ' t seem t o work , s o u s e Matlab d i r e c t l y : F i l e / S e t Path . . .
I f you don ' t have w r i t i n g r i g h t s , then s a v e p a t h d e f .m and copy i t t o t h e
b i n d i r e c t o r y o f matlab
2.19 Snapshot - Capture d'ecran
x f c e 4 −s c r e e n s h o o t e r
2.20 FOR LOOPS/ FIND / XARGS and SPACE CHARACTERS ->
Find in PDF
bash u s e s s p a c e c h a r a c t e r s a s d e f a u l t s e p a r a t o r s . This i s
v a r i a l b l e $ IFS
set
with t h e
#Option 1
#! / b i n / bash
SAVEIFS=$ IFS
IFS=$ ( echo −en " \n\b" )
for f in *
do
echo
"$ f "
done
IFS=$SAVEIFS
#Option 2
f i n d . −p r i n t 0 |
while
read
−d
$
'\0 ' f i l e
do
echo
−v " $ f i l e "
done
# Application : S c r ip t to find in pdf :
#! / b i n / bash
SAVEIFS=$ IFS
IFS=$ ( echo −en " \n\b" )
echo
for
" Looking f o r " $ 1
i i n ` f i n d −name " * . pdf " − p r i n t f '%h /%f \n '
2>
/ dev / n u l l
`
do
echo
echo
echo
E. Branlard
"−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
"$ i " ;
"−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
25
CHAPTER 2. APPPLICATIONS
#
done ;
p d f t o t e x t $ i − | g r e p −− c o l o r=always
s t r i n g s "$ i " | g r e p $1
$1
IFS=$SAVEIFS
2.21 Iceweasel / Firefox et java plugin
R é c a p i t u l a t i f d ' i n s t a l l a t i o n de JAVA
et
d e s p l u g i n s Java dans I c e w e a s e l
J ' a i t é l é c h a r g é j r e −6u1−l i n u x − i 5 8 6 . b i n i c i
h t t p : // s d l c 5 c . sun . com/ . . .
J ' a i changé l e s p r o p r i é t é s d ' a c c è s du f i c h i e r a f i n de p o u v o i r l ' e x é c u t e r .
#chmod +x j r e −6u1− l i n u x −i 5 8 6 . b i n
J ' a i e x é c u t é l e f i c h i e r à l ' a i d e de l a commande s u i v a n t e :
#. / j r e −6u1− l i n u x −i 5 8 6 . b i n
Un r é p e r t o i r e nommé j r e 1 . 6 . 0 v i e n t d ' ê t r e c r é é . J ' a i d é p l a c é c e r é p e r t o i r e
dans l e r é p e r t o i r e / opt q u i va c o n t e n i r t o u t e s l e s a p p l i c a t i o n s
utilisateurs propriétaires .
#mv − f j r e 1 . 6 . 0_01 / / o p t /
J ' a i a j o u t é l e s l i e n s v e r s l e s b i n a i r e s n é c e s s a i r e s à l ' a i d e d e s commandes
suivantes :
#l n − s / o p t / j r e 1 . 6 . 0_01 / b i n / j a v a / u s r / l o c a l / b i n / j a v a
#l n − s / o p t / j r e 1 . 6 . 0_01 / b i n / p o l i c y t o o l / u s r / l o c a l / b i n / p o l i c y t o o l
J ' a i r e n s e i g n é l e r e s t e du système que l a Java Runtime Environment e s t
i n s t a l l é e en a j o u t a n t l a l i g n e s u i v a n t e au f i c h i e r / e t c / environment
#echo JAVA_HOME=/ o p t / j r e 1 . 6 . 0_01 >> / e t c / environment
C r é a t i o n de l i e n v e r s l i b j a v a p l u g i n_ o j i . s o
#l n − s f v / o p t / j r e 1 . 6 . 0_01 / p l u g i n / i 3 8 6 / ns7 / l i b j a v a p l u g i n_o j i . so
iceweasel/plugins
/usr/ l i b /
2.22 VISIO 2003
L ' i n s t a l l a t i o n marche
#Pour r e s o u d r e l ' e r r e u r IOPL not e n a b l e d :
winecfg
#Go t o t h e L i b r a r i e s tab , and add an e n t r y c a l l e d g d i p l u s . Then , e d i t t h e
e n t r y you j u s t added , and s e l e c t N a t i v e ( Windows ) .
2.23 Firefox / iceweasel slow, tweak it
dans l a b a r r e d ' a d d r e s s e :
about : c o n f i g
d e s a c t i v e r l ' Ipv6 en d o u b l e c l i q u a n t s u r
network . dns . d i s a b l e I p v 6
Other tweaks t h a t can be done i n t h e u s e r . j s f i l e
ou ( p r e f . j s quand f i r e f o x i s c l o s e d )
E. Branlard
26
CHAPTER 2. APPPLICATIONS
o r by about : c o n f i g
* Speed Tweak − Common t o a l l C o n f i g u r a t i o n s */
u s e r_p r e f ( " network . h t t p . p i p e l i n i n g " , true ) ;
u s e r_p r e f ( " network . h t t p . proxy . p i p e l i n i n g " , true ) ;
u s e r_p r e f ( " network . h t t p . p i p e l i n i n g . m a x re q u es t s " , 8 ) ;
u s e r_p r e f ( " c o n t e n t . n o t i f y . b a c k o f f c o u n t " , 5 ) ;
u s e r_p r e f ( " p l u g i n . e x p o s e_ f u l l _path " , true ) ;
u s e r_p r e f ( " u i . submenuDelay " , 0 ) ;
/ * Speed Tweak − Fast Computer Fast Connection * /
u s e r_p r e f ( " c o n t e n t . i n t e r r u p t . p a r s i n g " , true ) ;
u s e r_p r e f ( " c o n t e n t . max . t o k e n i z i n g . time " , 2 2 5 0 0 0 0 ) ;
u s e r_p r e f ( " c o n t e n t . n o t i f y . i n t e r v a l " , 7 5 0 0 0 0 ) ;
u s e r_p r e f ( " c o n t e n t . n o t i f y . o n t i m e r " , true ) ;
u s e r_p r e f ( " c o n t e n t . s w i t c h . t h r e s h o l d " , 7 5 0 0 0 0 ) ;
u s e r_p r e f ( " n g l a y o u t . i n i t i a l p a i n t . d e l a y " , 0 ) ;
u s e r_p r e f ( " network . h t t p . max− c o n n e c t i o n s " , 4 8 ) ;
u s e r_p r e f ( " network . h t t p . max−c o n n e c t i o n s −per − s e r v e r " , 1 6 ) ;
u s e r_p r e f ( " network . h t t p . max− p e r s i s t e n t −c o n n e c t i o n s −per −proxy " , 1 6 ) ;
u s e r_p r e f ( " network . h t t p . max− p e r s i s t e n t −c o n n e c t i o n s −per − s e r v e r " , 8 ) ;
u s e r_p r e f ( " b r o w s e r . c a c h e . memory . c a p a c i t y " , 6 5 5 3 6 ) ;
/
D i s a b l i n g i p v 6 i s t h e b i g g i e t h a t t e n d s t o s p e e d t h i n g s up . As mentioned
in the " other " thread .
/ * Speed Tweak − Another Tweak * /
u s e r_p r e f ( " network . dns . d i s a b l e I P v 6 " , true ) ;
* Tor S e t t i n g s */
u s e r_p r e f ( " network . h t t p . keep − a l i v e . t i m e o u t " , 6 0 0 ) ;
u s e r_p r e f ( " network . h t t p . proxy . keep − a l i v e " , true ) ;
/
# Perso :
# Pour a v o i r l e s t a b de memes t a i l l e s , m o d i f i e r l e s t a b o p t i o n s
max_t a b s_undo
tabMaxWidth
tabMinWidth
2.24 PDF Croping - suppression d'espace de marges
#U t i l i s e r p d f c r o p ( s c r i p t p e r l d ' E r i c Doviak e t Mark S h e r r y ) d i s p o n i b l e
sur source forge
#Sinon , pour a v o i r l a t a i l l e ( o l d s t u f f )
i d e n t i f y x . pdf
Puis
c o n v e r t − c r o p 10+10+0+0 x . pdf y . pdf
# R e c e n t l y : I found i t t o work by f i r s t c o n v e r t i n g t o png w i t h a d e n s i t y
chosen ( between 100 and 300 d e p e n d i n g )
f o r i i n * . pdf ; do c o n v e r t − d e n s i t y 150 $ i tmp/$ { i %. * } . png ;
done
identify *
( g i v e s W0xH0)
c o n c e r t − c r o p W2xH2+L2+T2 +r e p a g e x . png y . png
Option +r e p a g e i s important , i t remove t h e canvas i n f o r m a t i o n , s e t i t t o
t h e new image s i z e .
E. Branlard
27
CHAPTER 2. APPPLICATIONS
#c o n v e r t − crop 950 x1160 +280+160 +r e p a g e x . png y , png
2.25 Renommage massif unix
ca depend de l a v e r s i o n de rename
rename " s /mp4/mp3/ g " * . mp4
rename . mp3 . mp4 * . mp3
rename " s /mp4/mp3/ " * . mp4
f o r i i n *htm ; do mv $ i ` basename $ i htm ` html ;
f o r i i n *htm ; do mv $ i $ { i%%. htm } . html ; done
done
2.26 Faire un dictionaire - Compter le nombre de keywords d'une
page web
unalias
grep
− V i r e r l e s commandes HTML : sed −e : a −e ' s / <[^>] *>// g ; /</N; // ba '
− U t i l i s e r t r pour t r a n s f o r m e r un c h a r a c t e r en un a u t r e ( e s p a c e en n e w l i n e )
: t r ' ' '\n '
− V i r e r l a p o n c t u a t i o n : t r −d ' [ : punct : ] '
− V i r e r l e s l i g n e s avec d e s c a r a c t e r e s q u i ne s o n t pas d e s l e t t r e s ( tab ,
nombres . . . ) : g r e p −v ' [ ^ a−z ] '
− V i r e r l e s mots de moins de 2 l e t t r e s e t l e s l i g n e s v i d e s : g r e p −E ' [ a−z
]{3 ,} '
−Mettre t o u t en l o w e r c a se :
t r ' [ : upper : ] ' ' [ : l o w e r : ] '
− V i r e r l e s mot communs :
g r e p −v −E −w ' t h e | and | f o r | from | with | used '
− T r i e r avec s o r t
−Compter l e s o c c u r e n c e s avec uniq e t l ' o p t i o n −c : uniq −c
− T r i e r par nombre r e v e r s e : s o r t −rn
cat
* php * | sed −e : a −e ' s / <[^>] *>// g ; /</N; // ba ' | t r ' ' ' \ n ' | t r −d
' [ : punct : ] ' | g r e p −v ' [ ^ a−z ] ' | g r e p −E ' [ a−z ] { 3 , } ' | t r ' [ : upper : ] '
' [ : l o w e r : ] ' | g r e p −v −w −E ' t h e | and | f o r | from | with | used | which | a r e | t h a t |
t h i s | w i l l | can | been | s h o u l d | u s i n g | a l l | one | two | t h r e e | has | taken | where | made |
a l s o | t h u s | though | have | when | not | such | f i g u r e | t a b l e | t h e s e | c o u l d | s e e n | g i v e n
| nbsp | l e s | d e s | from | d i f f e r e n t | e s t | dans | une | our | q u i | between | next | would |
s o n t | i t s | s e e | son | p l u s | c a se | que | pour | s u i v a n t | nous | par | s u r | each | but | than |
o n l y | o t h e r | main | f i g u r e s | t a b l e s | more | t h e r e | v a l u e | v a l u e s | were | was | low |
h i g h | around | s i n c e | v e r y | o r d e r | p e r | i n t o | f i r s t | b e c a u s e | found | them | done |
good | t h e i r | r e a l l y | h e r e | g o t | b i g | b e t t e r | w e l l | away | shown | o v e r | l i k e | while |
w i t h i n | t a k e | due | any | then | under | same | much | most | both | s e c o n d | l o t | u s e | g e t |
pas | mais | a l o r s | peut | p l o t | l e f t | r i g h t ' | s o r t | uniq −c | s o r t −rn | head
−50 | sed ' s / ' [ \ 0 − 9] ' // g ' | x a r g s
SUPERFILE | g r e p −E ' [ a−z ] { 3 , } ' | t r
' [ : punct : ] ' >SUPERFILE2
cat
cat
' [ : upper : ] '
' [ : l o w e r : ] ' | t r −d
SUPERFILE3 | g r e p −v −w −E ' t h e | and | f o r | from | with | used | which | a r e | t h a t |
t h i s | w i l l | can | been | s h o u l d | u s i n g | a l l | one | two | t h r e e | has | taken | where | made |
E. Branlard
28
CHAPTER 2. APPPLICATIONS
a l s o | t h u s | though | have | when | not | such | f i g u r e | t a b l e | t h e s e | c o u l d | s e e n | g i v e n
| nbsp | l e s | d e s | from | d i f f e r e n t | e s t | dans | une | our | q u i | between | next | would |
s o n t | i t s | s e e | son | p l u s | c a se | que | pour | s u i v a n t | nous | par | s u r | each | but | than |
o n l y | o t h e r | main | f i g u r e s | t a b l e s | more | t h e r e | v a l u e | v a l u e s | were | was | low |
h i g h | around | s i n c e | v e r y | o r d e r | p e r | i n t o | f i r s t | b e c a u s e | found | them | done |
good | t h e i r | r e a l l y | h e r e | g o t | b i g | b e t t e r | w e l l | away | shown | o v e r | l i k e | while |
w i t h i n | t a k e | due | any | then | under | same | much | most | both | s e c o n d | l o t | u s e | g e t |
pas | mais | a l o r s | peut | p l o t | l e f t | r i g h t ' | s o r t | uniq −c | s o r t −rn | head
−300
cat
t e s t | g r e p −v −w −E ' t h e | and | f o r | from | with | used | which | a r e | t h a t | t h i s |
w i l l | can | been | s h o u l d | u s i n g | a l l | one | two | t h r e e | has | taken | where | made | a l s o |
t h u s | though | have | when | not | such | f i g u r e | t a b l e | t h e s e | c o u l d | s e e n | g i v e n | nbsp
| l e s | d e s | from | d i f f e r e n t | e s t | dans | une | our | q u i | between | next | would | s o n t |
i t s | s e e | son | p l u s | c a se | que | pour | s u i v a n t | nous | par | s u r | each | but | than | o n l y |
o t h e r | main | f i g u r e s | t a b l e s | more | t h e r e | v a l u e | v a l u e s | were | was | low | h i g h |
around | s i n c e | v e r y | o r d e r | p e r | i n t o | f i r s t | b e c a u s e | found | them | done | good |
t h e i r | r e a l l y | h e r e | g o t | b i g | b e t t e r | w e l l | away | shown | o v e r | l i k e | while | w i t h i n
| t a k e | due | any | then | under | same | much | most | both | s e c o n d | l o t | u s e | g e t | pas |
mais | a l o r s | peut | p l o t | l e f t | r i g h t ' | s o r t | uniq −c | s o r t −rn | head −300
2.27 Aspirer un site avec wget
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? i d =78954
wget − r − l 1 −k −E −A * svg h t t p : //www. o p e n c l i p a r t . o r g / u s e r − c l i p a r t s / johnny_
a u t o m a t i c ? page=$ i
wget − r − l 5 −k −E −np www. u n s i t e . com
`−− no−parent ' Do not e v e r a s c e n d t o t h e p a r e n t d i r e c t o r y when
r e t r i e v i n g r e c u r s i v e l y . This i s a u s e f u l o p t i o n , s i n c e i t
guarantees
t h a t o n l y t h e f i l e s _below_ a c e r t a i n h i e r a r c h y w i l l be downloaded .
s e e " D i r e c t o r y −Based L i m i t s " , f o r more d e t a i l s .
Explication :
−r
−l 5
−k
−E
: r é c u r s i f sur l e s i t e
: c i n q n i v e a u x de r é c u r s i o n au maximum
: c o n v e r t i r l e s d e s t i n a t i o n s d e s l i e n s pour une l e c t u r e l o c a l e
: c o n v e r t i r l e s t y p e s de f i c h i e r au format HTML ( pour é v i t e r que l a
l e c t u r e de s i t e s en PHP ne f o i r e en l e c t u r e s o u s F i r e f o x ) .
−np : −−no−parent ' Do not e v e r a s c e n d t o t h e p a r e n t d i r e c t o r y
−A : + l i s t o f f i l e t y p e s p a t t e r n s
−c : continue p r e v i o u s l y s t o p p e d download
−−−−−−−−−
Pour a l l e r p l u s l o i n .
E. Branlard
29
CHAPTER 2. APPPLICATIONS
S i vous v o u l e z p l u s d ' o p t i o n s , l a page de manuel de wget e s t p l e i n e d '
i n f o s u t i l e s , v o i c i des options t r è s i n t é r e s s a n t e s :
− t : s p é c i f i e r combien de f o i s que wget d e v r a i t e s s a y e r de t é l é c h a r g e r
chaque f i c h i e r .
−w : s p é c i f i e r combien de temps a t t e n d r e e n t r e l e s e s s a i s
−c : demander à wget de c o n t i n u e r un t é l é c h a r g e m e n t i n t e r r o m p u .
−T : s p é c i f i e r au bout de combien de s e c o n d e s s a n s r é p o n s e wget abandonne
une c o n n e x i o n
−− l i m i t − r a t e : m e t t r e une v i t e s s e de c o n n e x i o n maximale pour ne pas
m o n o p o l i s e r v o t r e bande p a s s a n t e
−Q : l i m i t e r l a p l a c e que p r e n d r o n t t o u s l e s f i c h i e r s t é l é c h a r g é s , pour ne
pas t r o p r e m p l i r v o t r e d i s q u e dur . Dès qu ' à l a f i n d ' un t é l é c h a r g e m e n t
l e quota s e r a d é p a s s é , wget s ' a r r ê t e r a
−−load − c o o k i e s : i m p o r t e r d e s c o o k i e s ( p r a t i q u e pour l e s s i t e s où vous
devriez être authentifié )
−X : e x c l u r e un r é p e r t o i r e
2.28 Modication pdf - Avec le paquet pdftk
# Concaténer l e s f i c h i e r s A1 e t A2 pour o b t e n i r l e f i c h i e r B. p d f
p d f t k A1 . pdf A2 . pdf c a t output B . pdf
# Supprimer l e s 2 p r e m i è r e s p a g e s d ' un document de 9 p a g e s
p d f t k o r i g i n a l . pdf c a t 3−9 output f i n a l . pdf
# Supprimer l e s page 6 e t 7
p d f t k o r i g i n a l . pdf c a t 1−5 8− end output f i n a l . pdf
# Garder l e s p a g e s 69 a 117 i m p a i r e
p d f t k o r i g i n a l . pdf c a t 69 − 117odd output f i n a l . pdf
p d f t k ` l s −1 * . pdf | s o r t −g | xargs `
cat
output out . pdf
#decomposer en p l u s i e u r s f i c h i e r s
p d f t k chap . pdf b u r s t
# R o t a t e an e n t i r e PDF document t o 180 d e g r e e s
p d f t k i n . pdf c a t 1− endS output out . pdf
2.29 Manipulation d'images en masse : image magick
d i s p l a y : i n t e r f a c e g r a p h i q u e moyen ( mauvais gimp )
P l u s i e u r s o u t i l s pour m u l t i p l e s f i c h i e r s dont m o g r i f y
− " m o g r i f y " m o d i f i e l e s image en p l a c e s a l o r s que
− " c o n v e r t " l e s sauve s o u s un a u t r e nom
− " i d e n t i f y " pour donner d e s i n f o s u r l ' image
Options
mogrify
mogrify
mogrify
mogrify
mogrify
mogrify
E. Branlard
utiles :
− r e s i z e 800 x600 * . JPG
− r e s i z e 50% * . JPG
−n e g a t e t e s t . j p g
−monochrome t e s t . j p g
− format j p g * . png
− s c a l e 110 x2 * . png # wouldn ' t work w i t h 110 x1
30
CHAPTER 2. APPPLICATIONS
c o n v e r t f i g 1 3 . png − c r o p 1530 x1210+75+95
16 x16
24 x24
32 x32
48 x48
export f o l d=a c t i o n s
cd $ f o l d
export s i z e =16x16
mkdir . . /$ s i z e /$ f o l d
mogrify −r e s i z e $ s i z e
export s i z e =24x24
mkdir . . /$ s i z e /$ f o l d
mogrify −r e s i z e $ s i z e
export s i z e =32x32
mkdir . . /$ s i z e /$ f o l d
mogrify −r e s i z e $ s i z e
export s i z e =48x48
mkdir . . /$ s i z e /$ f o l d
mogrify −r e s i z e $ s i z e
test
. png
mkdir
mkdir
mkdir
mkdir
−path . . /$ s i z e /$ f o l d * . png
−path . . /$ s i z e /$ f o l d * . png
−path . . /$ s i z e /$ f o l d * . png
−path . . /$ s i z e /$ f o l d * . png
2.30 Evince cannot open any pdf documents anymore
remove
/ u s r / l o c a l / s h a r e /mime/mime .
or
~/ . l o c a l / s h a r e /mime/mime .
cache
cache
2.31 Audio format conversion : ogg, au, mp3, wav, snd,ai ...
SoX i s a b l e t o h a n d l e f o r m a t s l i k e Ogg Vorbis , MP3, WAV, AIFF , VOC, SND,
AU, GSM
sudo a p t i t u d e i n s t a l l sox l i b s o x −fmt− a l l
2.32 dos2unix : package tofrodos
C o n v e r t i t un p o i n t bat
2.33 Vim en color
Dans l e home m e t t r e un f i c h i e r . vimrc avec :
s y n t a x enable
s e t background=dark
f i l e t y p e on
A p a r t ca , pour un s i m p l e f i c h i e r t a p e r " : s y n t a x e n a b l e " s u f f i t
− S i on a c e message :
E319 : Sorry , t h e command i s not a v a i l a b l e i n t h i s v e r s i o n : s y n t a x on
E. Branlard
31
CHAPTER 2. APPPLICATIONS
a l o r s f a i r e un a p t i t u d e i n s t a l l vim ( c a r t o u s l e s runtime ne s o n t pas
presents )
2.34 Listen ou Exaile ou Quod libet ou banshee ou xrmms pour remplacer Amarok
aptitude i n s t a l l l i s t e n
aptitude i n t s a l l exaile
2.35 WICD pour remplacer Gnome Netwok Manager
a p t i t u d e i n s t a l l wicd
2.36 Installer un nouveau pager : most
Le p a g e r e s t un programme q u i s e r t à a f f i c h e r du t e x t e . Vous avez l e
c h o i x e n t r e plu −
s i e u r s programmes , g r â c e à un mécanisme d ' a l t e r n a t i v e s . Je vous p r o p o s e d '
installer
e t d ' u t i l i s e r most , un p a g e r q u i permet e n t r e a u t r e s de c o l o r e r l e s p a g e s
de manuel .
# a p t i t u d e i n s t a l l most
# update − a l t e r n a t i v e s −− c o n f i g p a g e r
La s e c o n d e commande vous demnde de c h o i s i r l e p a g e r à u t i l i s e r .
Répondez en
donnant l e numéro q u i c o r r e s p o n d à most . Maintenant , c ' e s t c e programme
qui sera
u t i l i s é pour a f f i c h e r l e s manuels .
2.37 Gparted equivalent
Dur a t r o u v e r . => p a r t e d en l i g n e de commande
De t o u t e f acon , i l f a u t d e s p a r t i t i o n s demontees , donc u t i l i s a t i o n d ' un
l i v e CD.
I n u t i l e d ' i n s t a l l e r gparted
2.38 Congure skype sound
Son e n t r a n t : HDAINTEL
Le p l u s i m p o r t a n t :
D i g i t a l i n p u t source must be d i g i t a l mic 1 , i n s t e a d o f a n a l o g i n p u t
Plus c l a i r e m e n t :
Avec x f c e 4 −mixer :
Onglet Capture :
Capture e t d i g i t a l en mode en r e g i s t r e m e n t
Onglet Options :
MicJacMode Mic In
E. Branlard
32
CHAPTER 2. APPPLICATIONS
Playback S o u r c e : Analog mux 1
Peut− e t r e : v i r e r p u l s e a u d i o
2.39 Logiciels equivalent linux / windows
h t t p : // w i k i . l i n u x q u e s t i o n s . o r g / w i k i / Linux_s o f t w a r e_e q u i v a l e n t_t o_Windows_
software
h t t p : //www. l i b e r v i s . com/ w i k i / i n d e x . php? t i t l e =Table_o f_E q u i v a l e n t_S o f t w a r e
2.40 Personaliser xterm
xrdb
~/ .
Xdefaults
prompt c o l o r e : ( v a r i a b l e PS1 )
par d e f a u l t : $ { d e b i a n_c h r o o t :+( $ d e b i a n_c h r o o t ) }\u@\h : \w\ $
export PS1 = '\033[1m\ 0 3 3 [ 1 ; 3 3m\u : \ e [ 3 2 ; 1m\w\ e [ 3 3 ; 1m$ \ 0 3 3 [m'
export PS1 = ' \ [ \ 0 3 3 [ 1m\ ] \ [ \ 0 3 3 [ 1 ; 3 3m\ ] \ u : \ [ \ e [ 3 2 ; 1m\ ] \w \ [ \ e [ 3 3 ; 1m\ ] \ $
\ [ \ 0 3 3 [m\ ] '
vim . b a s h r c
# some more l s a l i a s e s
a l i a s l l =' l s − lhb '
a l i a s l s =' l s −F −− c o l o r=always '
a l i a s l a =' l s −lAXh | more '
a l i a s l a g =' l s −lAgXh | grep '
a l i a s l s d =' l s − l | g r e p drwx '
a l i a s l a g =' l s −lAgXh | grep '
a l i a s l s d =' l s − l | g r e p drwx '
a l i a s d i r =' l s −− c o l o r=auto −− format=v e r t i c a l '
a l i a s cd . . = ' cd . . '
a l i a s g r e p =' g r e p −− c o l o r=always '
alias
cp =' cp
a l i a s mv='mv
a l i a s rm='rm '
−i '
−i '
g e d i t =' geany '
m y d i f f =' d i f f −a −b −B −w −y − i −− s u p p r e s s −common− l i n e s '
a l i a s m y d i f f b =' d i f f −a −b −B −w −y − i '
a l i a s f i l e m a n u p=" j a v a − j a r / home / s h a r e / C o n f i g / A p p l i c a t i o n s / F i l e −
m a n u p i l a t i o n −v1 . 3 1 5 / F i l e −Manupilation −v1 . 3 1 5 . j a r "
a l i a s a l a r m a n i a c=" j a v a − j a r / home / s h a r e / C o n f i g / A p p l i c a t i o n s / Alarmaniac /
alarmaniac . j a r "
alias
alias
vim . X d e f a u l t s
xterm
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
xterm * faceName :
monospace : p i x e l s i z e =14
! xterm * dynamicColors :
true
! xterm * u t f 8 :
2
! xterm * e i g h t B i t I n p u t :
true
xterm * s c r o l l T t y K e y p r e s s : true
!
E. Branlard
33
CHAPTER 2. APPPLICATIONS
xterm * s c r o l l T t y O u t p u t :
false
xterm * s c r o l l B a r :
true
xterm * r i g h t S c r o l l B a r :
true
xterm * j u m p S c r o l l :
true
xterm * m u l t i S c r o l l :
true
xterm * background : b l a c k
xterm * f o r e g r o u n d : g r e e n
xterm * t i t l e : xterm
xterm * vt100 . geometry : 80 x28
XTerm* r e v e r s e V i d e o : on
XTerm* S a v e L i n e s : 1000
Xcursor
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Xcursor * theme : V a n i l l a −DMZ−AA
Xcursor . s i z e : 22
!
A m e t t r e dans l e . x i n i t r c
xrdb ~/ . X d e f a u l t s
2.41 Hacker xterm - source code
h t t p : //www. davidsimmons . com/ s o f t / xtermhacks /
S o u r c e code :
h t t p : // i n v i s i b l e − i s l a n d . n e t / xterm / xterm . html
2.42 Congurer Geany
h t t p : // marcimat . magraine . n e t / Geany−SVN−et− p l u g i n s −sous −Ubuntu
Transformer l e s c a r a c t è r e s a c c e n t u é s en un coup de crayon
* sudo a p t i t u d e i n s t a l l r e c o d e
* C l i c d r o i t dans geany > format > e n v o y e r s é l e c t i o n > d é f i n i r une
commande p e r s o n n a l i s é e
* a j o u t e r r e c o d e . . html
* Puis E d i t e r > p r é f é r e n c e s > r a c c o u r c i s > format > Envoyer v e r s l a
commande p e r s o n n a l i s é e 1 . S é l e c t i o n n e r v o t r e r a c c o u r c i . . . pour moi ,
c e s e r a : c o n t r o l+&
2.43 Telecharger les jaquettes des pistes de la liste de lecture d'amarok
dans leur dossier
for
( ( i =0; i <` dcop amarok p l a y l i s t getTotalTrackCount ` ; i ++)) ; do echo "
Traitement de : ` dcop amarok p l a y e r nowPlaying ` " ; cp − f " $ ( dcop amarok
p l a y e r coverImage ) " " $ ( dirname " $ ( dcop amarok p l a y e r path ) " ) " / " $ ( dcop
amarok p l a y e r a r t i s t ) " \ −\ " $ ( dcop amarok p l a y e r album ) " . j p g " " ; dcop
amarok p l a y e r next ; done
for
( ( i =0; i <` dcop amarok p l a y l i s t getTotalTrackCount ` ; i ++)) \
" Traitement de : ` dcop amarok p l a y e r nowPlaying ` " ; \
do echo
E. Branlard
34
CHAPTER 2. APPPLICATIONS
" $ ( dcop amarok p l a y e r path ) " " $ ( dcop amarok p l a y e r nowPlaying ) "
dcop amarok p l a y e r next ; \
done ;
cp
2.44 Latex et packages
editer
/ e t c / texmf / texmf
. cnf , r e p è r e l a l i g n e TEXMFHOME = $HOME/ texmf
comenter %, r e m p l a c e r par TEXMFHOME = /home/manu/ C o n f i g / texmf ,
c r e e r l ' a r b o r e s c e n c e texmf / t e x / l a t e x / e t y m e t t r e t o u s s e s . s t y
Puis f a i r e un :
t e x h a s h ~/ C o n f i g / texmf
p o s s i b i l i t e d ' i n s t a l l e r a u s s i t e x l i n e −g e n e r i c −e x t r a
2.45 Latex et windows
Les f i c h i e r s c r e e r s o u s windows peuvent e t r e u t i l i s e s . I l f a u t l e s o u v r i r
en 8859 − 16 pour d e t e c t e r l e s a c c e n t s .
L' entete doit etre
%\u s e p a c k a g e [ T1 ] { f o n t e n c }
\ usepackage [ l a t i n 1 ] { inputenc }
2.46 RAW photo images nikon .NEF
ufraw −−out −type j p g −− c o m p r e s s i o n 90 * .NEF
2.47 split view, gestionnaire de fenetre a gauche a droite, avec compiz
h t t p : // ubuntuforums . o r g / showthread . php? t =801170&h i g h l i g h t=w i n s p l i t
sudo apt −g e t i n s t a l l compiz − f u s i o n −bcop compiz −dev c o m p i z c o n f i g − s e t t i n g s −
manager b u i l d − e s s e n t i a l l i b t o o l l i b g l u 1 −mesa−dev l i b x s s −dev l i b c a i r o 2 −
dev g i t − c o r e
mkdir
~/ compiz
cd ~/ compiz
g i t c l o n e g i t : // a n o n g i t . compiz − f u s i o n . o r g / u s e r s / s t e v e k / g r i d
grid
make
make i n s t a l l
cd
7 . 1 You may need t o enable " Normal" o r " Extra " under d e s k t o p e f f e c t s i n
System−>P r e f e r e n c e s −>Appearance f i r s t . ( You may a l s o need t o chown −R
u s e r : u s e r ~/ compiz i n o r d e r t o g e t t h i n g s t o c o m p i l e . )
ccsm
9 . Check " g r i d " under "Window Management" .
E. Branlard
35
Chapter
3
Xorg - clavier souris touchpad
3.1 Bien lire le log Xorg
grep
grep
grep
grep
grep
\ (EE / var / l o g / Xorg . 0 . l o g
\ (WW / var / l o g / Xorg . 0 . l o g
d i s a b l e d / var / l o g / Xorg . 0 . l o g
e n a b l e d / var / l o g / Xorg . 0 . l o g
Unload / var / l o g / Xorg . 0 . l o g
3.2 Xorg ou/et HAL
Xorg u t i l i s e d e s o r m a i s HAL pour d é t e r m i n e r l a c o n f i g u r a t i o n . Ce q u i a pour
conséquences :
* De s i m p l i f i e r l a v i e pour l e s débutants , ou de ceux q u i ne v e u l e n t
pas s e p r e n d r e l a t ê t e . ; − )
* De r e n d r e l e f i c h i e r xorg . c o n f i n u t i l e , s i s o u h a i t é .
* Que l a commande x o r g c o n f i g , p e r m e t t a n t de g é n é r e r l e f i c h i e r de
c o n f i g u r a t i o n , a é t é supprimée .
S i v o t r e m a t é r i e l n ' a r i e n de s p é c i a l , que vous c o n n a i s s e z mal v o t r e
c o n f i g u r a t i o n m a t é r i e l l e ou que vous n ' ê t e s pas s û r de vos paramètres ,
i l e s t t r è s probablement p l u s prudent e t s û r de l a i s s e r f a i r e HAL. La
c o n f i g u r a t i o n ne s e r a peut ê t r e pas o p t i m a l e ou p a r f a i t e , mais e l l e
fonctionnera .
#U t i l i s e r x o r g . conf , comme a v a n t
Pour c e f a i r e , en r o o t , i l f a u t a j o u t e r à c e d e r n i e r dans l a s e c t i o n
S e r v e r L a y o u t l e s deux o p t i o n s s u i v a n t e s :
Option
" AllowEmptyInput " " f a l s e "
Option
" AutoAddDevices " " f a l s e "
La p r e m i è r e s e r t à s e d é b a r r a s s e r du warning , c e q u i provoque un "
bégaiement " du c l a v i e r ( é c r i t t r o i s f o i s l a même l e t t r e pour chaque
t o u c h e tapée , ou s u i v a n t l e s c a s e s t a u s s i a l é a t o i r e ) . La s e c o n d e s e r t
à c o r r i g e r l e " bégaiement " du c l a v i e r a p r è s s u p p r e s s i o n du warning .
#C o n f i g u r e r HAL
Ca s e p a s s e i c i , e t c ' e s t un peu p l u s complique .
/etc/hal/ f d i / policy /
36
CHAPTER 3. XORG - CLAVIER SOURIS TOUCHPAD
3.3 Numlockx conicting
Fine c r e a t e your own :
xsetnumlock . c :
#i n c l u d e <X11/ e x t e n s i o n s / XTest . h>
#i n c l u d e <X11/ keysym . h>
/
*
Requires :
a p t i t u d e i n s t a l l l i b x c b −keysyms1 −dev l i b x t s t −dev
Compiled with :
g c c − I / u s r / i n c l u d e /X11 −L/ u s r / l i b /X11 −o xsetnumlock xsetnumlock . c −lX11 −
l X t s t */
i n t main ( v o i d )
{
D i s p l a y * d i s p = XOpenDisplay (NULL) ;
if
( d i s p == NULL)
return
1;
XTestFakeKeyEvent ( d i s p , XKeysymToKeycode ( d i s p , XK_Num_Lock ) ,
True , CurrentTime ) ;
XTestFakeKeyEvent ( d i s p , XKeysymToKeycode ( d i s p , XK_Num_Lock ) ,
F a l s e , CurrentTime ) ;
XCloseDisplay ( disp ) ;
return
}
0;
a p t i t u d e i n s t a l l l i b x c b −keysyms1 −dev l i b x t s t −dev
g c c − I / u s r / i n c l u d e /X11 −L/ u s r / l i b /X11 −o xsetnumlock xsetnumlock . c −lX11 −
lXtst
sudo cp xsetnumlock / u s r / b i n
a p t i t u d e remove l i b x c b −keysyms1 −dev l i b x t s t −dev
3.4 X11 working x11 without hald/dbus
Voi p l u s haut pour un peu p l u s de d e t a i l s
Bien m e t t r e c e s deux o p t i o n s pour que l a c o n f i g u r a t i o n d e s d e v i c e s de xorg
. c o n f s o i e n t p r i s e s en compte ( s i n o n , c o n f i g u r e r HAL)
Section " ServerFlags "
(...)
Option " AllowEmptyInput " " o f f "
Option " AutoAddDevices " " o f f "
EndSection
3.5 Ctrl alt Backspace to restart X server
#La s o l u t i o n f a c i l e Dans ~/ . x i n i t r c
setxkbmap − o p t i o n − o p t i o n t e r m i n a t e : c t r l _a l t_bksp
E. Branlard
37
CHAPTER 3. XORG - CLAVIER SOURIS TOUCHPAD
%%
%%
%%OU
#f a i r e c e s deux manip dans l e x o r g . c o n f
Section " ServerFlags "
(...)
Option "DontZap" " o f f "
EndSection
Section " InputDevice "
(...)
Option " XkbOptions " " t e r m i n a t e : c t r l _a l t_bksp "
EndSection
3.6 QWERTY et accents
Sous x f c e i l n ' y a pas moyen de c o n f i g u r e r compose dans l e s o p t i o n s du
clavier :
i l f a u t m o d i f i e r l e / e t c /X11/ xorg . c o n f
e t a j o u t e r a l a s e c t i o n i n p u t d e v i c e keyboard
Option
" XkbOptions "
" compose : r a l t "
Ou t o u t a u t r e o p t i o n pour l a t o u c h e compose r a l t , lwin , c a p s e t c . . .
Un a c c e n t s e f a i t a l o r s en tappant Compose , p u i s en l a r e l a c h a n t p u i s
apostrophe , puis e
A t t e n t i o n : a c c e n t c i r c o n f l e x e : compose , s h i t +6 ( ^ ) + e
#OU l a s o l u t i o n f a c i l e Dans ~/ . x i n i t r c
setxkbmap − o p t i o n − o p t i o n compose : r a l t
3.7 Get keyboard keycodes
Se s e r v i r de l a commande
xev : pour a v o i r l e s k e y c o d e s
# Mute
xmodmap −e ' keycode 160 = XF86AudioMute '
3.8 Cong souris logitech lx8 left handed
h t t p : // tuxtweaks . com/ 2008 / 09 /how−to −south −paw− l o g i t e c h −lx8 −in − l i n u x /
# t o u t d ' abord l a c o n f i g de b a s e de x o r g . c o n f
Section " InputDevice "
Identifier
" C o n f i g u r e d Mouse"
Driver
"mouse"
Option
" CorePointer "
Option
" D ev i ce " " / dev / i n p u t / mice "
Option " P r o t o c o l " " ExplorerPS / 2 "
Option " ZAxisMapping " " 4 5 "
Option " ButtonMapping " " 1 2 3 8 9 6 7 " #RH
# Option " ButtonMapping " "3 2 1 9 8 6 7" #LH
EndSection
# E n s u i t e g e r e l ' a l t e r n a n c e avec xmodmap dans . b a s h r c
# a l i a s e s f o r l e f t and r i g h t handed L o g i t e c h LX8 mice
E. Branlard
38
CHAPTER 3. XORG - CLAVIER SOURIS TOUCHPAD
alias
alias
lhm='xmodmap −e " p o i n t e r = 3 2 1 4 5 7 6 8 9 " '
rhm='xmodmap −e " p o i n t e r = 1 2 3 4 5 6 7 8 9 " '
## f a i r e marcher l e s c o l l h o r i z o n t a l
#h t t p : // t u x t w e a k s . com/ 2008 / 12 / update − l o g i t e c h −l x 8 −in −ubuntu /
3.9 Mise en veille et hibernation qui chie, avec cartes Nvidia
R a j o u t e r dans l a s e c t i o n d e v i c e de / e t c /X11/ xorg
Option
"NvAGP" " 1 "
Option
"NoLogo" " t r u e "
Peut e t r e M o d i f i e r / e t c / a c p i / s l e e p . sh
# Ajout s i n o n c r a s h on resume . Copie l i g n e de h i b e r n a t i o n . sh
# Unset v i d e o p o s t i n g
unset POST_VIDEO
S i l a mise en v e i l l e s u r ram ( s u s p e n d r e ) ou s u r d i s q u e ( h i b e r n e r ) ne
f o n c t i o n n e pas , i l e s t p o s s i b l e d ' u t i l i s e r une a u t r e méthode u t i l i s a n t
l e paquet apt : // uswsusp .
h t t p : //www. s h a l l o w s k y . com/ l i n u x / x−s c r e e n −b l a n k i n g . html
3.10 Monitor going to sleep after 10 minutes - Power management
I t i s p r o b a b l y DPMS which i s d o i n g t h i s .
check x s e t −q
Standby : 60 ( i n s e c o n d s ) . . .
# easy
You can s e t t h i s up by i n s t a l l i n g x s c r e e n s a v e r and r u n n i n g x s c r e e n s a v e r −
demo on advanced tab
But t h e r e s h o u l d be a s m a r t e r way . . .
# On t h e f l y ( b e f o r e w a t c h i n g a movie )
D i s a b l e dpms
x s e t −dpms
Put i t back with
x s e t +dpms
x s e t −dpms
#
x s e t +dpms
#
xset s o f f
#
x s e t s 150
#
x s e t dpms 300 600 900
seconds )
x s e t dpms f o r c e standby
x s e t dpms f o r c e suspend
x s e t dpms f o r c e o f f
E. Branlard
D i s a b l e DPMS
Enable DPMS
Disable screen blanking
Blank t h e s c r e e n a f t e r 150 s e c o n d s
# S e t s t a n d b y , suspend , & o f f t i m e s ( i n
# I m m e d i a t e l y go i n t o s t a n d b y mode
# I m m e d i a t e l y go i n t o suspend mode
# I m m e d i a t e l y t u r n o f f t h e monitor
39
CHAPTER 3. XORG - CLAVIER SOURIS TOUCHPAD
x s e t −q
# Query c u r r e n t s e t t i n g s
#
C o n f i g u r i n g DPMS i n xorg . c o n f i n s e c t i o n Monitor ( times a r e i n minutes ! ! ! )
Option
"DPMS"
Option
" BlankTime "
"4"
Option
" StandbyTime "
"0"
Option
" SuspendTime "
"0"
Option
" OffTime "
"5"
E. Branlard
40
Chapter
4
XFCE - xfce4
4.1 Cleaning up Xfce menu - applications wine
These menu a r e i n t h e s e f o l d e r s
~/ . l o c a l / s h a r e / a p p l i c a t i o n s / wine
*
~/ . l o c a l / s h a r e / desktop − d i r e c t o r i e s / wine −
~/ .
c o n f i g / menus / a p p l i c a t i o n s −merged / wine −*
. l o c a l / s h a r e / desktop − d i r e c t o r i e s
I f your wine a p p l i c a t i o n s go i n t o Other menu i n s t e a d o f Wine you a r e
m i s s i n g a menu c o n f i g f i l e which i s not re − c r e a t e d by s i m p l y re −
i n s t a l l i n g wine package .
. c o n f i g / menus
c r e a t e a f o l d e r named a p p l i c a t i o n s −merged
and i n s i d e a t e x t f i l e with wine −Programs . menu
with t h e f o l l o w i n g t e x t :
< !DOCTYPE Menu PUBLIC "−// f r e e d e s k t o p //DTD Menu 1 . 0 //EN"
" h t t p : //www. f r e e d e s k t o p . o r g / s t a n d a r d s /menu−s p e c /menu − 1 . 0 . dtd ">
<Menu>
<Name>A p p l i c a t i o n s </Name>
<Menu>
<Name>wine −wine</Name>
<D i r e c t o r y >wine −wine . d i r e c t o r y </ D i r e c t o r y >
<Menu>
<Name>wine −Programs</Name>
<D i r e c t o r y >wine −Programs . d i r e c t o r y </ D i r e c t o r y >
<I n c l u d e >
<Filename>wine −Programs −Wenlin . desktop</ Filename>
</ I n c l u d e >
</Menu>
</Menu>
</Menu>
41
CHAPTER 4. XFCE - XFCE4
4.2 Understanding Mimetypes
~/ . l o c a l / s h a r e /
~/ . l o c a l /mime
4.3 Command for Toggle Desktop
#! / b i n / sh
i f xprop − r o o t
_NET_SHOWING_DESKTOP| e g r e p '= 1 ' ;
wmctrl −k o f f ;
then
else
wmctrl −k on ;
fi
4.4 Notications
sudo a p t i t u d e i n s t a l l l i b n o t i f y −b i n
send n o t i f i c a t i o n t o a n o t i f i c a t i o n daemon : x f c e 4 − n o t i f y d par exemple
n o t i f y −send j d g h j d f h
du − c h s %N | x a r g s −0 n o t i f y −send − t 2000 − i o p e n o f f i c e o r g −20− d a t a b a s e
ffmpeg − i %f 2>&1 | g r e p Stream | awk −F , ' { p r i n t $ 1 " \n
"$2 $3
" $ 5 } ' | x a r g s −0 n o t i f y −send − t 2000 − i gnome−volume− c o n t r o l
awk
−F , ' { p r i n t
$ 1 " \n
"$2
$ 3 $ 4 " \n
$ 4 " \n
" $ 5 } ' Test
4.5 Thunar - User customed actions
S t o r e d i n ~/ . c o n f i g / Thunar / uca . xml
mine : l a t e x c l e a n , To mp3 , Zip i t ! , New f o l d e r , I n s t a l l package , Eps2pdf ,
terminal Fichier
(How Big t h e s e l e c t i o n )
h t t p : // forums . d e b i a n . n e t / v i e w t o p i c . php? f =20&t =49558
4.6 Astuce XFCE : transparent background for panel
patch :
h t t p : // forum . x f c e . o r g / i n d e x . php? t o p i c = 4 7 2 1 . 0 ; prev_next=prev#new
sudo a p t i t u d e i n s t a l l l i b e x o −0.3 − dev l i b x f c e g u i 4 −dev xorg −dev l i b g t k 2 .0 −
dev l i b x f c e 4 u t i l −dev libwnck −dev
E. Branlard
42
CHAPTER 4. XFCE - XFCE4
4.7 Astuce XFCE : Handle acpi event for power button, show Xfce
logout options
I f you would l i k e t h e x f c e logout menu t o show up when you p r e s s your
power button , and your machine has a c p i support , then do t h e f o l l o w i n g :
*
sudo vim
/ e t c / a c p i / e v e n t s / powerbtn
# / e t c / a c p i / e v e n t s / powerbtn
# This i s c a l l e d when t h e u s e r p r e s s e s t h e power b u t t o n and c a l l s
# / e t c / a c p i / powerbtn . sh f o r f u r t h e r p r o c e s s i n g .
# O p t i o n a l l y you can s p e c i f y t h e p l a c e h o l d e r %e . I t w i l l p a s s
# t h r o u g h t h e whole k e r n e l e v e n t message t o t h e program you ' ve
# specified .
# We need t o r e a c t on " b u t t o n power . * " and " b u t t o n / power . * " b e c a u s e
# of k e r n e l changes .
e v e n t=button [ / ] power
a c t i o n=/ u s r / l o c a l / s b i n / x f c e 4 −shutdown−as − u s e r . sh
*
sudo vim
/ u s r / l o c a l / s b i n / x f c e 4 −shutdown −as − u s e r
. sh
#! / b i n / sh
# x f c e 4 −shutdown −as −u s e r . sh
#
# Check how many u s e r s are c u r r e n t l y l o g g e d i n t o X.
# I f o n l y one u s e r i s l o g g e d in , run a s c r i p t which s e t s
# up t h e environment t o c a l l x f c e 4 − s e s s i o n − l o g o u t .
LOGGED_IN_USER=` l s − t r l /tmp/ . ICE−unix / | t a i l −n −1 | c u t −d ' ' − f3 `
NUM_X_USERS=` echo $LOGGED_IN_USER | wc − l `
if
[
$NUM_X_USERS −eq 1 ] ; then
sudo −H −u $LOGGED_IN_USER / u s r / l o c a l / s b i n / x f c e 4 −u s e r − s e s s i o n −shutdown
. sh
fi
* sudo vim
/ u s r / l o c a l / s b i n / x f c e 4 −u s e r − s e s s i o n −shutdown
. sh
#! / b i n / sh
# x f c e 4 −user − s e s s i o n −shutdown . sh
#
# S e t up t h e environment so t h a t DISPLAY and
# SESSION_MANAGER are v a l i d , and x f c e 4 − s e s s i o n − l o g o u t can run
HOST=`hostname `
SESSION_ID=` l s − t /tmp/ . ICE−unix / | head −n1 `
# Note t h a t d i s t r o s use d i f f e r e n t s y n t a x f o r t h e SESSION_MANAGER v a r i a b l e
( t h i s s c r i p t has Debian ' s format ) .
# I f t h i s does not work , t h e n t r y s o m e th i n g l i k e SESSION_MANAGER=" l o c a l /$
HOST:@/ tmp / . ICE−u n i x /$SESSION_ID"
# i n s t e a d . You can a l w a y s f i n d t h e c o r r e c t format f o r your d i s t r i b u t i o n by
looking at the
# v a l u e o f SESSION_MANAGER i n a X s e s s i o n .
E. Branlard
43
CHAPTER 4. XFCE - XFCE4
DISPLAY=:0 SESSION_MANAGER=" l o c a l /$HOST: /tmp/ . ICE−unix /$SESSION_ID"
b i n / x f c e 4 − s e s s i o n −logout
/usr/
4.8 Xubuntu et programme au demarrage de session
malgré l a c a se d é c o c h é e dans " s e s s i o n s e t démarrage " du g e s t i o n n a i r e de
p a r a m è t r e s de x f c e , t o u s l e s programmes r e v e n a i e n t à l ' o u v e r t u r e de
session .
j ' a i e f f e c t u é l e s o p é r a t i o n s s u i v a n t e s e t t o u t e s t r e n t r é dans l ' o r d r e :
dans mon r é p e r t o i r e p e r s o :
1 ) j ' a i supprimé l e contenu du r é p e r t o i r e . c a c h e / s e s s i o n s
2 ) j ' a i é d i t é l e f i c h i e r . c o n f i g / x f c e 4 − s e s s i o n / x f c e 4 − s e s s i o n . r c pour
remplacer :
SaveOnExit=true
par
SaveOnExit= f a l s e
4.9 Se passer de keytouch - utiliser xfce
%%
%
Avec a l s a m i x e r ( avec p u l s e a u d i o ! ! ! l ' o p t i o n −c 0 e s t r e q u i s e ( d e f a u l t
device ) )
amixer −c 0 s s e t Master t o g g l e
amixer −c 0 s s e t Master 1− unmute
amixer −c 0 s s e t Master 1+ unmute
%%
%
Avec aumix ( mieux avec p u l s e a u d i o ? ? ? )
aumix −v+1
aumix −v−1
%%
%
Avec a l s a m i x e r
#t o g g l e Mute
amixer s s e t Master t o g g l e
#d e c r e a s e
amixer s s e t Master 1− unmute
#i n c r e a s e
amixer s s e t Master 1+ unmute
4.10 xfce shortcuts are stored in
~/ .
c o n f i g / x f c e 4 / x f c o n f / x f c e −p e r c h a n n e l −xml / x f c e 4 −keyboard − s h o r t c u t s . xml
and t h e r e r a r e p l e n t y o f o t h e r c o o l f i l e s t h e r e
4.11 Equivalent win split revolution avec wmctrl - raccourcis clavier
xfce
Les r a c c o u r c i s c l a v i e r x f c e s o n t s t o c k e s dans :
. c o n f i g / x f c e 4 / x f c o n f . . . . s h o r t c u r t s . xml
E. Branlard
44
CHAPTER 4. XFCE - XFCE4
Modifier le f i c h i e r xfce
. config/xfce4/xfconf . . . .
s h o r t c u r t s . xml
sudo a p t i t u d e i n s t a l l wmctrl
TopLeft :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 1 , 8 3 , 0 , 6 6 4 , 4 6 0
TopRight :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 0 , 7 4 5 , 0 , 6 6 4 , 4 6 0
Bottom L e f t :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 1 , 8 3 , 4 4 4 , 6 6 4 , 4 4 4
Bottom Right :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 0 , 7 4 5 , 4 4 5 , 6 6 4 , 4 4 4
bottom :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 0 , 8 3 , 4 4 5 , 1 3 2 2 , 4 4 4
top :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 0 , 8 3 , 0 , 1 3 2 2 , 4 6 0
left :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 1 , 8 3 , 0 , 6 6 4 , 8 8 6
right :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 0 , 7 4 5 , 0 , 6 6 4 , 8 8 6
Middle :
wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ; wmctrl − r :
ACTIVE : −e 0 , 8 3 , 0 , 1 3 2 2 , 8 9 8
E. Branlard
45
CHAPTER 4. XFCE - XFCE4
Modifier le f i c h i e r xfce
. config/xfce4/xfconf . . . .
s h o r t c u r t s . xml
<c h a n n e l name=" x f c e 4 −keyboard − s h o r t c u t s " v e r s i o n=" 1 . 0 ">
<p r o p e r t y name="commands" type="empty">
<p r o p e r t y name=" d e f a u l t " type="empty">
<p r o p e r t y name="& l t ; Alt&g t ; F2" type="empty" />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ; D e l e t e " type="empty" />
<p r o p e r t y name=" XF86Display " type="empty" />
<p r o p e r t y name=" P r i n t " type="empty" />
<p r o p e r t y name="& l t ; Alt&g t ; P r i n t " type="empty" />
</ p r o p e r t y >
<p r o p e r t y name=" custom " type="empty">
<p r o p e r t y name="& l t ; Alt&g t ; F2" type=" s t r i n g " v a l u e=" x f r u n 4 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ; D e l e t e " type=" s t r i n g "
v a l u e=" x f l o c k 4 " />
<p r o p e r t y name=" XF86Display " type=" s t r i n g " v a l u e=" xrandr −−auto " />
<p r o p e r t y name=" o v e r r i d e " type=" b o o l " v a l u e=" t r u e " />
<p r o p e r t y name="XF86AudioMute" type=" s t r i n g " v a l u e=" aumix −v0 " />
<p r o p e r t y name=" XF86AudioRaiseVolume " type=" s t r i n g " v a l u e=" aumix −v
+10" />
<p r o p e r t y name="& l t ; C o n t r o l&g t ; Escape " type=" s t r i n g " v a l u e=" x f c e 4 −
popup−menu" />
<p r o p e r t y name="& l t ; Meta&g t ; F1" type=" s t r i n g " v a l u e=" x f h e l p 4 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Meta&g t ; D e l e t e " type=" s t r i n g "
v a l u e=" x f l o c k 4 " />
<p r o p e r t y name="& l t ; Meta&g t ; F2" type=" s t r i n g " v a l u e=" x f r u n 4 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Meta&g t ; Escape " type=" s t r i n g "
v a l u e=" x k i l l " />
<p r o p e r t y name="XF86AudioLowerVolume" type=" s t r i n g " v a l u e=" aumix −v
−10" />
<p r o p e r t y name="& l t ; Super&g t ; r " type=" s t r i n g " v a l u e=" xterm − f a
Monospace − f s 11 − f g &quot ; g r e e n&quot ; −bg &quot ; b l a c k&quot ; " />
<p r o p e r t y name="& l t ; Super&g t ; e " type=" s t r i n g " v a l u e=" thunar " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_1 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 0 , 0 , 4 4 5 , 6 4 4 , 4 3 0 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_9 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 0 , 7 3 8 , 0 , 6 4 4 , 4 3 0 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_4 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 0 , 0 , 0 , 6 4 4 , 8 7 6 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_2 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 0 , 7 3 8 , 4 4 5 , 1 2 9 8 , 4 3 0 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_3 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 0 , 7 3 8 , 4 4 5 , 6 4 4 , 4 3 0 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_8 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 1 , 0 , 0 , 1 2 9 8 , 4 3 0 " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_7 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 1 , 1 , 0 , 6 4 4 , 4 3 0 " />
E. Branlard
46
CHAPTER 4. XFCE - XFCE4
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_5 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b add , maximized_v e r t , maximized_h o r z " />
<p r o p e r t y name="& l t ; C o n t r o l&g t ;& l t ; Alt&g t ;KP_6 " type=" s t r i n g " v a l u e=
" wmctrl − r : ACTIVE : −b remove , maximized_v e r t , maximized_h o r z ;
wmctrl − r : ACTIVE : −e 0 , 7 3 8 , 0 , 6 4 4 , 8 7 6 " />
</ p r o p e r t y >
</ p r o p e r t y >
4.12 Applications pour environnement xfce sans dependances gnome
ou kde
MP3 p l a y e r : xmms l i s t e n banshee quod− l i b e t rhytmbox s o n a t a
amarok
xfce4
x f c e 4 − e x t r a s / thunar −volman
x f c e 4 −e x t r a s / x f c e 4 −s c r e e n s h o o t e r
xfburn : gravure
x a r c h i v e r s q u e e z e : a r c h i v e management
xfmedia : multimedia p l a y e r −> n u l
Image v i e w e r
g p i c v i e w > OK (mon p r e f e r e )
mirage −> b o f
r i s t r e t t o −> n u l
L i f e r e a : Flux RSS
web b r o w s e r :
m i d o r i −> ok , but b o f
khazeakaze
x f b i b : e d i t BibTeX f i l e s ( f o r u s e with LyX) ,
l y x : between word and l a t e x ? ? ? ? ?
emelfm2 enca : a l t e r n a t i v e t o thunar , l i k e t o t a l commander
catfish : f i l e searching tool
HardInfo ( sys −apps / h a r d i n f o ) −− System P r o f i l e r and Benchmark
q a l c u l a t e −gtk q a l c u l a t e −b a s e s q a l c u l a t e −c u r r e n c y q a l c u l a t e − u n i t s
EasyTAG ( media−sound / e a s y t a g ) −− U t i l i t y f o r e d i t i n g MP2, MP3, MP4, FLAC,
Ogg and o t h e r media t a g s
xfmedia o r :
haaw ! Media P l a y e r ( media−v i d e o /whaawmp) −− A l i g h t w e i g h t a u d i o / v i d e o
p l a y e r u s i n g Gstreamer
4.13 Astuce XFCE : How to include all application while switching
windows
There a r e some hidden o p t i o n with Xfce t h a t a l l o w s t h e p a n e l a s w e l l a s
apps l i k e Gkrellm t o be i n c l u d e d while you s w i t c h from one window t o
a n o t h e r with t h e Alt+Tab s h o r t c u t .
E. Branlard
47
CHAPTER 4. XFCE - XFCE4
Just e d i t the f i l e
~/ .
c o n f i g / x f c e 4 / xfwm4 / xfwm4rc and add t h e l i n e below
c y c l e_minimum= f a l s e
E. Branlard
48
Chapter
5
SYSTEM
5.1 Password protect single user mode
When b o o t i n g i n t o s i n g l e u s e r mode you w i l l not be prompted f o r t h e r o o t
password . This i s something e v e r y a t t a c k e r knows and p r a y s on once he
has g a i n e d p h y s i c a l a c c e s s t o you box . So what do you do ?
su : S : wait : / s b i n / s u l o g i n
to / etc / i n i t t a b
5.2 Turn o php expose
e d i t php . i n i , s e a r c h f o r e x p o s e and t u r n i t o f f
sudo vim / e t c / php5 / apache2 / php . i n i
5.3 Heure machine exacted - NTP daemon
i n s t a l l e r ntp
5.4 Increase password strencgth with PAM cracklib or passwdqc
a p t i t u d e i n s t a l l libpam −passwdqc
5.5 Init Boot sequence messages in color - [ok]
h t t p : // ubuntuforums . o r g / showthread . php? t =50054
Ed it / l i b / l s b / i n i t − f u n c t i o n s
Find t h e l o g_end_msg ( ) function , a l l t h e way a t t h e bottom o f t h e f i l e
− Add GREEN=` $TPUT s e t a f 2 ` below RED=` $TPUT s e t a f 1 `
− I n s t e a d o f echo " . " :
echo " $UP$END[ $ {GREEN} ok $ {NORMAL} ] "
Un peu p l u s d ' a i d e :
l o g_b e g i n_msg ( ) {
49
CHAPTER 5. SYSTEM
if
[ −z " $ {1: − } " ] ;
return 1
then
fi
if
l o g_u s e_f a n c y_output ; then
GREEN=` $TPUT s e t a f 2 `
NORMAL=` $TPUT op `
else
GREEN= ' '
NORMAL= ' '
fi
−n "
#echo −n "
echo
}
*
$NORMAL[ $GREEN $NORMAL]
$@"
$@"
l o g_u s e_f a n c y_output ; then
RED=` $TPUT s e t a f 1 `
GREEN=` $TPUT s e t a f 2 `
YELLOW=` $TPUT s e t a f 3 `
NORMAL=` $TPUT s e t a f 7 `
BOLD=` $TPUT b o l d `
UNBOLD=` $TPUT rmso `
COLS=$ ( $TPUT c o l s )
COL=$ ( ( $COLS− 8) )
UP=$ ( $TPUT cuu1 )
END=$ ( $TPUT hpa $COL)
START=$ ( $TPUT hpa 0 )
if
#
#
#
else
RED= ' '
GREEN= ' '
YELLOW= ' '
NORMAL= ' '
fi
−eq 0 ] ; then
/ b i n /echo −e " $START$NORMAL[ $ {GREEN} ok $ {NORMAL} ] "
e l i f [ $ 1 −eq 255 ] ; then
/ b i n /echo −e " $START$NORMAL[ $ {YELLOW}warn $ {NORMAL} ] "
if
[
else
$1
#/ b i n / echo −e " $END$NORMAL[ $ {RED} f a i l $ {NORMAL} ] "
/ b i n /echo −e " $START$NORMAL[ $ {RED} f a i l $ {NORMAL} ] "
fi
5.6 Default User directories
See :
/ e t c / xdg / u s e r − d i r s
. conf
And mainly , e d i t :
$ {XDG_CONFIG_HOME: −~/ . c o n f i g } / u s e r − d i r s . d i r s
This can be u s e f u l
for
Desktop , Templates , Images , Download e t c . . .
5.7 Nettoyage des log automatique
E. Branlard
50
CHAPTER 5. SYSTEM
l o g r o t a t e s e c h a r g e de ca , par d e f a u l t en c r o n . d a i l y . Perso j e l e f o u en
c r o n . weekly .
Modifier l e /etc/ logrotate . conf
5.8 Une systeme plus reactif
5.9 Swappiness
Système avec beaucoup de mémoire v i v e : d i m i n u e r l a v a l e u r pour l i m i t e r
l e s a c c è s d i s q u e s e t l a c h a r g e p r o c e s s e u r , au p r i x d ' une u t i l i s a t i o n de
l a mémoire p l u s i m p o r t a n t e .
La v a l e u r par d é f a u t e s t 6 0 , s i vous d i s p o s e z de p l u s de 1Go de mémoire n '
h é s i t e z pas à d e s c e n d r e à 2 0 , v o i r a u s s i bas que 5 au− d e s s u s de 2Go . De
t o u t e f a ç o n même s i l a v a l e u r 0 e s t u t i l i s é e e t que du swapping s o i t
n é c e s s a i r e , l e noyau o u t r e p a s s e r a l e r é g l a g e , simplement i l ne l e f e r a
qu ' en d e r n i e r r e c o u r s e t non s y s t ém a t i q u e m e n t en avance . J ' u t i l i s e l a
v a l e u r 10 q u i me donne s a t i s f a c t i o n , l a mémoire v i v e e s t p l u s u t i l i s é e
e t j e n ' a i j a m a i s de swap , l e s a p p l i c a t i o n s e t l ' environnement de
bureau s o n t p l u s r é a c t i f s , en p a r t i c u l i e r a p r è s une c o u r t e p é r i o d e d '
inutilisation .
Pour c h a n g e r c e r é g l a g e é d i t e z l e f i c h i e r / e t c / s y s c t l . c o n f en r o o t e t
a j o u t e z à l a f i n du f i c h i e r l e s l i g n e s :
#s w a p p i n e s s p e r s o
vm . s w a p p i n e s s =10
pour c h o i s i r une v a l e u r de 1 0 .
Pour r e n d r e l e changement e f f e c t i f
#
/sbin/ s y s c t l
utilisez :
−p
5.10 Optimisation - Date de modif
Pour c e q u i e s t d e s o p t i o n s p r o p r e s au système d ' e x p l o i t a t i o n , avec un
système j o u r n a l i s é comme e x t 3 ou r e i s e r f s l e système va e n r e g i s t r e r l '
h e u r e p r é c i s e d ' a c c è s à un f i c h i e r l o r s de s a c r é a t i o n , m o d i f i c a t i o n ou
simplement de son o u v e r t u r e . Ce d e r n i e r p o i n t e s t un g â c h i s de
r e s s o u r c e s s u r un p o s t e de t r a v a i l ( s u r un s e r v e u r i l peut s e j u s t i f i e r
par l a n é c e s s i t e r de p o u v o i r e f f e c t u e r d e s c o n t r ô l e s s u r l e s a c c è s à
un f i c h i e r s donné , mais l e p r e m i e r p i r a t e venu m o d i f i a n t c e paramètre d
' un s i m p l e " touch " on peut d o u t e r de son e f f i c a c i t é . . . ) . Pour
s u p p r i m e r c e comportement a j o u t e z l ' o p t i o n noatime dans v o t r e f i c h i e r /
e t c / f s t a b . Un exemple de l i g n e s m o d i f i é e s :
/ dev / sda1
E. Branlard
/
ext3
d e f a u l t s , noatime , e r r o r s=remount−r o 0
1
51
CHAPTER 5. SYSTEM
C e t t e o p t i o n e s t a p p l i c a b l e à l a p a r t i t i o n r o o t e t /home , mais é g a l e m e n t
aux a u t r e s p a r t i t i o n s c o n t e n a n t d e s données s i vous avez un
p a r t i t i o n n e m e n t p l u s é l a b o r é ( / u s r ; /tmp ; . . . ) , l ' o p t i o n n ' e s t pas
u t i l e s u r / boot , e t pas u t i l i s a b l e s u r / swap .
Comme a l t e r n a t i v e , l ' o p t i o n r e l a t i m e e s t un bon compromis . C e r t a i n s
programmes comme "mutt" ( c l i e n t de c o u r r i e l en l i g n e de commande )
peuvent ê t r e p e r t u r b é s par " noatime " , c e q u i ne s e r a pas l e c a s de "
relatime " .
5.11 Readahead
Readahead e s t un programme conçu pour a c c é l é r e r l e chargement d ' a u t r e s
programmes , p l u s p a r t i c u l i è r e m e n t pendant l a s é q u e n c e de démarrage . À
n o t e r que l e paquet " readahead " semble ê t r e en v o i e d ' abandon dans
Debian e t Ubuntu . Sur Debian i l e s t r e m p l a c é par " readahead − f e d o r a " à
p a r t i r de Squeeze .
Pour que " readahead [ − f e d o r a ] " f o n c t i o n n e v o t r e noyau d o i t ê t r e c o m p i l é
avec l e s u p p o r t du système d ' a u d i t . C' e s t l e c a s d e s noyaux par d é f a u t
Debian . S i vous c o m p i l e z vous même v o t r e noyau v é r i f i e z avec :
$
g r e p CONFIG_AUDIT=
/ boot / c o n f i g −$ ( uname
−r )
Après son i n s t a l l a t i o n , i l f a u t l u i p e r m e t t r e de " p r o f i l e r " l a s é q u e n c e de
démarrage .
Sur grub2 :
*
*
*
*
S é l e c t i o n n e z l ' e n t r é e c o r r e s p o n d a n t à v o t r e système ,
avec l a t o u c h e [ e ] .
P l a c e z vous s u r l a l i g n e " l i n u x " ,
et
et
éditez la
éditez la directement .
A j o u t e z en f i n de l a l i g n e " l i n u x " l ' o p t i o n p r o f i l e .
P o u r s u i v e z l e démarrage avec [ c t r l ] [ x ]
C e c i n ' e s t p l u s n é c e s s a i r e avec " readahead − f e d o r a " , d e s t â c h e s " c r o n " s e
c h a r g e a n t de l a c o n f i g u r a t i o n s a n s i n t e r v e n t i o n de l ' u t i l i s a t e u r ( c ' e s t
beau l e p r o g r è s ; − ) )
Le démarrage peut ê t r e s e n s i b l e m e n t p l u s l e n t que l a normal , c e s e r a l '
unique f o i s , l ' o p t i o n " p r o f i l e " que vous avez a j o u t e z aura d i s p a r u au
p r o c h a i n démarrage . Les démarrages s u i v a n t d e v r a i e n t ê t r e p l u s r a p i d e s .
Vous pouvez j e t e r un o e i l aux f i c h i e r s de c o n f i g u r a t i o n dans / e t c /
readahead / ( / e t c / readahead . c o n f pour " readahead − f e d o r a " ) , i l s
c o n t i e n n e n t l a l i s t e d e s e x é c u t a b l e s e t l i b r a i r i e s à pré − c h a r g e r en
c a c h e pour l e démarrage ( f i c h i e r " boot " ) , e t l e f o n c t i o n n e m e n t normal (
f i c h i e r " desktop " ) .
Readahead ne p r é s e n t e aucun danger pour v o t r e système , i l e s t e n c o r e p l u s
e f f i c a c e u t i l i s é c o n j o i n t e m e n t au o p t i o n s s u i v a n t e s :
# echo CONCURRENCY=m a k e f i l e >> / e t c / d e f a u l t / rcS
# aptitude i n s t a l l insserrv
# dpkg − r e c o n f i g u r e i n s s e r v s y s v −r c
E. Branlard
52
CHAPTER 5. SYSTEM
Cela c o n s i s t e à r é o r g a n i s e r t o t a l e m e n t l a s é q u e n c e d ' e x é c u t i o n d e s s c r i p t s
" i n i t " , e t p e r m e t t r e l e u r e x é c u t i o n p a r a l l è l e ( en p a r t i c u l i e r s u r l e s
p r o c e s s e u r s m u l t i c o e u r s ) . S i vous c o n s t a t e z d e s p r o b l è m e s d '
i n i t i a l i s a t i o n de c e r t a i n s s c r i p t s " i n i t " avec c e s r é g l a g e s ( peu
p r o b a b l e ) , f a i t e s un r a p p o r t de bug au mainteneur du paquet en q u e s t i o n
. I l l u i s u f f i t de c o r r i g e r l e s en− t ê t e s d e s s c r i p t " i n i t " .
" readahead " peut ê t r e u t i l i s é c o n j o i n t e m e n t à " u p s t a r t " p r é s e n t é c i −
d e s s o u s , l i s e z / u s r / s h a r e / doc / readahead − f e d o r a /README pour l e s
é v e n t u e l l e s p r é c a u t i o n s ( en p a r t i c u l i e r d é s i n s t a l l e r " a u d i t d " s i
présent ) .
5.12 Informations systeme
lspci
lsusb
5.13 Addressse MAC
sudo i f c o n f i g
Regarder a p r e s HWaddress
5.14 Journaux systemes - bootlog
dmesg
/ var / l o g / kren
. l o g mes sag es . l o g
syslog . log
u t i l e de l e s v o i r avec gnome−system − l o g
B o o t l o g : a l l e r v o i r / e t c / d e f a u l t / b o o t l o g d =Yes
5.15 Bootchart
L ' i n s t a l l e r , p u i s a j o u t e r l ' o p t i o n au k e r n e l dans grub :
k e r n e l / vmlinuz − 2 . 6 . 1 0 r o r o o t=/ dev / hda1 i n i t=/ s b i n / b o o t c h a r t d
Un t a r b a l l e s t g e n e r é dans / var / l o g . en tappant b o o t c h a r t dasn son home ,
un png e s t g e n e r é .
5.16 Add a path to locate
ADD a NETPATH i n t h e f i l e
/ e t c / updatedb
. conf or
/ etc /cron
. daily/locate
5.17 ANSI Escape sequences - escape codes for bashrc and login
E. Branlard
53
CHAPTER 5. SYSTEM
ESC e s t l e c a c t e r e code ACII 27 s o i t en o c t a l 033
L ' i n s e r e r avec vim en mode i n s e r t i o n : C t r l+V C t r l+Esc ( a f f i c h e ^ [ <=>
ESC)
#Les p l u s i m p o r t a n t :
Wherever you s e e '# ' , t h a t s h o u l d be r e p l a c e d by t h e a p p r o p r i a t e number .
ESC [ 2 J
C l e a r s c r e e n and home c u r s o r
ESC [ #; # ; . . . . ; #m
S e t d i s p l a y a t t r i b u t e s where # i s
0 : normal d i s p l a y
1 : bold
4 : underline
5 : blink
2 2 : normal
30 b l a c k f o r e g r o u n d
31 r e d f o r e g r o u n d
32 g r e e n f o r e g r o u n d
33 y e l l o w f o r e g r o u n d
34 b l u e f o r e g r o u n d
35 magenta f o r e g r o u n d
36 cyan f o r e g r o u n d
37 w h i t e f o r e g r o u n d
39 d e f a u l t f o r e g r o u n d
40 b l a c k background
41 r e d background
42 g r e e n background
43 y e l l o w background
44 b l u e background
45 magenta background
46 cyan background
47 w h i t e background
49 d e f a u l t background
#L i s t e c o m p l e t e : h t t p : // i s t h e . com/ chongo / t e c h / comp / a n s i_e s c a p e s . html
5.18 Geeking around with the login prompt - Customization
The l i n e b e f o r e t h e l o g i n i s c o n f i g u r e d i n t h e f i l e
/etc/issue
5.19 A quiet boot with color-coded error messages in Debian
# Less messages :
F i r s t o f a l l , change VERBOSE=y e s t o VERBOSE=no i n / e t c / d e f a u l t / r c S .
This g e t r i d o f some me ssa ges from t h e boot s c r i p t s .
Next , add ' q u i e t ' a s a k e r n e l o p t i o n i n / boot / grub /menu . c f g . This
t e l l t h e k e r n e l and i n i t r a m f s t o be more q u i e t on t h e c o n s o l e .
# Usplash
Last , i n s t a l l t h e u s p l a s h package . This enable c o l o r c o d i n g o f t h e
boot mes sag es . You do not have t o enable t h e s p l a s h s u p p o r t t o g e t
the c o l o r coding .
I f you do want t o enable t h e s p l a s h support , I
recommend i n s t a l l i n g some o t h e r s p l a s h image , f o r example t h e one i n
debian −edu−artwork − u s p l a s h . To enable t h e s p l a s h s u p p o r t add ' s p l a s h '
a s a k e r n e l o p t i o n i n / boot / grub /menu . c f g .
E. Branlard
54
CHAPTER 5. SYSTEM
#a l s o
sudo a p t i t u d e i n s t a l l s t a r t u p m a n a g e r
5.20 Utiliser aptitude
#I n v e r s e s e a r c h t o s e e d e p e n d e n c i e s
a p t i t u d e s e a r c h ' ~ i ~Dbash '
#purge t o u s l e s p a q u e s t q u i s o n t dans l ' e t a t " c " ( d e l e t e d mais
configuration )
a p t i t u d e purge ~c
1 st caractere : state
p : non p r e s e n t s u r l e systeme
i : installe
u : paquet v i r t u e l
c : supprime mais c o n f i g s u r l e system
2 eme : a c t i o n prevue
i : install
d : suppr
p : purger , s u p p r i m e r + s u p p r i m e r c o n f i g
A : i n s t a l l e automatiquement
c l e a n : supprime t o u s l e s p a q u e t s du c a c h e : / var / c a c h e / apt / a r c h i v e s
a u t o c l e a n : supprime s u e l e u m e n t l e s a n c i e n s p a q u e t s
5.21 Bien maitriser ses paquets - application a nvidia
#
/ etc /apt/sources
. list
#/ e t c / a p t / p r e f e r e n c e s
# que l ' on c h e c k avec
apt −c a c h e p o l i c y
a p t i t u d e d i s t −upgrade −d
apt −c a c h e p o l i c y n v i d i a − g l x
apt −c a c h e p o l i c y n v i d i a − k e r n e l −source
dpkg − l | g r e p n v i d i a
apt −g e t
apt −g e t
m−a a− i
apt −g e t
update
i n s t a l l n v i d i a − k e r n e l −source
n v i d i a − k e r n e l −source
i n s t a l l n v i d i a −g l x
5.22 Command to reload fstab
E. Branlard
55
CHAPTER 5. SYSTEM
#t o r e l a o d
mount −a
/ e t c / mtab
and
/etc/fstab
5.23 Changer le nom de votre machine, hostname
sudo vim
/ e t c / hostname
5.24 Rendre clef USB amorcable - partitions, formatage , bootable
h t t p : //www. s y s r e s c c d . o r g / S y s r e s c c d −manual−en_How_t o_ i n s t a l l _SystemRescueCd
_on_an_USB− s t i c k
#a p t i t u d e i n s t a l l f s a r c h i v e r ( j u s t t o c h e c k )
#f s a r c h i v e r p r o b e
# s ' i l y a une p a r t i t i o n
mount − t v f a t / dev / s d f 1 /mnt/ u s b s t i c k
# r e i n i t i a l i z a t i o n de l a t a b l e d e s p a r t i t i o n s
c f d i s k / dev / sdb
Select
type
LBA FAT32
# f o r m a t t i n g and l a b e l l i n g t h e p a r t i t i o n
mkfs . v f a t −F 32 −n PARTITIONNAME / dev / sdb1
%%
%
putting syslinux
# using sy sli nu x for boot
aptitude i n s t a l l syslinux
# c o p y i n g t h e d e f a u l t MBR o f s y s l i n u x
dd i f =/ u s r / s h a r e / s y s l i n u x /mbr . b i n o f=/ dev / sdb
/ u s r / l i b / s y s l i n u x /mbr . b i n
%%
%
Debian : d i r e c t l y with t h e f i l e hd−media / boot . img . gz
z c a t hd−media / boot . img . gz > / dev / sdb1
mount t h e p a r t i t i o n on your USB memory s t i c k ( mount / dev / sda1 /mnt ) and
copy a Debian n e t i n s t o r b u s i n e s s c a r d ISO image t o i t ( p l e a s e n o t e t h a t
t h e f i l e name must end i n . ISO ) .
%%
%#
img f i l e
Even though t h i s image i s a . img f i l e , i t i s gzipped , s o i t n e e d s t o be
e x t r a c t e d t o your t a r g e t volume :
g u n z i p −c FreeNAS−amd64−embedded−xxx . img | dd o f=/ dev / sdb
5.25 Migrer de Ext3 a Ext4
E. Branlard
56
CHAPTER 5. SYSTEM
# References
I n s p i r e de :
h t t p : //www. w e b s t r a t . f r / b l o g /web−t e c h n o l o g y / migrer −s e s − p a r t i t i o n s −ext3 −v e r s
−ext4 −sous −l i n u x −ubuntu
Rescue CD u t i l i s e : ( i l f a u t un v e r s i o n r e c e n t e pour a v o i r l e s u p p o r t e x t 4 )
h t t p : //www. s y s r e s c c d . o r g / S y s r e s c c d −manual−en_How_t o_ i n s t a l l _SystemRescueCd
_on_an_USB− s t i c k
# Intro
Ci− d e s s o u s comment m i g r e r l a p a r t i t i o n systeme du format e x t 3 a e x t 4 .
Pour e v i t e r t o u t e p e r t e de donnee , on va d ' abord t e s t e r s u r une p a r t i t i o n
i n t e r m e d i a i r e , p u i s e n s u i t e recommencer l a meme o p e r a t i o n , de s o r t e qu '
on a t o u j o u r s une p a r t i t i o n avec un system complet .
( s i p a r t i t i o n home s e p a r e e , idem mais moins dur )
# Step 1
P a r t i t i o n systeme : sda3
Avec gparted , c r e e r une p a r t i t i o n e x t 4 a u s s i grande que sda3 −> i c i sda9
# Step 2
Booter s u r un l i v e CD avec s u p p o r t e x t 4 e t grub ( s u r c l e f USB, c ' e s t
beaucoup p l u s r a p i d e ! )
− monter l e s deux p a r t i t i o n s
mount − t e x t 3 / dev / sda3 /mnt/ deb3
mount − t e x t 4 / dev / sda9 /mnt/ deb4
− c o p i e r de l ' un a l ' a u t r e ( v pour v e r s a t i l e ) :
r s y n c −av /mnt/ deb3 /* /mnt/ deb4 /
( Perso , s o u s mon systeme ( pas l e l i v e CD) , j ' a i f a i t l a c o p i e de t o u s l e s
g r o s r e p e r t o i r e s de " / " s a u f / sys , / p r o c e t / dev avec l a commande
cp −a / b i n / boot / var / e t c / / u s r / opt / l i b / media / P a r t i t i o n E x t 4
Le "−a " e s t i m p o r t a n t pour l e s l i e n s s y m b o l i q u e s !
Puis , s o u s l e l i v e CD, j ' a i f i n a l i s é avec un r s y n c . Ca permet de c o n t i n u e r
a b o s s e r s u r son systeme normal pendant l a c o p i e de l a p l u p a r t d e s
f i c h i e r s systemes . )
# S t e p 3 ( Sous l e l i v e CD t o u j o u r s )
− on i n s t a l l l e grub de sda9 dans l e MBR
grub − i n s t a l l −− r o o t − d i r=/mnt/ deb4 / dev / sda
− A c e s t a d e , s i on r e d e m a r r e on aura t o u j o u r s l e systeme p r e c e d e n t , c a r
l e s f i c h i e r s du boot de sda9 s o n t i d e n t i q u e s a ceux de sda3 e t donc
r e f e r e n t au boot de sda3 ( hd0 , 2 ) . Du coup , i l f a u t m o d i f i e r l e f i c h i e r
/mnt/ deb4 / boot /menu . l s t e t r e m p l a c e r l e s ( hd0 , 2 ) par ( hd0 , 8 ) e t sda3
par sda9 .
# S t e p 4 ( Sous l e l i v e CD t o u j o u r s )
on m o d i f i e l e / e t c / f s t a b pour que l a p a r t i t i o n
/
s o i t b i e n sda9
#
−
−
−
Step 5
on r e d e m a r r e
au menu grub , on v e r i f i e que c ' e s t b i e n l e grub de sda9
on v e r i f i e que c ' e s t b i e n l e systeme de sda9 q u i e s t l a n c e e s t pas c e l u i
de sda3
− une f o i s l e system en p l a c e , on f a i t un update −grub .
# Step 6
S i t o u t marche i m p e c c a b l e , on recommence t o u t . On f o r m a t t e sda3 , on c o p i e
de sda9 a sda3 , i n s t a l l e grub e t f s t a b , redemarrage , t e s t s , update −grub
e t on supprime sda9 .
E. Branlard
57
CHAPTER 5. SYSTEM
5.26 Comment savoir si on est 32 ou 64bits
%%
%methode
1
cat / p r o c / c p u i n f o
model name
: AMD Athlon (tm) 64 P r o c e s s o r 3500+
2 ( model name
: I n t e l (R) Atom(TM) CPU N270
p e r l −e ' p r i n t ~ 1 2 3 ; '
4294967172 #32 b i t s
18446744073709551492 #64 b i t s
%%
%methode
%%
%methode
cat
test
.c
@ 1 . 6 0GHz)
3 script C
#i n c l u d e <s t d i o . h>
#i n c l u d e <u n i s t d . h>
i n t main ( v o i d )
{
p r i n t f ( "%l d CPU (%u b i t s ) \n" , s y s c o n f (_SC_NPROCESSORS_ONLN) , 8 *
s i z e o f ( void*) ) ;
return 0 ;
}
g c c −W −Wall −O2
a . out
24 CPU ( 3 2 b i t s )
test
.c
5.27 Exécuter plusieurs versions de Debian avec chroot
h t t p : //www. d e b i a n . o r g / doc / manuals / debian − r e f e r e n c e / ch− t i p s . f r . html
Un environnment c h r o o t Debian peut a i s é m e n t ê t r e c r é é par l a commande
d e b o o t s t r a p de Woody . Par exemple , pour c r é e r un c h r o o t S i d s u r / s i d −
r o o t avec une c o n n e x i o n I n t e r n e t r a p i d e :
main # cd / ; mkdir / s i d − r o o t
main # d e b o o t s t r a p s i d / s i d − r o o t h t t p : // f t p . d e b i a n . org / d e b i a n /
. . . r e g a r d e z l e système s e t é l é c h a r g e r
main # echo " proc − s i d / s i d − r o o t / proc proc none 0 0" >> / e t c / f s t a b
main # mount proc − s i d / s i d − r o o t / proc − t proc
main # cp / e t c / h o s t s / s i d − r o o t / e t c / h o s t s
main # c h r o o t / s i d − r o o t / b i n / bash
c h r o o t # cd / dev ; / s b i n /MAKEDEV g e n e r i c ; cd −
c h r o o t # apt − s e t u p # s e t −up / e t c / a p t / s o u r c e s . l i s t
chroot # v i / etc /apt/sources . l i s t # mettre l a source sur u n s t a b l e
c h r o o t # d s e l e c t # ou a p t i t u d e , i n s t a l l e z mc e t vim : − )
A c e p o i n t , vous d e v r i e z a v o i r un système Debian complètement f o n c t i o n n e l
, avec l e q u e l vous pouvez j o u e r s a n s a v o i r peur de t o u c h e r v o t r e
i n s t a l l a t i o n Debian p r i n c i p a l e .
5.28 Probleme d'heure
# h w c l o c k −r #or h w c l o c k −−show
# h w c l o c k −w #or h w c l o c k −− s y s t o h c
E. Branlard
58
CHAPTER 5. SYSTEM
# h w c l o c k − s #or h w c l o c k −− h c t o s y s
sudo hwclock −− h c t o s y s
hardware
sudo hwclock −− s y s t o h c
systeme
#r e s e t l ' heure s y s t e m e a p a r t i r de l ' heure
#r e s e t l ' heure hardware a p a r t i r de l ' heure
sudo d a t e +%H:%M −−s e t=" 2 1 : 4 2 "
veut
#s e t l ' heure s y s t e m e a c e l l e que l ' on
5.29 Script automatique au demarrage
Sinon , pour qu ' i l s e l a n c e au démarrage , i l f a u t que tu c r é e s un p e t i t
s c r i p t de r i e n du t o u t e t que tu l e m e t t e s dans ton d o s s i e r ou s o n t l e s
s c r i p t s de démarrage . . .
Par exemple , s i l e s c r i p t p l u s haut s ' a p p e l automat−s s h . sh , l e s c r i p t de
demarrage peut ê t r e : ( on l ' a p p e l e r a i n i t −automatssh . sh pour l a s u i t e )
#! / b i n / bash
automat −s s h . sh
Tu l e c o p i e s dans / e t c / i n i t . d /
Tu l u i donnes l e s bons d r o i t s : chmod +x i n i t −automatss . sh
Tu r e p è r e s ton d o s s i e r de demarrage . ( S i tu ne l e c o n n a i s pas , r e g a r d e
dans i n i t t a b , au n i v e a u du r u n l e v e l . )
S i c ' e s t 2 ( c ' e s t mon c a s ) , a l o r s dans / e t c / r c 2 . d / , tu f a i s un l i e n s v e r s
ton s u p e r s c r i p t !
l n −s
/etc/ i n i t
. d / i n i t −automat . sh
/etc/rc2
. d / S90automatssh . sh
( S90 s e r a l e 90 ième s e r v i c e l a n c é , j e mets ça , p a r c e que j e p e n s e que ton
r e s e a u e s t d e j a l a n c é à c e s t a d e du démarrage . . . )
5.30 Bip systeme - tab - arret systeme
%%
%
Method 1
Fermer l e c l a p p e t au PC beep avec a l s a m i x e r
%%
%
Method 2
X command : t o run i n a t e r m i n a l o r put i n . x i n i t r c
xset b o f f
%%
%
Method 3 ( f i r s t check i s lsmod r e t u r n s p c s p k r )
#You can d i s a b l e t h i s by e d i t i n g a f i l e and e n t e r i n g two s i m p l e l i n e s .
sudo vim / e t c / modprobe . d / b l a c k l i s t
# s i l l y s p e a k e r beep
b l a c k l i s t pcspkr
I f you don ' t want t o wait u n t i l a r e b o o t , s i m p l y type :
sudo rmmod p c s p k r
5.31 Congurer son reseau a la main
E. Branlard
59
CHAPTER 5. SYSTEM
#A j o u t e r l ' i n t e r f a c e e t h 0 en dhcp
auto e t h 0
i f a c e e t h 0 i n e t dhcp
/ e t c / network / i n t e r f a c e s
r e d e m a r r e r l e network : / e t c / i n i t . d / n e t w o r k i n g r e s t a r t
r e v e i l l e r l e r e s e a u avec
i f u p eth0
5.32 Conversion UTF8 ISO-8859-1
h t t p : //www. h a y p o c a l c . com/ w i k i /UTF−8_e t_Linux
#i c o n v
i c o n v − f i s o −8859 −1 − t u t f −8 <i n >out
# v e r s UTF−8
i c o n v − f u t f −8 − t i s o −8859 −1 <i n >out
# v e r s l a t i n −1
i c o n v − f u t f −8 − t i s o −8859 −1 f i l e 1 > f i l e 2
# f i l e − i : c o n n a i t r e l ' encodage
f i l e −i filename
f i l e − i * | g r e p u t f −8 | awk −F : ' { p r i n t
$1;}
' | xargs
#us − a s c i i
US− a s c i i ne c o n t e i n t pas d ' a c c e n t s .
La t a b l e de c a r a c t è r e s us − a s c i i e s t s t r i c t e m e n t i n s c r i t e dans u t f −8
t o u s l e s c a r a c t è r e s de us − a s c i i ont l a même v a l e u r dans us − a s c i i
dans u t f 8 . Donc v o u l o i r c o n v e r t i r de us − a s c i i v e r s u t f 8 n ' a t o u t
simplement pas de s e n s .
et
et
5.33 Initramfs
initramfs
sudo m k i n i t r a m f s −o / boot / i n i t r a m f s − 2 . 6 . 2 6
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? i d =238953
5.34 Restaurer une installation Debian
S i tu veux p o u v o i r r e p r o d u i r e une i n s t a l l a t i o n s o u s Debian , j ' a i entendu
p a r l e r du c o u p l e :
dpkg −−get − s e l e c t i o n s > l i s t e . dpkg
pour l i s t e r l e s p a q u e t s i n s t a l l é s s u r Debian au format pour l a commande
suivante :
dpkg −−s e t − s e l e c t i o n s < l i s t e . dpkg
q u i f e r a l e " r e s t a u r e " d e s p a q u e t s s u r une a u t r e machine Debian .
s i tu veux v o i r t o u t t e s package i n s t a l l é f a i t un l s
archives
Ou e n c o r e
a p t i t u d e s e a r c h ' ~ i ! ( ~M) '
E. Branlard
/ var / c a c h e / apt /
60
CHAPTER 5. SYSTEM
5.35 Accents, caracteres accentues, font terminal amarok
dpkg− r e c o n f i g u r e l o c a l e s
a v o i r f r_FR.UTF−8
5.36 Congurer sudoers
e di t er /etc/sudoers
pour a u t o r i s e r sudo avec password a j o u t e r l a l i g n e :
%sudo ALL=(ALL) ALL
s a n s password :
%sudo ALL=NOPASSWD: ALL
5.37 Eteindre / redemarrer : droits utilisateur
On peut p a s s e r par l e f i c h i e r de s u d o e r s mais l e p l u s s i m p l e c ' e s t d '
a j o u t e r l ' u t i l i s a t e u r au groupe powerdev
sudo a d d u s e r manu powerdev
5.38 Son muet au demarrage
r e s i n s t a l l e r pulseaudio
5.39 Demarrage - gestionnaire de connexion - autologin
Pour l ' a u t o l o g i n
− M o d i f i e r l e f i c h i e r d e f i n i s s a n t l e t e r m i n a l p r i n c i p a l / l e s terminaux :
−−−Sous Debian :
Code :
gedit
/etc/ inittab
Commenter l a l i g n e : #1 : 2 3 4 5 : respawn : / s b i n / g e t t y t t y 1
#
La r e m p l a c e r par : 1 : 2 3 4 5 : respawn : / s b i n / m i n g e t t y t t y 1 −− a u t o l o g i n
MONLOGIN
#
1 : 2 3 4 5 : respawn : / b i n / l o g i n − f YOUR_USER_NAME t t y 1 /
dev / t t y 1 2>&1
1 : 2 3 4 5 : respawn : / b i n / l o g i n
− f manu t t y 1 / dev / t t y 1
2>&1
−−−Sous Ubuntu :
Code :
− I n s t a l l e r mingetty : sudo apt −g e t mingetty
g e d i t / e t c / e v e n t . d/ t t y 1
Commenter l a l i g n e : #e x e c
E. Branlard
/sbin/getty
−n 38400 t t y 1
61
CHAPTER 5. SYSTEM
La r e m p l a c e r par :
exec / s b i n / mingetty
t t y 1 −− a u t o l o g i n MONLOGIN
#e x e c / s b i n / g e t t y − l /
u s r / s b i n / a u t o l o g i n −n
38400 t t y 1
Mise en g a r d e :
S i on a un g e s t i o n a i r e de connexion , i l e s t n e c e s s a i r e de l e d e s a c t i v e r !
Pour c e l a j ' a i u t i l i s e sysv −rc −conf , programe q u i permet de g e r e r l e s
s e r v i c e s c h a r g e s au demarrage . On d e s a c t i v e t o u s l e s r u n l e v e l de s l i m
ou gdm ou kdm .
Quelques remarques :
Rq1 : A mon a v i s l ' o p t i o n a u t o l o g i n ne marche pas avec g e t t y , d ' ou l e
b e s o i n d ' u t i l i s e r mingetty −> U t i l i s e r l o g i n s o u s Debian
Rq2 : Mingetty e s t e q u i v a l e n t a r u n g e t t y , mais s o i t d i s a n t p l u s l i g h t !
Rq3 : Sur i n t e r n e t on t r o u v e : u t i l i s e r g e t t y en f a i s a n t un s c r i p t s h e l l
p e r s o , ou en c o m p i l a n t son p r o p r e p e t i t f i c h i e r c
5.40 Demarrage - gestionnaire de connexion - auto-startx - autostartx
− Creer/ e d i t e r l e f i c h i e r
Y inserer :
Code :
~/ .
bash_ p r o f i l e ( en u t i l i s a t e u r , pas en r o o t )
# Load X11
#i f [ − z " $DISPLAY" ] && [ $ ( t t y ) == / dev / t t y 1 ] ; t h e n
i f [ ` ps − l e | g r e p s t a r t x | wc − l ` == 0 ] ; then
startx
fi
Permettant
1.
Maintenant
xfce . . )
xinitrc
a i n s i de l a n c e r X a chaque o u v e r t u r e de s e s s i o n s u r l e t e r m i n a l
s i vous avez p l u s i e u r s g e s t i o n n a i r e de f e n e t r e ( f l u x b o x / gnome /
, j e p e n s e que l e c h o i x de c e l u i − c i s e f a i t v i a l e f i c h i e r .
. A confirmer .
Rq : j ' a i eu un probleme , mes u t i l i s a t e u r s n ' a v a i e n t pas l a p e r m i s s i o n de
l a n c e r s t a r t x ( e r r e u r : u n a b l e t o open Xwrapper . c o n f i g . . . ) . J ' a i
r e i n s t a l l e r ou r e c o n f i g u r e r , j e s a i s p l u s , mon s e r v e u r x .
5.41 Autologin, fenetre de connexion sans gdm
You can a l s o u s e g e t t y t o a u t o l o g i n :
1) Create a f i l e /usr/ sbin / a u t o l o g i n
which i s a s f o l l o w s :
#!
/ b i n / bash
exec
l o g i n <your_username>
R ep l ac e <your_username> with t h e name o f t h e u s e r you want t o l o g i n
a u t o m a t i c a l l y . Then make t h a t f i l e e x e c u t a b l e v i a
E. Branlard
62
CHAPTER 5. SYSTEM
sudo chmod a+x
/usr/sbin/autologin
2 ) Edi t t h e f i l e
/ etc /event
. d/ t t y 1
and change t h e l i n e
exec / s b i n / g e t t y 38400 t t y 1
to
exec / s b i n / g e t t y − l / u s r / s b i n / a u t o l o g i n −n 38400 t t y 1
E. Branlard
63
Chapter
6
FILESYSTEMS, UTILISATEURS, GROUPES,
DROITS
6.1 Les droits d'endossement SetUID et SetGID
h t t p : //www. commentcamarche . n e t / f a q / 3603 − s e c u r i t e − d r o i t s −d−a c c e s −gnu− l i n u x#
i i i −l e s − d r o i t s −s p e c i a u x
chmod 4644 f i c h i e r
chmod 4700 f i c h i e r
chmod 4755 f i c h i e r
chmod u+s
chmod g+s
(4000)
(2000)
Les d r o i t s d ' endossement dans GNU/ Linux s o n t r e p r é s e n t é s par :
* la lettre s ( si le droit x est positionné )
* l a l e t t r e S ( s i l e d r o i t x n ' e s t pas p o s i t i o n n é )
Numériquement , l e s d r o i t s d ' endossement s o n t r e p r é s e n t é s de l a f a ç o n
suivante :
* 4000 − pour l ' endossement de l ' i d e n t i t é du p r o p r i é t a i r e
* 2000 − pour l ' endossement de l ' i d e n t i t é du groupe
Le comportement d e s d r o i t s d ' endossement .
* Pour l e s f i c h i e r s programme ou e x é c u t a b l e
o SUID = 4000 − l e p r o c e s s u s a l e s d r o i t s du p r o p r i é t a i r e du
programme e x é c u t é
o SGID = 2000 − l e p r o c e s s u s a l e s d r o i t s du groupe du programme
exécuté
* Pour l e s r é p e r t o i r e s
o SGID = 2000 − l e s f i c h i e r s q u i s e t r o u v e n t dans l e r é p e r t o i r e
a p p a r t i e n n e n t au groupe du r é p e r t o i r e
64
CHAPTER 6. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
Les d r o i t s d ' endossement s o n t t r è s i m p o r t a n t s pour l a s é c u r i t é .
Au l i e u de donner l ' a c c è s à un f i c h i e r , on donne l e d r o i t d ' a c c è s à une
commande .
Le k e r n e l ( ou noyau ) , au moment de l ' e x é c u t i o n de l a commande e n d o s s e l '
i d e n t i t é du p r o p r i é t a i r e ou du groupe de l a commande au l i e u de c e l l e
de l ' u t i l i s a t e u r q u i a l a n c é l a commande .
Donc l ' a c c è s au f i c h i e r s e f a i t par l e b i a i s de l a commande e t non pas
directement .
Quand un u t i l i s a t e u r s e c o n n e c t e s u r un système GNU/ Linux , i l d é t i e n t 2
UID ( U s e r I D e n t i t y ) e t 2 GID ( GroupIDentity ) : l e r é e l e t l ' e f f e c t i f .
* Au moment de l ' e x é c u t i o n d ' une commande l e s UID
e t GID s o n t l e s
r é e l s , l e s e f f e c t i f s s o n t a t t r i b u é s à l a commande .
* Quand l e s d r o i t s d ' endossement ne s o n t pas p o s i t i o n n é s , a l o r s l e s
UID e t GID e f f e c t i f s s o n t i d e n t i q u e s aux UID e t GID r é e l s .
* S i l e s d r o i t s d ' endossement s o n t p o s i t i o n n é s a l o r s l ' UID e t / ou GID
e f f e c t i f s s o n t ceux de l a commande . Ce q u i veut d i r e que l e s UID e t
GID e f f e c t i f s s o n t ceux q u i c o n t r ô l e n t l e s d r o i t s d ' a c c è s à une
commande
Pour c o n n a î t r e l e s f i c h i e r s avec l e s d r o i t s d ' endossement de v o t r e système
t a p e z dans un t e r m i n a l l a commande s u i v a n t e :
# find
/
−perm −2000 −o −perm −4000 − e x e c l s − l {} \ ; 2>/ dev / n u l l
Un bon exemple c ' e s t l a commande c r o n t a b . C e t t e commande c r é e un f i c h i e r
dans / var / s p o o l / c r o n / c r o n t a b s pour l ' u t i l i s a t e u r q u i a e x é c u t é l a
commande c r o n t a b . L ' a c c è s au r é p e r t o i r e / var / s p o o l / c r o n t / c r o n t a b s e s t
i n t e r d i t aux u t i l i s a t e u r s s a u f r o o t .
$ cd / var / s p o o l / c r o n / c r o n t a b s /
bash :
cd :
/ var / s p o o l / c r o n / c r o n t a b s / :
P e r m i s s i o n non a c c o r d é e
Quand l ' u t i l i s a t e u r l a n c e l a commande c r o n t a b −e ( pour é d i t e r son f i c h i e r
/ var / s p o o l / c r o n / c r o n t a b s /nom_u s e r ) , l a commande s ' e x é c u t e avec l ' UID e t
GID r é e l de l ' u t i l i s a t e u r mais avec l ' UID e t GID e f f e c t i f de r o o t .
$ l s −l /usr/bin/crontab
−rwxr −s r −x 1 r o o t c r o n t a b 26872 2004 − 07 − 28 2 2 : 4 4
/usr/bin/crontab
On v o i t que l a commande c r o n t a b e s t l a p r o p r i é t é de r o o t
p a r t i e du groupe c r o n t a b avec l e d r o i t SGID .
Et comme r o o t a l e d r o i t de c r é e r dans
sera créé .
qu ' e l l e f a i t
/ var / s p o o l / c r o n / c r o n t a b s
# l s − l / var / s p o o l / cron / c r o n t a b s / l a m i 2 0 j
−rw−−−−−−− 1 l a m i 2 0 j c r o n t a b 225 2006 − 07 − 22 1 6 : 0 0
/lami20j
E. Branlard
et
le fichier
/ var / s p o o l / c r o n / c r o n t a b s
65
CHAPTER 6. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
On v o i t que l ' u t i l i s a t e u r l a m i 2 0 j e s t l e p r o p r i é t a i r e du f i c h i e r e t qu ' i l
a l e s d r o i t s de l e c t u r e e t d ' é c r i t u r e . Cependant i l ne peut pas l e
f a i r e directement .
6.2 Begin:waiting for resume on startup, resume process
The resume s c r i p t check
if
t h e swap p a r t i t i o n e x i s t s .
1 . f i r s t make t h e swap p a r t i t i o n work a g a i n by
sudo mkswap / dev / sda6
( where sda6 s h o u l d be t h e c o r r e s p o n d i n g p a r t i t i o n on your system . Check
g p a r t e d t o e n s u r e t h i s . This w i l l DESTROY a l l your data i f you u s e i t
on a data p a r t i t i o n , l i k e your /home one )
( i f not working ( o c c u p i e d ) , you need t o f r e e i t
s w a p o f f / dev / sda6
)
2 . then compute t h e UUID o f t h e new swap p a r t i t i o n
sudo b l k i d / dev / sda6
3 . change t h e UUID code i n both t h e s e f i l e s
/etc/fstab
( o n l y change t h e one c o n c e r n i n g / dev / sda6 ! )
. d / resume
/ e t c / i n i t r a m f s −t o o l s / c o n f
4 . r e b u i l d t h e i n i t r a m f s with
update − i n i t r a m f s −u
5. reboot
You can a l s o change back t h e swap UUID with t h i s command ( thanks L o w e l l )
mkswap −U UUID / dev / swapdev
where UUID i s t h e ID shown i n both mentioned / e t c f i l e s ( t h e ID s h o u l d be
t h e same i n both them , o t h e r w i s e f o l l o w t h e 1−3 s t e p s ! )
6.3 Forcer le montage en ecriture d'une partition ntfs apres un mauvais demontage de windows
demonter l e d i s q u e
p u i s l e monter avec l ' o p t i o n f o r c e :
sudo mount − t n t f s −3g / dev / sdb1 / media / S t o r a g e D i s k −o f o r c e
6.4 Disque externe en lecture seule
cat
mtab
/ dev / s d c 1
/ media / S t o r a g e f u s e b l k rw , nosuid , nodev , noatime , a l l o w_o t h e r ,
b l k s i z e =4096 0 0
sudo v o l_i d −u / dev / sdxx
UUID : 0C3C5FC03C5FA40C
E. Branlard
66
CHAPTER 6. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
d e f a u l t s Correspond a rw , s u i d , dev , exec , auto , n o u s e r e t async
# g i d =100 a s s i g n e r a l ' ensemble d e s f i c h i e r s au groupe dont l e g i d ( pour
group id , i d e n t i f i a n t de groupe ) e s t 1 0 0 . Sous Ubuntu , l e g i d 100
c o r r e s p o n d au groupe u s e r s , a u q u e l t o u s l e s u t i l i s a t e u r s f o n t
normalement p a r t i e . Vous pouvez r e t r o u v e r une l i s t e de t o u s l e s g r o u p e s
e x i s t a n t s s u r v o t r e machine avec l e u r g i d dans l e f i c h i e r / e t c / group .
S i vous o m e t t e z c e t t e o p t i o n , t o u s l e s f i c h i e r s s e r o n t a s s i g n é s au
groupe 0 , s o i t r o o t ( l e compte s y s t è m e ) .
# u i d =1000 a s s i g n e r a l ' ensemble d e s f i c h i e r s de l a p a r t i t i o n à l '
u t i l i s a t e u r dont l ' UID ( pour User ID , i d e n t i f i a n t d ' u t i l i s a t e u r ) e s t
1 0 0 0 . Sous Ubuntu , l ' UID 1000 c o r r e s p o n d au premier u t i l i s a t e u r , c r é é
l o r s de l ' i n s t a l l a t i o n de Ubuntu . S i vous o m e t t e z c e t t e o p t i o n , t o u s
l e s f i c h i e r s s e r o n t a s s i g n é s à l ' u t i l i s a t e u r r o o t ( l e compte s y s t è m e ) .
# L ' o p t i o n umask=002 donnera l e s d r o i t s d ' accès , s u r l ' ensemble d e s
r é p e r t o i r e s e t f i c h i e r s , en l e c t u r e e t en é c r i t u r e à tous , de même qu '
en e x é c u t i o n au p r o p r i é t a i r e du f i c h i e r .
6.5 Utilisateurs et groupes
U t i l i s a t e u r s : ( / e t c / passwd
/ e t c / shadow )
u s e r a d d −m
−m pour c r e a t i o n automatique du d o s s i e r dans home
passwd −d USER ( v i d e l e passwd , l ' u t i l i s a t e u r l e change en tappant passwd
)
usermod
addgroup u s e r group
userdel
id
groups
Groupes :
groupadd
groupmod
groupdel
( / e t c / group
−> g i d
et
membre du groupe )
Droits f i c h i e r s dossiers :
chmod 770 f o l d
chown −R u s e r : group f o l d
chown : g i d f o l d
chown u i d f o l d
chmod u=rwX , g=rwXs , o=−−− f o l d −> l e s e s t important , t o u s l e s f i c h i e r s
c r e e r dans l e d o s s i e r e t s o u s d o s s i e r a p p a r t i e n n e n t au g r o p e
6.6 Droits partage dossier chiers
Les b a s e s de d r o i t UNIX
Les d r o i t s s o u s unix dans l e u r v e r s i o n POSIX s o n t r e l a t i v e m e n t s i m p l e s . Un
u t i l i s a t e u r e s t d é f i n i par un i d e n t i f i a n t e t un groupe . Le nom de c e
groupe e s t g é n é r a l e m e n t l e même que l e nom de l ' i d e n t i f i a n t . A i n s i
l o r s q u e l ' on c r é e un n o u v e l u t i l i s a t e u r par l a commande a d d u s e r gaston ,
e s t automatiquement f a b r i q u é l ' i d e n t i f i a n t g a s t o n ET son groupe g a s t o n
E. Branlard
67
CHAPTER 6. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
. L ' i d é e sous − j a c e n t e de c e groupe un peu s p é c i a l , e s t que s e u l l '
u t i l i s a t e u r y a p p a r t i e n t et p e r s o n n e d ' a u t r e .
La commande addgroup permet quant à e l l e d ' a j o u t e r de nouveaux g r o u p e s q u i
ne s o n t à l ' o r i g i n e l i é s à aucun u t i l i s a t e u r . Après i l e s t p o s s i b l e d '
a j o u t e r a r b i t r a i r e m e n t un u t i l i s a t e u r à un de c e s groupe avec l a
commande usermod . Un u t i l i s a t e u r e s t donc l e s e u l à a p p a r t e n i r au
groupe q u i p o r t e l e nom de son i d e n t i f i a n t , mais peut a p p a r t e n i r à
p l e i n d ' autres groupes .
Chaque r e s s o u r c e ( f i c h i e r ou un d o s s i e r ) e s t d é c r i t par un groupe , un
i d e n t i f i a n t e t t r o i s n i v e a u x de d r o i t s . Chacun de c e s t r o i s n i v e a u x
c o r r e s p o n d à une d e s c o n d i t i o n s s u i v a n t e s a p p l i q u é e à l ' u t i l i s a t e u r q u i
tente d ' accéder à la ressource :
1 . u ou u s e r − Son i d e n t i f i a n t e s t c e l u i de l a r e s s o u r c e .
2 . g ou group − I l a p p a r t i e n t au groupe de l a r e s s o u r c e .
3 . o ou o t h e r − I l n ' e s t n i du bon groupe , n i du bon i d e n t i f i a n t .
A chacun de s e s n i v e a u x c o r r e s p o n d une s é r i e d ' a u t o r i s a t i o n : d r o i t de
l e c t u r e ( r ) , d r o i t d ' é c r i t u r e (w) e t d r o i t d ' e x é c u t i o n ( x ) . Sachant qu '
e x é c u t e r un d o s s i e r c o n s i s t e s o u s Unix à p o u v o i r r e n t r e r dedans . . .
A i n s i l o r s q u ' un u t i l i s a t e u r a c c è d e à une r e s s o u r c e , UNIX c h e r c h e l a
p r e m i è r e c o n d i t i o n v é r i f i é e , r e g a r d e l e s d r o i t s q u i c o r r e s p o n d e n t et
l e s a p p l i q u e . La commande pour c h a n g e r l e s d r o i t s s u r une r e s s o u r c e e s t
chmod . Par exemple chmod gu+rw , o−rw , donne un a c c è s l e c t u r e ( r ) e t
é c r i t u r e (w) pour l a c o n d i t i o n ( 1 ) e t ( 2 ) , e t aucun d r o i t pour l a
condition (3) .
Lorsqu ' un u t i l i s a t e u r f a b r i q u e un f i c h i e r , c e d e r n i e r l u i a p p a r t i e n t , c '
e s t à d i r e que l e groupe e t l ' i d e n t i f i a n t du f i c h i e r s o n t ceux de l '
u t i l i s a t e u r ( d ' où l ' i n t é r ê t du groupe p r i v é ) . Les d r o i t s du f i c h i e r
s o n t g é n é r a l e m e n t de type rw pour groupe e t p r o p r i é t a i r e , e t r
s e u l e m e n t pour l e s a u t r e s . Ces d r o i t s par d é f a u t peuvent cependant ê t r e
c h a n g é s par l a commande umask q u i permet d ' e n l e v e r d e s d r o i t s aux
f i c h i e r s c r é é s . Par exemple umask go−w f e r a que t o u s l e s p r o c h a i n s
f i c h i e r s n ' a u r o n t p l u s l e d r o i t d ' é c r i t u r e que s u r o ( l e p r o p r i é t a i r e ) .
L ' umask par d é f a u t e s t donc o−w .
Pour une i n f o r m a t i o n p l u s p o u s s é e s u r l e s d r o i t s unix , j e vous c o n s e i l l e
de l i r e l ' e x c e l l e n t a r t i c l e s u r w i k i p e d i a .
Première approche du p a r t a g e
Par " p a r t a g e " , i l f a u t e n t e n d r e i c i " système de f i c h i e r " . I l n ' e s t
absolument pas q u e s t i o n de NFS, CIFS ou a u t r e a p p a r e i l l a g e du même
a c a b i t s . L ' i d é e de d é p a r t du b e s o i n e s t l a s u i v a n t e :
* Sur une machine j ' a i d e s u t i l i s a t e u r s , d i s o n s gaston , j o s e t t e
et
robert
* J ' a i d e s d o s s i e r s q u i s o n t chacun p a r t a g é s par un ensemble d i f f é r e n t
d ' u t i l i s a t e u r s . Le d o s s i e r / p h o t o s e s t p a r t a g é par j o s e t t e e t
gaston , mais / v i d é o s l ' e s t par g a s t o n e t r o b e r t .
* Je veux que l o r s q u ' un u t i l i s a t e u r c r é e une r e s s o u r c e ( d o s s i e r ou
f i c h i e r ) dans un d o s s i e r ( ou sous − d o s s i e r ) , l e s a u t r e s u t i l i s a t e u r s
ayant a c c è s à c e d o s s i e r p u i s s e m o d i f i e r c e t t e r e s s o u r c e .
Simple n ' e s t −c e pas ? On s e d i t dans une p r e m i è r e approche qu ' i l
suffit :
1 . De c r é e r a u t a n t de g r o u p e s que de d o s s i e r .
E. Branlard
68
CHAPTER 6. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
2 . De c h a n g e r l e s d r o i t s de chaque d o s s i e r ( de manière r é c u r s i v e ) de
s o r t e à l e s donner au groupe en é c r i t u r e .
3 . D' a j o u t e r dans c e groupe chaque u t i l i s a t e u r ayant a c c è s au d o s s i e r .
Ce q u i nous donne :
# c r é a t i o n des u t i l i s a t e u r s
adduser gaston
adduser j o s e t t e
adduser r o b e r t
# c r é a t i o n d e s deux g r o u p s
addgroup a c c e s −p h o t o s
addgroup a c c e s − v i d e o s
# changement d e s d r o i t s s u r l e s d o s s i e r s : l e c t u r e / é c r i t u r e / t r a v e r s é e
pour groupe e t u t i l i s a t e u r , r i e n pour l e s Autres .
chown o−rwx , gu+rwX / v i d é o s / p h o t o s −Rc
Le mode d ' a c c è s de ` / v i d é o s / nos_v a c a n c e s . avi ' a é t é m o d i f i é à 0660 ( rw
−rw−−−−) .
# changement du group d ' a p p a r t e n a n c e
chown : a c c e s − v i d e o s / v i d é o s −Rc
chown : a c c e s −p h o t o s / p h o t o s −Rc
# ajout
usermod
usermod
usermod
r o o t#
d e s u t i l i s a t e u r s aux d i f f é r e n t s g r o u p s
−a −G a c c e s −v i d e o s , a c c e s −p h o t o s g a s t o n
−a −G a c c e s − v i d e o s j o s e t t e
−a −G a c c e s −p h o t o s r o b e r t
A p a r t i r de l à t o u t va b i e n ou presque , c a r l e s e n n u i s commencent l o r s q u '
un u t i l i s a t e u r commence à c r é e r un f i c h i e r dans un p a r t a g e . Comme nous
l ' avons vu p l u s haut , c e nouveau f i c h i e r h é r i t e r a de l ' i d e n t i f i a n t e t
du group de l ' u t i l i s a t e u r q u i l ' aura c r é e . La conséqu ence , à c a u s e de l
' umask par d é f a u t , e s t l ' i m p o s s i b i l i t é d ' ê t r e m o d i f i é e par q u i que c e
s o i t , vu que t o u t l e monde e s t o t h e r dans c e c a s de f i g u r e .
D r o i t SGID e t SUID
Les d r o i t s SUID e t SGID s ' a p p l i q u e n t g é n é r a l e m e n t aux e x é c u t a b l e s en
donnant à l ' u t i l i s a t e u r q u i l e s l a n c e n t l e s mêmes d r o i t que l '
u t i l i s a t e u r (SGID) ou l e groupe (SGID) a u q u e l l ' e x é c u t a b l e a p p a r t i e n t .
A i n s i s u r une commande a p p a r t e n a n t à r o o t , un chmod u+s p e r m e t t r a i t à n
' i m p o r t e q u i de l a l a n c e r AVEC l e s d r o i t s r o o t . . .
Dans l e c a s q u i nous i n t é r e s s e , SGID a une p r o p r i é t é un peu moins connue .
En e f f e t l o r s q u e c e t t e f o i s c ' e s t un d o s s i e r q u i d i s p o s e du d r o i t SGID ,
t o u s l e s d o s s i e r s e t t o u s l e s f i c h i e r s q u i s e r o n t c r é é immédiatement
en d e s s o u s a u r o n t l e même groupe que l u i . Plus i n t é r e s s a n t e n c o r e , t o u t
d o s s i e r c r é é aura en p l u s l e SGID de p o s i t i o n n é .
A i n s i n o t r e problème s e r è g l e t r è s simplement en p o s i t i o n n a n t au d é p a r t l e
SGID s u r t o u s l e s d o s s i e r s ( e t s e u l e m e n t l e s d o s s i e r s ! ! ) :
r o o t#f i n d
r o o t#f i n d
r o o t#
E. Branlard
/vidéos
/photos
− t y p e d − e x e c chmod g+s {} \ ;
− t y p e d − e x e c chmod g+s {} \ ;
69
CHAPTER 6. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS
E n s u i t e , SGID é t a n t p o s i t i o n n é , t o u s l e s p r o c h a i n s f i c h i e r s c r é é s i c i
a u r o n t l e bon groupe e t t o u s l e s nouveaux d o s s i e r l e SGID .
Conclusion
L ' avantage de c e t t e approche e s t que l a m a j o r i t é d e s a p p l i c a t i o n s q u i vont
a c c é d e r au système de f i c h i e r vont r e s p e c t e r c e s d r o i t s . Maintenant c e
n ' e s t pas l ' a b s o l u e panacée c a r l e f i c h i e r ou l e d o s s i e r continue d '
a p p a r t e n i r à l ' u t i l i s a t e u r q u i l ' a c r é é , e t r i e n ne l ' empêche d ' a l l e r
m o d i f i e r l e s d r o i t s , y c o m p r i s l e SGID . I l y a a u s s i c e r t a i n e s
a p p l i c a t i o n s comme t a r q u i vont m o d i f i e r c e s d r o i t s e t l ' on r i s q u e
a l o r s à nouveau l ' i n c o h é r e n c e . Mais c e t t e méthode r è g l e une grande
p a r t i e d e s p r o b l è m e s e t une p e t i t e t â c h e CRON peut v e n i r f i n i r l e
travail .
6.7 org.freedesktop.hal.storage
sudo nano / e t c / P o l i c y K i t / P o l i c y K i t . c o n f
<?xml v e r s i o n=" 1 . 0 " e n c o d i n g="UTF−8"?> < !−− −*− XML −*− −−>
< !DOCTYPE p k c o n f i g PUBLIC "−// f r e e d e s k t o p //DTD P o l i c y K i t C o n f i g u r a t i o n 1 . 0
//EN"
" h t t p : // h a l . f r e e d e s k t o p . o r g / r e l e a s e s / P o l i c y K i t / 1 . 0 / c o n f i g . dtd ">
< !−− See t h e manual page P o l i c y K i t . c o n f ( 5 )
for
f i l e format −−>
<c o n f i g v e r s i o n=" 0 . 1 ">
<d e f i n e_admin_auth group=" u s e r s " />
<match a c t i o n=" o r g . f r e e d e s k t o p . h a l . power−management . shutdown ">
<return r e s u l t=" y e s " />
</ match>
<match a c t i o n=" o r g . f r e e d e s k t o p . h a l . power−management . r e b o o t ">
<return r e s u l t=" y e s " />
</ match>
<match a c t i o n=" o r g . f r e e d e s k t o p . h a l . power−management . suspend ">
<return r e s u l t=" y e s " />
</ match>
<match a c t i o n=" o r g . f r e e d e s k t o p . h a l . power−management .
h i b e r n a t e ">
<return r e s u l t=" y e s " />
</ match>
<match a c t i o n=" o r g . f r e e d e s k t o p . h a l . s t o r a g e . * ">
<return r e s u l t=" y e s " />
</ match>
<match a c t i o n=" hal − s t o r a g e −mount− f i x e d −e x t r a − o p t i o n s "> < !−− f o r
i n t e r n a l d e v i c e s mounted with e x t r a o p t i o n s l i k e a wished mount
p o i n t −−>
<return r e s u l t=" y e s " />
</ match>
<match a c t i o n=" hal − s t o r a g e −mount−removable −e x t r a − o p t i o n s "> < !−−
f o r e x t e r n a l d e v i c e s mounted with e x t r a o p t i o n s l i k e a wished
mount p o i n t $
<return r e s u l t=" y e s " />
</ match>
</ c o n f i g >
E. Branlard
70
Chapter
7
Grub, dual-boot, MBR
7.1 Grub 2
F i c h i e r de c o n f i g dans :
. cfg
/ boot / grub / grub
Methode p r o p r e :
h t t p : // b l o g s . k o o l w a l . n e t / 2008 / 12 / 28 / windows−x p v i s t a −dual −boot −does −not −
boot −from −grub2 −or −grub −pc /
# nano / e t c / g r u b . d / 11_Windows ( t h i s w i l l e s s e n t i a l l y c r e a t e a new f i l e )
#! / b i n / sh −e
echo " Adding Windows" >&2
c a t << EOF
menuentry "Windows XP" {
s e t r o o t =(hd0 , 1 )
c h a i n l o a d e r +1
}
EOF
chmod a+x / e t c / grub . d / 11_Windows
# nano / e t c / g r u b . d / 05_d e b i a n_theme
COLOR_NORMAL=" g r e e n / b l a c k "
COLOR_HIGHLIGHT=" w h i t e / b l a c k "
update −grub2
7.2 Installer grub dans le MBR
%%
%%
%%
%%
%
# b o o t e r s u r System r e s c u e CD
# mounter FS
mount / dev / sda3 /mnt/ g e n t o o
# I n s t a l l e r g r u b 1 ( / dev / sda SANS NUMERO)
grub − i n s t a l l −− r o o t − d i r e c t o r y=/mnt/ g e n t o o / dev / sda
#−− r o o t − d i r ca e v i t e de monter / proc e t / dev e t de c h r o o t e r
# C e t t e methode r e i n s t a l l g r u b 1 .
# I l f a u d r a donc f a i r e un update −g r u b une f o i s que t o u t marche
71
CHAPTER 7. GRUB, DUAL-BOOT, MBR
%%
%%
%%
%%
%
i n s t a l l e r grub dans l e MBR ( Master Boot Record ) .
I l f a u t t o u t d ' abord s a v o i r q u e l l e e s t l a p a r t i t i o n q u i c o n t i e n t v o t r e
f i c h i e r / boot / grub / s t a g e 1 , e t c . Ce p o i n t e s t t r è s i m p o r t a n t . La
commande
d f / boot / grub / s t a g e 1
d e v r a i t vous r e n s e i g n e r avec p r é c i s i o n .
I l faudra , s e l o n c e t exemple , que l e r é p e r t o i r e / boot / grub c o n t i e n n e t o u s
l e s f i c h i e r s n é c e s s a i r e s à grub : s t a g e 1 , xxx_s t a g e 1_5 ( xxx é t a n t l e s
f i l e s y s t e m s dont vous avez b e s o i n ) , menu . l s t ( q u i e s t un l i e n v e r s grub
. conf ) , stage2 .
Supposons que c e s o i t l a p a r t i t i o n / dev / hda5 . On l a n c e r a a l o r s l e s
commandes :
/ s b i n / grub
r o o t ( hd0 , 4 )
s e t u p ( hd0 )
quit
%%
%##
1 . Marquer l a p a r t i t i o n où s e t r o u v e / boot comme a c t i v e ( drapeau boot
avec l ' u t i l i t a i r e c f d i s k par exemple ) e t « démarquer » l a p a r t i t i o n
Windows .
2 . I n s t a l l e r un MBR g é n é r i q u e avec l a commande i n s t a l l −mbr du paquet
mbr .
3 . Démarrer s u r un Live −CD (comme Knoppix ou K a e l l a ) , monter l a
p a r t i t i o n c o n t e n a n t / boot , s e « c h r o o t e r » dedans , e t l a n c e r un grub
−i n s t a l l .
4 . Démarrer s u r un Live −CD e t r é i n s t a l l e r GRUB dans l e MBR de c e t t e
manière :
# grub
grub> r o o t ( hd0 , 4 )
grub> s e t u p ( hd0 )
grub> q u i t
Complements ( e l e m e n t s d i s p a r a t e s a o r g a n i s e r ) : a p a r t i r d ' un l i v e
−monter l e bon hdax
mount / dev / hdax /mnt/ temp
−l e c h r o o t e r :
c h r o o t /mnt/ temp
c h r o o t /mnt/ temp / b i n / sh − i
c h r o o t /mnt/ temp / b i n / bash
−monter e l e m e n t s q u i peuvent e t r e u t i l e s a l ' i n s t a l l a t i o n
mount −o bind / dev / /mnt/ temp / dev
mount −o bind / p r o c /mnt/ temp / p r o c
cp / p r o c / mounts /mnt/ temp / e t c / mtap
cd
sudo grub
>f i n d / boot / grub / s t a g e 1
>r o o t ( hdx , y )
>s e t u p hd0
>q u i t
grub − i n s t a l l
/ dev / hdax
exit
umount
E. Branlard
/mnt
72
CHAPTER 7. GRUB, DUAL-BOOT, MBR
sudo − s
su −
7.3 Installer un dual boot avec Vista, sans utiliser le MBR
I n s t a l l e r Vista
I n s t a l l e r ubuntu , mais ne pas i n s t a l l e r grub s u r l e MBR, l ' i n s t a l l e r dans
/ boot / grub de l a p a r t i t i o n l i n u x .
I n s t a l l e r Easy BCD s o u s v i s t a
A j o u t e r un c h o i x v e r s une p a r t i t i o n l i n u x .
E. Branlard
73
Chapter
8
WIFI
8.1 Congurer ma carte wi bcm4310, broadcom
#commandes u t i l e s
iwconfig
ifconfig
l s p c i | g r e p − i network
lsmod # v o i r l e s modules c h a r g e s
lshw −C network
#Pour k e r n e l 2 . 6 . 3 2 ( what I ' ve done w i t h 2.6.32 − 4 and 5)
(− i n s t a l l firmware −b43 . . . maybe u s e l e s s ? )
− i n s t a l l source from broadcom−b43
− go t o / u s r / s r c / modules / broadcom− s t a / i 3 8 0
Puis a p a r t i r d e s s o u r c e s de broadcom :
make
( c r e e wl . ko )
make i n s t a l l ( l e met dans / l i b / modules / 2.6.32 −XXX/ k e r n e l / d r i v e r s / n e t /
w i r e l e s s /)
depmod
( pour que wl s o i t reconnu )
− E n s u i t e ! ! ! L ' i m p o r t a n t e s t l a s e q u e n c e dans l a q u e l l e l e s modules s e
chargent :
t o u t d e l o a d e r : rmmod b43 b44 wl s s b
Puis dans l ' o r d r e :
modprobe wl
modprobe s s b
modprobe b44
Un depmod −a
modules
ne d o i t pas f a i r e de mal pour g e n e r e r l e s dependances e n t r e
S ' i l f a u t a p p l i q u e r d e s b l a k l i s t s , c e l a s i g n i f i e qu ' i l f a u t surement
r e f a i r e un i n i r a m f s
update − i n i t r a m f s −u
En e f f e t , b44 peut e t r e c h a r g é dans l ' i n i t r a m f s . Ca s e v e r i f i e en tappant :
g u n z i p −c / boot / i n i t r d . img−$ ( uname − r ) | c p i o −− l i s t | g r e p b44
74
CHAPTER 8. WIFI
#pour k e r n e l s u p e r i e u r a 2 . 6 . 3 0
h t t p : // w i k i . d e b i a n . o r g / wl#S q u e e z e
h t t p : // forums . d e b i a n . n e t / v i e w t o p i c . php? f =16&t =30648&s i d =20
b a 5 c c e a 3 f 4 a 0 9 8 2 9 4 2 1 b 0 8 a 6 9 4 b 0 6 9&s t a r t =120
h t t p : //www. a r c h l i n u x . i t / w i k i / i n d e x . php? t i t l e =Broadcom_BCM4312
sudo a p t i t u d e i n s t a l l broadcom−s t a − s o u r c e s
p u i s a l l e r dans l e r e p e r t o i r e / u s r / s h a r e / doc / broadcom−s t a −source /
e t l i r e l e readme
/ e t c / modprobe . d / broadcom−s t a −common . c o n f
# o r i g i n a l c o n t e n t s was t h e l i n e i m m e d i a t e l y b e l o w
# i n s t a l l wl / s b i n / modprobe − q r b43 s s b ; / s b i n / modprobe −− i g n o r e − i n s t a l l
wl $CMDLINE_OPTS
i n s t a l l wl / s b i n / modprobe − qr b44 s s b ; / s b i n / modprobe −− i g n o r e − i n s t a l l wl
$CMDLINE_OPTS
My b e s t g u e s s , was t h a t t h e r e a s o n my w i f i i s n ' t working t h a t i t ' s r e l a t e d
t o t h e module s s b . I can not keep t h e module from b e i n g l o a d e d and I
can not remove t h e module . A f t e r r e a d i n g some about b l a c k l i s t i n g h t t p : /
/ w i k i . d e b i a n . o r g / K e r n e l M o d u l e B l a c k l i s t i n g I saw t h a t I was not e n t e r i n g
' b l a c k l i s t ssb ' i n t h e c o r r e c t f i l e and I f o l l o w e d t h e i n s t r u c t i o n t h e
t h e URL. I had p r e v i o u s l y n o t i c e d t h a t t h e r e was some dependency o f
b44 on s s b and I couldn ' t remove s s b u n t i l b44 was out o f t h e way . I
d e c i d e d t o ( I don ' t r e a l l y know why ) l o o k a t / e t c / modprobe . d / broadcom−
s t a −common . c o n f and n o t i c e d t h e removal o f b43 module i n s t e a d o f b44
module . So when I changed ' b43 ' t o ' b44 ' I then had w i f i . As noted i n a
p r e v i o u s post , b44 i s my w i r e d e t h e r n e t .
The o n l y t h i n g t h a t might be a concern , i s t h a t my w i r e l e s s d e v i c e i s
named e t h 1 i n s t e a d o f wlan0 . Not t h a t i t r e a l l y m a t t e r s but i n k e e p i n g
c o n v e n t i o n , my w i r e l e s s s h o u l d be wlanX not ethX .
ou
sudo a p t i t u d e i n s t a l l broadcom−s t a −modules − 2.6.30 − 1 − 686
puis
b l a c k l i s t e r ( / e t c / modprobe . d / b l a c k l i s t . d ) b43 b44 s s b
les virer
rmmod b43 ; rmmod b44 ; rmmod s s b ;
Enfin , a j o u t e r wl e t peut − e t r e l i b 8 0 2 1 1_c r y p t_t k i p dans
/ e t c / modules
Sinon , p a t c e r s o i meme l e s f i c h i e r s wl_l i n u x . c e t wl_l i n u x . h l o r s de l a
c o m p i l a t i o n du d r i v e r wl . ko ( v o i r p l u s bas )
a f i n de ne pas u t i l i s e r i e e e 8 0 2 1 1 mais l i b 8 0 2 1 1
#Pour k e r n e l < 2 . 6 . 3 0
De l a b a l l e ! ! ! ! ! ! ! :
U t i l i s e r l e s d r i v e r s broadcom :
h t t p : //www. broadcom . com/ s u p p o r t / 8 0 2 . 1 1 / l i n u x_s t a . php
U t i l i s e r l e patch s i b e s o i n ( k e r n e l > 2 . 6 . 2 8 )
Le module i e e e 8 0 2 1 1_c r y p t_t k i p a change de nom , maintenant c ' e s t l i b 8 0 2 1 1_
c r y p t_t k i p
donc , f a i r e :
modprobe l i b 8 0 2 1 1_c r y p t_t k i p
puis
insmod wl . ko
E. Branlard
75
CHAPTER 8. WIFI
Article explicatif :
h t t p : // jomcode . com/ f a d h i l / ?p=59
J ' a i sauve l e f i c h i e r t a r dans mon C o n f i g
t a r − x v z f hybrid − p o r t s r c −x86_32_5_10_27_6 . t a r . gz
make −C
/ l i b / modules /
` uname −r ` / b u i l d M=`pwd `
Of c o u r s e , you need t o make s u r e you have a l l t h e r e q u i r e d k e r n e l h e a d e r s
before building i t .
Once that ' s done , your d i r e c t o r y l i s t i n g s h o u l d l o o k l i k e t h i s :
b u i l t −i n . o
hybrid − p o r t s r c −x86_32_5_10_27_6 . t a r . gz
lib
Makefile
modules . o r d e r
Module . symvers
src
wl . ko
wl . mod . c
wl . mod . o
wl . o
The magic f i l e we need i s wl . ko . Make s u r e you don ' t have b43 , b 4 3 l e g a c y
o r b43xx l o a d e d by r u n n i n g t h i s :
rmmod bcm43xx ; rmmod b43 ; rmmod b 4 3 l e g a c y
And
for
good measure remove n d i s w r a p p e r modules :
rmmod n d i s w r a p p e r
Now l o a d t h e module i e e e 8 0 2 1 1_c r y p t_t k i p :
modprobe i e e e 8 0 2 1 1_c r y p t_t k i p
And f i n a l l y l o a d t h e wl . ko module :
insmod wl . ko
Now
i f you do an i f c o n f i g , you s h o u l d s e e wlan0 r i g h t a f t e r your e t h 0 and
lo devices . Y
i p p e e −kay−yay ! Test i t out by s c a n n i n g and c o n n e c t i n g t o a network .
I f i t works , then you might want your module t o l o a d upon boot , which i s
something t h e Broadcom readme doesn ' t touch on .
Let me s c h o o l you how .
Copy t h e wl . ko f i l e t o
cp
wl . ko
/ l i b / modules / 2.6.26 − 1 − 686 / k e r n e l / n e t / w i r e l e s s /
/ l i b / modules / 2.6.26 − 1 − 686 / k e r n e l / n e t / w i r e l e s s /
C r e a t e t h e module d e p e n d e n c i e s :
depmod −a
Try l o a d i n g your new module ! :
E. Branlard
76
CHAPTER 8. WIFI
modprobe wl
I f you g e t no e r r o r on modprobe , then i t worked p e r f e c t l y ! Next you have
t o t e l l your system t o l o a d t h e module a t s t a r t u p .
On my d e b i a n system , I do t h i s by e d i t i n g t h e f i l e / e t c / modules t o i n c l u d e
the f o l l o w i n g :
i e e e 8 0 2 1 1_c r y p t_t k i p
wl
Now, r e b o o t and you ' ve g o t o f f i c i a l Broadcom w i f i g o o d n e s s !
# old s t u f f
h t t p : // ubuntu . c a f u e g o . n e t / d i s t s / hardy −c a f u e g o / broadcom /
c e que j ' a i f a i t :
i n s t a l l e r d e p u i s c a f u e g o bcm43xx−f i r m w a r e
s e l e c t system −>a d m i n i s t r a t i o n −>s o f t w a r e s o u r c e s
under t h e update tab s e l e c t hardy −proposed , and i n s t a l l t h e r e s t r i c t e d
d r i v e r s module and r e s t a r t your computer
j ' a i i n s t a l l e gnome−d e v i c e −manager
j ' a i i n s t a l l e hostapd e t l i n u x −wlan
et
wl−b e t a
8.2 Fluxbox et wi
dans l e . f l u x b o x de home , r a j o u t e r :
nm− a p p l e t &
btw networkmanager need h a l and dbus t o be s t a r t e d .
DAEMONS=( s y s l o g −ng ! network h a l dhcdbd networkmanager n e t f s crond ipw3945d
)
8.3 Cracker wi WAP
8.4 Cracker wi WEP
La s u i t e a i r c r a c k −ng comprend p l u s i e u r s programmes dont l e s 3 p r i n c i p a u x
sont
* airodump −ng , l e l o g i c i e l de c a p t u r e de paquets , c ' e s t l u i q u i s c a n l e s
r é s e a u x et c o n s e r v e l e s p a q u e t s q u i s e r v i r o n t à d é c r y p t e r l a c l e f .
* a i r e p l a y −ng , un l o g i c i e l dont l a p r i n c i p a l e f o n c t i o n e s t l ' e n v o i s de
p a q u e t s dans l e but de s t i m u l e r l e r e s e a u e t c a p t u r e r p l u s de p a q u e t s .
E. Branlard
77
CHAPTER 8. WIFI
* a i r c r a c k −ng , l e l o g i c i e l de c r a c k de c l e f , c ' e s t un l o g i c i e l q u i à
p a r t i r d e s i n f o r m a t i o n s c a p t u r é e s à l ' a i d e d ' airodump va nous donner l a
c l e f ( s i b i e n s u r on en a un nombre s u f f i s a n t ) .
h t t p : //www. cdc . i n f o r m a t i k . tu −darmstadt . de / a i r c r a c k −ptw /
A i r c r a c k −ptw
Our t o o l i s q u i t e s i m i l a r t o a i r c r a c k −ng .
T u t o t r i a l a i r c r a c k −ng : h t t p : //www. a i r c r a c k −ng . o r g / doku . php? i d=s i m p l e_wep_
crack
For ptw :
* In Step 3 , you MUST NOT u s e t h e parameter − i v s . J u s t s k i p t h i s
parameter , t h e o t h e r command l i n e arguments s t i l l apply .
* In Step 5 , you s h o u l d u s e a i r c r a c k −ptw i n s t e a d o f a i r c r a c k −ng . l s −
l a output * . cap w i l l g i v e you a l i s t o f c a p t u r e f i l e s airodump −ng
has c r e a t e d . U s u a l l y , i f you d i d not i n t e r r u p t airodump −ng , t h e r e
s h o u l d be o n l y one f i l e named output − 01. cap . J u s t s t a r t a i r c r a c k −
ptw output − 01. cap t o g e t t h e key . I f a i r c r a c k −ptw was not
s u c c e s s f u l l , wait a few s e c o n d s and s t a r t i t a g a i n .
A i r c r a c k −ng :
sudo a p t i t u d e i n s t a l l b u i l d − e s s e n t i a l
sudo a p t i t u d e i n s t a l l l i b s s l −dev l i b s q l i t e 3 −dev
? sqlite
apt −g e t i n s t a l l l i b p c a p 0 .8 − dev .
8.5 Monitor mode for wi usb key : TL-WN321G chipset Ralink rt73
h t t p : // a i r c r a c k −ng . o r g / doku . php? i d=r t 7 3
wget h t t p : // homepages . tu −darmstadt . de /~p_l a r b i g / wlan / r t 7 3 −k2wrlz − 3 . 0 . 3 . t a r
. bz2
t a r − x j f r t 7 3 −k2wrlz − 3 . 0 . 3 . t a r . bz2
cd r t 7 3 −k2wrlz − 3 . 0 . 3 / Module
make
then
, as root ,
type
make i n s t a l l
modprobe r t 7 3
Conseil perso :
r e c h e r c h e r dans / l i b / modules / 2 . 6 . 3 0 / l e s f i c h i e r s r t 7 3 *
D e p l a c e r l e s modules r t 2 x 0 0 ( r t 7 3 u s b , r t 2 5 0 0 e t c ) dans un d o s s i e r ( / r o o t / r t
−o l d par exemple )
R e c r e e r l e s dependances module :
depmod −ae
et r e d e m a r r e r
E. Branlard
78
CHAPTER 8. WIFI
A c t i v e r l e mode monitor a l a main :
i w c o n f i g r a u s b 0 mode monitor
Ou avec airmon −ng
i f c o n f i g r a u s b 0 up
airmon −ng s t a r t r a u s b 0
La commande i w p r i v donne a c c e s ou " f o n c t i o n s " de l ' i n t e r f a c e
iwpriv raus0
8.6 WIFI, et GESTIONNAIRE DE TROUSSEAU
Avoir s a c o n n e x i o n w i f i mais a chaque f o i s ê t r e o b l i g é de r e n t r e r l e mot
de p a s s e du t r o u s s e a u pour p o u v o i r s e c o n n e c t e r , c ' e s t un peu l o u r d ,
s u r t o u t quand vous ê t e s t o u t s e u l s u r v o t r e machine , nous a l l o n s donc
a u t o m a t i s e r t o u t ça g r a c e à PAM q u i g è r e l ' a u t h e n t i f i c a t i o n automatique
.
I l vous f a u t avant t o u t i n s t a l l e r c e c i =>
Code :
b u i l d −e s s e n t i a l
libtool
l i b g l i b 2 .0 − dev
libgnome −k e y r i n g −dev
libpam0g −dev
E n s u i t e i n s t a l l e z c e c i pam_k e y r i n g .
Maintenant vous avez j u s t e à c o n f i g u r e r l e f i c h i e r gdm dans
/ e t c /pam . d / .
a j o u t e z à l a f i n du document =>
Code :
auth o p t i o n a l pam_k e y r i n g . s o t r y_ f i r s t _p a s s
s e s s i o n o p t i o n a l pam_k e y r i n g . s o
E. Branlard
79
Chapter
9
SERVERS - PHP SQL APACHE SAMBA FTP
SSH
9.1 Free shell servers
USER@shellmix . com −p 22
USER@elitter . n e t
−> a l l o w s
c l o s i n g of the s h e l l !
command
t o be runed even a f t e r
logout
and
9.2 Debian Serveur
LAMP : Linux Apache Mysql Php
m a i l (SMTP avec P o s t f i x e t POP/IMAP avec Cyrus )
temp (NTP)
dns ( bind9 )
l e DHCP ( dhcpd )
p a r t a g e de f i c h i e r s (NFS ou Samba )
i m p r e s s i o n (CUPS)
%%
%
SSH de b a s e − open s s h h s e r v e r ( e t non c l i e n t )
a p t i t u d e i n s t a l l openssh − s e r v e r
%%
%
Pour p l u s de s e c u r i t é e t u t i l i s a t i o n p l u s commode u t i l i s e r d e s c l e f s (
DSA)
# On c r e e l e c o u p l e de c l e f p u b l i q u e / p r i v e e s u r l a machine c l i e n t e
$ ssh −keygen − t dsa
c r e e l e f i c h i e r /home/ c l i e n t u s e r / . s s h / i d_dsa . pub
# i l f a u t e n s u i t e donner l a c l e f p u b l i q u e au s e r v e u r pour q u e l l e f i g u r e
dans l a l i s t e d e s c l e f a u t h o r i s e e de l ' u t i l i s a t e u r s e r v e u r
− s o i t en u t i l i s a n t ssh −copy − i d − i ~/ . s s h / i d_dsa . pub s e r v e r u s e r @ I P
− s o i t en a c t i v a n t temporairement l a c o n n e c t i o n par mot de p a s s e (PAM e t
Password ) , e t en f a i s a n t un s c p ou un echo >> dans l e f i c h i e r /home/
s e r v e r u s e r / . s s h / a u t h o r i z e d_k e y s de l ' u t i l i s a t e u r s e r v e r . Une f o i s l e
t r a n s f e r t e f f e c t u é , on d e s a c t i v e l a c o n n e c t i o n par mot de p a s s e
− s o i t en l a donnant par c l e f USB a l ' a d m i n i s t r a t e u r du s e r v e u r !
80
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
# On redemarre l e s e r v e u r s s h pour p r e n d r e en compte l a c l e f p u b l i q u e du
c l i e n t , e t p o s s i b l e m o d i f i c a t i o n du f i c h i e r s s h d_c o n f i g
%%
%
Exemple d ' o p t i o n s pour l e f i c h i e r s s h d_c o n f i g and p u b l i c key
## Low s e c u r i t y
#Port 12120
#PermitRootLogin no
#RSAAuthentication y e s
#P u b k e y A u t h e n t i c a t i o n no
#A u t h o r i z e d K e y s F i l e
%h / . s s h / a u t h o r i z e d_k e y s
#UsePAM y e s
## Higher s e c u r i t y
Port 12120
PermitRootLogin no
RSAAuthentication y e s
PubkeyAuthentication yes
A u t h o r i z e d K e y s F i l e %h / . s s h / a u t h o r i z e d_k e y s
P a s s w o r d A u t h e n t i c a t i o n no
UsePAM no
A ll o w Us e rs manu
DenyUsers t e s t g u e s t admin r o o t s n o r t apache nobody
MaxStartups 1
%%
%
Pour e n c o r e p l u s de s e c u r i t é avec d e s program q u i b a n i s s e n t
aptitude i n s t a l l t i g e r fail2ban
%%
%
Notes
− i l e s t p r e f e r a b l e que l e f i c h i e r a u t h o r i z e d_k e y s a i t l e s d r o i t s 600
− i l f a u t que dans s s h d_c o n f i g , l e home s o i t r e f e r r é comme ~h / . s s h /
a u t h o r i z e d_k e y s
− u t i l i s e r s s h −v donne l e s d e t a i l s de debug
# s o u s windows , c l i e n t de b a s e : p u t t y
SSH c ' e s t du TCP p o r t 22
# l e s bons t u t o s
h t t p : // t e c h n i q u e . a r s c e n i c . o r g / connexion − d i s t a n t e −au−s e r v e u r −s s h / a r t i c l e /
s e c u r i s a t i o n −ssh −p o u s s e e
h t t p : // doc . ubuntu− f r . o r g / s s h
h t t p : // w i k i . debian − f a c i l e . o r g / c o n f i g : s s h
h t t p : //www. c o a g u l . o r g / s p i p . php? a r t i c l e 1 6 8
# scan d e s p o r t s o u v e r t s
h t t p : //www. f r a m e i p . com/ s c a n / s c a n . php
%%
%
Connexion à un s e r v e u r SSH v i a un a u t r e s e r v e u r SSH
S i vous avez deux s e r v e u r s SSH mais q u i i l e s t n é c e s s a i r e de s e c o n n e c t e r
au p r e m i e r pour p o u v o i r a c c é d e r au deuxième , c e t t e commande permet de
E. Branlard
81
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
r é a l i s e r l e s deux c o n n e x i o n s :
s s h r o o t @ s e r v e u r 1 −t s s h r o o t @ s e r v e u r 2
%%
%
Tunnel c r y p t é en SSH
I l s e peut que vous v o u l i e z é t a b l i r une c o n n e x i o n d i s t a n t e pour t r a n s i t e r
d e s données de manière 100% t r a n s p a r e n t e e t s é c u r i s é e , nous a l l o n s donc
é t a b l i r un t u n n e l s s h .
# s s h −L 5 9 0 1 : l o c a l h o s t : 5 9 0 0 user@80 . 8 0 . 8 0 . 8 0
C e t t e t e c h n i q u e e s t t r è s u t i l e pour r e l i e r en l o c a l un bon nombre d '
u t i l i s a t i o n , comme s u r kde d i s t a n t , un s e r v e u r smtp p e r s o n n e l , une
b o i t e m a i l ( pop ou imap ) p e r s o n n e l l e , un bon nombre d ' u t i l i s a t i o n s
ont r e c o u r s à c e t t e t e c h n i q u e .
D é t a i l s u r l a l i g n e de commande SSH
ssh : invoque l e p r o t o c o l e
−L i n v o q u e de l a c r é a t i o n d ' un t u n n e l c r y p t é
5901 : p o r t c o t é l o c a l
l o c a l h o s t : i n d i q u e que l ' a c c è s s e f e r a en l o c a l de manière
transparente
5900 : p o r t du s e r v i c e d i s t a n t
user@80 . 8 0 . 8 0 . 8 0 : i n d i q u e avec q u e l l e u s e r e t s u r q u e l l e i p on va
é t a b l i r la connection
9.3 Video surveillance - Zone minder
h t t p : //www. csquad . o r g / cocoon / t a g s / p u b l i c / zoneminder / zoneminder . html#N1004A
h t t p : // forum . debian − f r . o r g / v i e w t o p i c . php? f =1&t =17162&view=next
9.4 Telnet
Pour f a i r e du t e l n e t a p r i o r i i l f a u t l a n c e r l e daemon openbsd − i n e t d ( j e l
' a i d e s a c t i v e au demarrage )
Http avec t e l n e t
t e l n e t www. g o o g l e . f r 80
9.5 Creer une base de donnees sql pour amarok
i n s t a l l e r mysql − s e r v e r
l a n c e r MySQL avant de f a i r e c e s m a n i p u l a t i o n s :
sudo / e t c / i n i t . d / mysql s t a r t
pour a c c e d e r a mysql : t a p p e r
mysql −u r o o t −p
#c r e e r un b a s e de donnes pour amarok
h t t p : // mikesubuntu . b l o g s p o t . com/ 2007 / 09 /how−to −s e t −up−mysql −database −in −
amarok . html
$ mysql −p −u r o o t
>CREATE DATABASE amarok ;
>USE mysql ;
>GRANT ALL ON amarok . * TO a m a r o k @ l o c a l h o s t IDENTIFIED BY ' amarok ' ;
>FLUSH PRIVILEGES ;
E. Branlard
82
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
>q u i t
In Amarok u s e t h e f o l l o w i n g s e t t i n g s :
Hostname : 1 2 7 . 0 . 0 . 1
Database : amarok
Port : 3306
Username : amarok
Password : Your Password
9.6 PHP mysql et apache sous ubuntu
h t t p : // g i m i n i k . d e v e l o p p e z . com/ a r t i c l e s / apache / d e b i a n /
# Les p a q u e s t n e c e s s a i r e s
sudo a p t i t u d e i n s t a l l apache2 php5 mysql − s e r v e r php5−mysql l i b a p a c h e 2 −mod−
php5
#Le mot de p a s s e a d m i n i s t r a t e u r mySQL vous e s t demandé : Entrez −en un .
sudo / e t c / i n i t . d / apache2 r e l o a d
#Un a j u s t e m e n t de l a p o l i t i q u e d e s d r o i t s permet de mieux u t i l i s e r ce
répertoire
sudo groupadd www−data
sudo addgroup manu www−data
sudo chown −R www−data :www−data / var /www
sudo chmod −R u=rwX , g=rwXs , o=−−− / var /www
# p e r m e t t r a à apache de l i r e l e r é p e r t o i r e pour p r o d u i r e l e s p a g e s
# p e r m e t t r a à t o u s l e s u t i l i s a t e u r s membres du groupe www−d a t a de
t r a v a i l l e r s u r l e s f i c h i e r s ( en g é n é r a l , i l f a u t c r é e r ce groupe "www−
d a t a " e t s e m e t t r e comme membre )
# p e r m e t t r a à t o u s l e s f i c h i e r s e t r é p e r t o i r e s c r é é s dans ce r é p e r t o i r e d
' a v o i r l e s mêmes p r o p r i é t é s au t r a v e r s du groupe (GIG a c t i v é par g=s )
# f a i r e un l i e n v e r s son d o s s i e r s i t e :
l n − s /home/manu/ S i t e s / var /www/ s i t e s
# C r e a t i o n d ' un f i c h i e r t e s t
echo "<? p h p i n f o ( ) ; ?>" > / var /www/ t e s t . php
Une f o i s l ' i n s t a l l a t i o n terminé , o u v r e z h t t p : // l o c a l h o s t dans v o t r e
navigateur
La r a c i n e de v o t r e s i t e web e s t s i t u é e dans / var /www
e t o u v r e z h t t p : // l o c a l h o s t / t e s t . php dans v o t r e n a v i g a t e u r .
l y n x h t t p : // l o c a l h o s t / t e s t . php
# S i ca ne marche pas e d i t e r / e t c / apache2 / apache2 . c o n f :
AddType a p p l i c a t i o n / x−httpd −php . php
LoadModule php5_module / u s r / l i b / apache2 / modules / l i b p h p 5 . s o
S i vous avez une e r r e u r comme c e l l e − l à :
ERROR 2002 ( HY000 ) : Can ' t c o n n e c t t o l o c a l MySQL s e r v e r through s o c k e t
' / var / run / mysqld / mysqld . sock ' ( 2 )
i l s u f f i t de l a n c e r MySQL avant de f a i r e c e s m a n i p u l a t i o n s :
sudo / e t c / i n i t . d / mysql s t a r t
pour a c c e d e r a mysql : t a p p e r
E. Branlard
83
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
mysql −u r o o t −p
Pour c h a n g e r l e password r o o t :
update mysql . u s e r s e t Password=PASSWORD( " t e s t " ) where User=" r o o t " ;
h t t p : // mikesubuntu . b l o g s p o t . com/ 2007 / 09 /how−to −s e t −up−mysql −database −in −
amarok . html
9.7 Apache - probleme de liens symbolic
c e s i t e −e n a b l e d marche
avec un l i e n s y m b o l i c de / var /www/ s i t e s / dans /home/manu/ S i t e s
e s d r o i s du r e p e r t o i r e s o n t e c r i t u r e pour u t i l i s a t e u r e t groupe
www−data
F a i r e b i e n a t t e n t i o n a l ' o r d r e Deny , Allow q u i e s t par d e f a u l t ,
de d r o i t d ' a c c e s
et
et
,manu :
donc pas
<V i r t u a l H o s t * :80 >
ServerAdmin w e b m a s t e r @ l o c a l h o s t
DocumentRoot
/ var /www
# D i s a b l e a c c e s s t o t h e e n t i r e f i l e system e x c e p t f o r t h e
directories that
# are e x p l i c i t l y a l l o w e d l a t e r .
<D i r e c t o r y />
A l l o w O v e r r i d e None
Order Deny , Allow
Deny from a l l
</ D i r e c t o r y >
<D i r e c t o r y / var /www >
Order a l l o w , deny
a l l o w from a l l
AllowOverride All
Options I n d e x e s FollowSymLinks
</ D i r e c t o r y >
</ V i r t u a l H o s t >
~
9.8 Aide server apache - les bases
Bien r e g a r d e r l e contenu de t o u s l e s f i c h i e r s / e t c / apache2 :
Le l o c a h o s t par d e f a u l t e s t dans s i t e s − a v a i l a b l e s \
Les s i t e s −e n a b l e d s o n t d e s l i e n s v e r s l e s s i t e s − a v a i l a b l e
ports . conf : l e s port sur l e s q u e l s l e serveur ecoute
c o n f . d / : c o n f i g de php , s e c u r i t e s
httpd . c o n f : l e f i c h i e r de c o n f pour l ' u t i l i s a t e u r . A mon a v i s : c ' e s t pas
p l u s mal d ' en m e t t r e un dans son home , e t d ' i n c l u r e c e f i c h i e r a l a
f i n de apache2 . c o n f
E. Branlard
84
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
A t t e n t i o n a l ' o p t i o n : " A l l o w O v e r r i d e None" , l e s . h t a c c e s s n ' ont aucun
e f f e t a c a u s e de c e l a
Ce s i t e a l e m e r i t e d ' e t r e s i m p l e ( sauve dans c o n f i g ) :
h t t p : // b l a i r e a u l i n u x . f r e e . f r / apache . php
h t t p : //www. nemako . n e t / dc2 / ? p o s t / 2006 / 01 / 13 /77− p e r s o n n a l i s e r −apache −avec −
htaccess
9.9 Aide server apache - l'autoindex et le probleme de php
Hierarchie :
#l e s i t e en q u e s t i o n
h t a c c e s s #d e f i n i t l e s changement de r e g l e s pour l '
option Indexes − autoindex
/ var /www/ s i t e s / s i t e 1 /_i n c l u d e s / . h t a c c e s s
#! ! ! t r e s i m p o r t a n t : a u t o r i s e
l e php
/ var /www/ s i t e s / s i t e 1 /_i n c l u d e s / h e a d e r . php
# l e nouveau h e a d e r
/ var /www/_i n c l u d e s / −> s i t e s / s i t e s 1 /_i n c l u d e s / h e a d e r . php
#un l i e n
s y m b o l i q u e a p a r t i r de l a r a c i n e du s i t e
/ var /www/ s i t e s / s i t e 1 /
/ var /www/ s i t e s / s i t e 1 / .
Mon httpd . c o n f :
#pour a c t i v e r l e . h t a c c e s s dans ce d o s s i e r , e t a i n s i changer l ' o p t i o n
indexes
<D i r e c t o r y " / var /www/ s i t e s / s i t e 1 / ">
AllowOverride All
Order a l l o w , deny
a l l o w from a l l
</ D i r e c t o r y >
#pour a u t o r i s e r un h e a d e r / f o o t e r en php , en l e c o n s i d e r a n t comme du t e x t e
<D i r e c t o r y " / var /www/_i n c l u d e s / ">
AllowOverride All
Order a l l o w , deny
a l l o w from a l l
</ D i r e c t o r y >
#. h t a c c e s s a l a r a c i n e de s i t e 1 : on change l a methode d ' i n d e x a t i o n
Options I n d e x e s
I n d e x O p t i o n s FancyIndexing F o l d e r s F i r s t
I n d e x O p t i o n s SuppressHTMLPreamble
IndexOptions SuppressDescription
I n d e x O p t i o n s NameWidth=50
HeaderName /_i n c l u d e s / h e a d e r . php
ReadmeName /_i n c l u d e s / f o o t e r . php
IndexIgnore . htaccess
#. h t a c c e s s dans l e d o s s i e r /_i n c l u d e s / : c o n s i d e r e l e php comme du t e x t e ,
uniquement dans ce d o s s i e r !
# on supprime l e l i s t a g e dans ce d o s s i e r par s e c u r i t e
AddType t e x t / html . php
E. Branlard
85
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
AddHandler a p p l i c a t i o n / x−httpd −php . php
Options − I n d e x e s
9.10 Aide server apache - protection par mot de passe
p r o t é g e r des pages
et
répertoires
Dans c e c h a p i t r e , nous a l l o n s v o i r l e s d i f f é r e n t e s é t a p e s pour p r o t é g e r
l e s p a g e s c o n t e n u e s dans / var /www/ t e s t / e t s e s sous − r é p e r t o i r e s .
1 . c r é e r un f i c h i e r mot de p a s s e s ( v i d e pour l ' i n s t a n t ) , par exemple
www/ . htpasswd
2 . é d i t e r l e f i c h i e r de l a forme :
f r e d : gWK3udIcGH832
bob : BgG6vsQflVS66
/ var /
Ce f i c h i e r d o i t c o n t e n i r l e s mots de p a s s e s o u s forme c r y p t é e uniquement .
Pour l e c r é e r , i l f a u t d ' abord m e t t r e n ' i m p o r t e q u o i à l a p l a c e du mot
de p a s s e .
Exemple :
fred : blabla
bob : bob
Puis , pour l e s c r y p t e r , on va t a p e r " htpasswd −b / var /www/ . htpasswd bob
mot−de−p a s s e en c l a i r " . Maintenant , l e mot de p a s s e de bob s e r a c r y p t é .
I l f a u t f a i r e p a r e i l avec t o u s l e s comptes . S i on ne veut pas que l e
mot de p a s s e a p p a r a i s s e en c l a i r s u r l a l i g n e de commande , i l f a u t
t a p e r " htpasswd / var /www/ . htpasswd bob" e t i l va demander de t a p e r l e
mot de p a s s e .
3 . é d i t e r l e f i c h i e r / var /www/ t e s t / . h t a c c e s s e t c o p i e r dedans :
A u t h U s e r F i l e / var /www/ . htpasswd
# f i c h i e r mot de p a s s e
AuthGroupFile / dev / n u l l
# idem pour l e groupe
AuthName " Accés r é s e r v é "
# t e x t e q u i a p p a r a i t dans l a b o i t e de
dialogue
AuthType B a s i c
# pour l u i d i r e d ' u t i l i s e r A u t h U s e r F i l e
<L im it GET POST>
R e q u i r e v a l i d −u s e r
# a u t o r i s e t o u s l e s u t i l i s a t e u r s q u i s o n t dans .
h t p a s s w d . On p o u r a i t m e t t r e " R e q u i r e u s e r f r e d " pour n ' a u t o r i s e r que
fred
</ Limit>
9.11 iptables
h t t p : // w i k i . d e b i a n . o r g / i p t a b l e s
#l i s t i n g
i p t a b l e s −− l i s t
#c l e a r i n g them
i p t a b l e s −F
i p t a b l e s −X
E. Branlard
86
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
iptables
iptables
iptables
iptables
iptables
iptables
−t
−t
−t
−t
−P
−P
nat −F
nat −X
mangle −F
mangle −X
INPUT ACCEPT
OUTPUT ACCEPT
9.12 Server FTP
a p t i t u d e i n s t a l l f t p d ( openbsd − i n e t d )
ou
aptitude i n s t a l l proftpd
#
/ e t c / i n i t . d/ p r o f t p d s t a r t
# L i s t e des e x c l u s
/etc/ftpusers
# Security
− i n s t a l l e r f a i l 2 b a n ( ! ! ! ! ) e t l e c o n f i g u r e r dans / e t c / f a i l 2 b a n / j a i l . l o c a l
( ! ! ! read below )
− i n s t a l l e r L y n i s t i g e r c h k r o o t q u i a i d e n t a d e t e c t e r l e s f a i l l e s de
securites
− i n s t a l l e r ufw
#f a i l 2 b a n problem avec i p t a b l e s
i p t a b l e s ne peut pas r e c e v o i r t r o p de commandes a l a s u i t e
m o d i f i e r / e t c / f a i l 2 b a n / a c t i o n s . d/
i p t a b l e s . conf
et
i p t a b l e s −m u l t i p o r t
mettre
sleep 3.0
a p r e s l a p r e m i e r e l i g n e de a c t i o n s t a r t
et
actionstop
s u r i n t e r n e t un mec p r o p o s e q u e l q u e c h o s e d ' a l e a t o i r e :
a c t i o n s t a r t = s l e e p $ {RANDOM: 0 : 1 } . $ {RANDOM: 0 : 1 }
i p t a b l e s −N f a i l 2 b a n −<name>
i p t a b l e s −A f a i l 2 b a n −<name> − j RETURN
i p t a b l e s − I INPUT −p <p r o t o c o l > −m m u l t i p o r t −− d p o r t s <port>
− j f a i l 2 b a n −<name>
%%
%Livebox
: Les p a s s i v e s p o r t s c ' e s t t r e s i m p o r t a n t ! ! !
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? i d =110641
p l a g e s de p o r t f t p :
a c t i v e : 20 − 21 20 − 21
p a s s i v e : 6000 − 6100 6000 − 6100
#<I f M o d u l e mod_dynmasq . c>
# DynMasqRefresh 28800
#</ IfModule >
#MasqueradeAddress %%%%%%. dyndns . org
E. Branlard
87
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
#DisplayXXX i l f a u t a v o i r l e s d r o i t s d ' a c c e s aux f i c h i e r s welcome , connect
, q u i t , goaway . . .
#
/etc/ i n i t
. d/ f a i l 2 b a n s t a r t
. d / ufw s t a r t
/ e t c / i n i t . d/ p r o f t p d s t a r t
#
/etc/ i n i t
Run t h e Ufw f i r e w a l l w i z a r d .
I n s t a l l a r a t e l i m i t i n g r u l e t o guard a g a i n s t DOS and b r u t e f o r c e r s :
# General new c o n n e c t i o n r a t e l i m i t i n g f o r DOS and Brute Force p r o t e c t i o n
i p t a b l e s − I INPUT −p TCP −m s t a t e −− s t a t e NEW −m l i m i t \
−− l i m i t 30 / minute −− l i m i t − b u r s t 5 − j ACCEPT
9.13 DynDNS
− C r e e r un compte g r a t u i t s u r dyndns
− c r e e r un h o s t ( avec IP a d d r e s s )
− C o n f i g u r e r l a Livebox h t t p : // 1 9 2 . 1 6 8 . 1 . 1
C o n f i g u r a t i o n / Avancee / DNS Dynamique
Nom du compte ( l o g i n de DynDNS)
Password l o g i n DynDNS
HostNane : c e l u i c h o i s i t s u r DynDns ( m o n s e r v e u r f t p . dyndns . o r g )
− Configurer l a l i v e b o x 2 : r e d i r e c t i o n des ports
S e r v e u r s LAN, A j o u t e r .
Nom du s e r v e u r : " S e r v e u r web" . (HTTP ou FTP)
P r o t o c o l e : TCP q u i e s t l e p r o t o c o l e g é n é r a l e m e n t u t i l i s é pour l e s
s e r v e u r s web .
Du p o r t 80 Au p o r t 8 0 .
A d r e s s e IP l o c a l e : c ' e s t l ' a d r e s s e IP de l a machine où e s t i n s t a l l é l e
s e r v e u r . E l l e e s t de l a forme 1 9 2 . 1 6 8 . 1 .XXX
9.14 Voisimage reseau : pyNeighborhood
#pyNeighborhood e s t un t r e s bon l o g i c i e l pour v o i s i n a g e r e s e a u
a p t i t u d e i n s t a l l pyNeighborhood
#Changer l e s commandes de montage / demontage en m e t t a n t sudo d e v a n t
#Au l i e u de umount . c i f s , m e t t r e umount
!
9.15 Samba fusesmb pyNeighborhood
E. Branlard
88
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
# pour l e s e r v e u r i n s t a l l e r samba
a p t i t u d e i n s t a l l samba
#e t d e f i n i r un nom de reseau , comme WORKGROUP
# pour l e c l i e n t i n s t a l l e r s m b c l i e n t
#samba
$ nmblookup VJK
q u e r y i n g VJK on 8 2 . 2 1 1 . 2 0 6 . 2 5 5
8 2 . 2 1 1 . 2 0 6 . 1 4 2 VJK<00>
8 2 . 2 1 1 . 2 0 6 . 9 2 VJK<00>
# <00> e s t l e c a s c o u r a n t <20> e s t pour un s e r v e u r
#c h e r c h e r
nmblookup
#c h e r c h e r
nmblookup
pour l e r e s e a u BRANET OU pour l e s r e s a u x SAMBA
BRANET __SAMBA__
pour l e r e s e a u BRANET ET pour l e s r e s a u x SAMBA
−B BRANET __SAMBA__
# This time we are t e s t i n g t h e a b i l i t y o f programs ( such as nmbd ) t o use
b r o a d c a s t . I t ' s e s s e n t i a l l y a c o n n e c t i v i t y t e s t , done v i a a b r o a d c a s t
t o t h e d e f a u l t b r o a d c a s t a d d r e s s . A number o f NetBIOS /TCP−IP h o s t s on
t h e network s h o u l d respond w i t h " g o t a p o s i t i v e name q u e r y r e s p o n s e "
messages . Samba may not c a t c h a l l o f t h e r e s p o n s e s i n t h e s h o r t time i t
l i s t e n s , so you won ' t a l w a y s s e e a l l t h e SMB c l i e n t s on t h e network .
However , you s h o u l d s e e most o f them :
manu@server $ nmblookup −d 2 ' * '
# l e −N c ' e s t pour e t r e anonyme , j e pense que ca d o i t r e v e n i r au meme que
−U% pour l e s s e r v e u r SAMBA mais pas pour windows
$ s m b c l i e n t −N −L 8 2 . 2 1 1 . 2 0 6 . 1 4 2
Domain=[KINGS−WIN] OS=[Windows 5 . 1 ] S e r v e r =[Windows 2000 LAN Manager ]
Sharename
Type
Comment
−−−−−−−−−
−−−−
−−−−−−−
SharedDocs
Disk
$smbclient
$smbclient
\\\\ k i n g s −win \\ SharedDocs −U u s e r passwd
' \ \ k i n g s −win \ SharedDocs ' −U u s e r passwd
' \ \ k i n g s −win \ SharedDocs ' −N
$smbclient
' \ \ olympe \ P u b l i c ' −N
$smbclient
smb : \> q u i t
#fusesmb
cp / u s r / s h a r e / doc / fusesmb / examples / fusesmb . c o n f . ex
chmod 600 ~/ . smb/ fusesmb . c o n f
E. Branlard
~/ . smb/ fusesmb
. conf
89
CHAPTER 9. SERVERS - PHP SQL APACHE SAMBA FTP SSH
9.16 Communiquer avec les reseaux microsoft
#I n s t a l l a t i o n de Samba , p o l i c e s M i c r o s o f t e t c a b e x t r a c t
sudo apt −g e t i n s t a l l samba m s t t c o r e f o n t s c a b e x t r a c t
#j o u t de l ' u t i l i s a t e u r au groupe sambashare d o i v e n t e t r e a u t o m a t i q u e
sudo a d d u s e r $USER sambashare
9.17 Activation du voisinage réseau Windows dans Thunar
#I n s t a l l a t i o n de fusesmb :
sudo apt −g e t i n s t a l l fusesmb
#V é r i f i e r l a p r é s e n c e du module f u s e dans / e t c / modules :
sudo vim / e t c / modules
#modprobe fusemb
#Redémarrer l e s e r v e u r X : C t r l + A l t + b a c s Space
#menu XFCE / Système / Users
: c o c h e r pour l e s u t i l i s a t e u r s d e v a n t
utiliser
9.18 fusemb
sudo modprobe f u s e
#I l f a u t e n s u i t e p e n s e r à r a j o u t e r l e groupe f u s e à v o t r e u t i l i s a t e u r .
sudo gpasswd −a $USER f u s e
#
cd ~
mkdir −p Network
fusesmb Network
A p a r t i r de maintenant , vous pouvez v o i r l e v o i s i n a g e r é s e a u de l a forme «
DOMAINES/MACHINES/PARTAGES » . Pour démonter l e p o i n t de montage :
fusermount −u Network
E. Branlard
90
Chapter
10
OTHERS
10.1 Lire wmv windows media video ?
sudo a p t i t u d e i n s t a l l w32codecs
10.2 Java Gcj versus Sun - select defaults JVM
sudo update − a l t e r n a t i v e s −− c o n f i g j a v a
( g c j −b a s e )
( sun−j a v a )
10.3 Script shell -Command FIND - manipulation album cover le
#f i n d . / −name " * . j p g "
toCover . sh :
#! / b i n / sh
− e x e c echo " ` dirname "{}" ` / c o v e r . j p g " \ ;
a=$ 1
"$a "
path =` dirname " $ a " `
echo " $ path "
cp " $ a " " $ path / c o v e r . j p g "
echo " "
echo
f i n d . / −name " * . j p g "
f i n d . / −name " * . JPG"
−exec . / toCover . sh ' { } ' \ ;
−exec . / toCover . sh ' { } ' \ ;
f i n d . / −name " * .wma"
−exec wma2mp3 ' { } ' \ ;
f i n d . /* − s i z e 0b −type f −exec
rm
{} \ ;
10.4 Connexion ssh avec mot de passe automatique, methode bourrin
mot de passe en clair
91
CHAPTER 10. OTHERS
U t i l i s a t i o n d ' expect ( a i n s t a l l e r )
C r e a t i o n d ' un s c r i p t :
#!
/usr/bin/ expect
−f
f o r c e_c o n s e r v a t i v e 1 ;
set
set timeout 2
spawn s s h ton −l o g i n @ l a −ou−tu −veux
e x p e c t " password : $ "
send " ton −passwd \n"
interact
10.5 Nvidia drivers
A c t u a l l y s i n c e you a l r e a d y have a n v i d i a d r i v e r s i n s t a l l e d you s h o u l d be
a b l e t o g e t away with :
# a p t i t u d e i n s t a l l n v i d i a − k e r n e l −s o u r c e module − a s s i s t a n t k e r n e l −p a c k a g e
l i n u x −headers − 2.6.30 − 1 − 686
Then , boot i n t o t h e new k e r n e l and , a f t e r you g e t dumped t o t h e c o n s o l e :
m−a a− i n v i d i a − k e r n e l −source
Fuck i t , t e l e c h a r g e r
nvidia
et
u t i l i s e r l e s d r i v e r s p r o p r i e t a i r e s s u r l e s i t e web
10.6 Timidity is not yet congured.
When r u n n i n g :
i t shows
/etc/ i n i t
. d/ t i m i d i t y s t a r t
T i m i d i t y i s not y e t c o n f i g u r e d .
Enable Alsa S e q u e n c e r f i r s t by e d i t i n g
/etc/default/timidity
.
sudo nano / e t c / d e f a u l t / t i m i d i t y
and uncomment t h e l i n e f o r ALSASEQ
10.7 Midi
1 . I n s t a l l TiMidity++. I f you a r e a Debian u s e r , t h i s package i s
a v a i l a b l e i n t h e o f f i c i a l r e p o s i t o r i e s . Other b i n a r y v e r s i o n s may be
a v a i l a b l e . You can a l s o c o m p i l e from source . I n s t r u c t i o n s and
download l o c a t i o n a v a i l a b l e a t t h e TiMidity w e b s i t e . Binary p a c k a g e s
for select d i s t r o s :
* Debian package
* Slackware b i n a r i e s
* RPM p a c k a g e s
2 . Get some good sound p a t c h e s . Debian u s e r s can u s e F r e e p a t s . But I
recommend t h e eaw p a t c h e s which a r e o f h i g h e r q u a l i t y . No Debian
p a c k a g e s a r e a v a i l a b l e , but l u c k i l y you can j u s t download i t and
e x t r a c t i t i n any l o c a t i o n . You can download t h e t a r . gz h e r e . J u s t
e x t r a c t i t i n t o your home d i r e c t o r y . Let ' s say /home/ h a r i / eawpats .
E. Branlard
92
CHAPTER 10. OTHERS
3 . R ep la c e t h e d e f a u l t TiMidity++ t i m i d i t y . c f g f i l e ( rename t h e o l d
f i l e t o something l i k e t i m i d i t y . c o n f . o l d ) with t h e one i n t h e /home/
h a r i / eawpats / l i n u x c o n f i g f o l d e r . J u s t e d i t i t t o make s u r e t h e
l o c a t i o n p o i n t s t o t h e d i r e c t o r y where you e x t r a c t e d t h e EAW p a t c h e s
. The c o n f i g f i l e i s l o c a t e d u s u a l l y i n t h e / e t c / t i m i d i t y / f o l d e r i n
Debian . I don ' t know about o t h e r d i s t r o s . Here i s how t h e f i l e
l o o k s l i k e . J u s t change t h e d i r s e t t i n g t o w h i c h e v e r l o c a t i o n you
e x t r a c t e d t h e EAW p a t c h e s t o :
dir
/ home / h a r i / eawpats /
gravis . cfg
gsdrums . c f g
source g s s f x . c f g
source xgmap2 . c f g
#mid −> wav : t i m i d i t y i n p u t . mid −Ow1S − s 44100 −o o u t p u t . wav
source
source
A l l r i g h t , you ' ve now i n s t a l l e d i t . To
f i l e . I f you have one , j u s t run
test
i t , you need t o p l a y a MIDI
t i m i d i t y f i l e n a m e . mid
10.8 FFMPEG et MP3 lame sous debian
h t t p : // b l o g . f c l e m e n t . i n f o / c o n t e n t / ffmpeg −et−mp3−avec −d e b i a n
conversion
ffmpeg − i %f −vn − a r 44100 −ac 2 −ab 128 k −y %n . mp3
ffmpeg − i %f − vcodec mpeg2video − a c o d e c libmp3lame − a r 22050 − s 320 x240 −y
%n . a v i
ffmpeg − i Test_a v i . a v i − vcodec mpeg2video − a c o d e c libmp3lame − a r copy − s
copy −y out . a v i
mencoder en 2 p a s s e s avec
−ovc l a v c − l a v c o p t s vcodec=mpeg4 avec un b i t r a t e =(HxL) / 325 à (HxL) / 350 où
H et L s o n t l e s l a r g e u r et h a u t e u r .
Le b i t r a t e v i d e o par d é f a u t de mencoder , j e c r o i s e s t de 8 0 0 . J ' u t i l i s a i s
plutôt 900.
10.9 Create from template
Dans l e home c r e r un d o s s i e r Template
et
en a j o u t e r
10.10 Probleme gnome barre verticale - liste de fenetres
h t t p s : // bugs . launchpad . n e t / ubuntu /+source / gnome−p a n e l /+bug / 187540
E. Branlard
93
CHAPTER 10. OTHERS
I ' ve c r e a t e d p a t c h e s f o r gnome−p a n e l and l i b w n c k s o l v i n g t h i s bug .
A p p l i c a b l e f o r gnome−p a n e l 1 : 2 . 2 2 . 2 − 0 ubuntu1 and l i b w n c k 2 2 2.22.1 − 0
ubuntu1 a s they a r e i n Hardy .
Dans un p r e m i e r temps on t e l e c h a r g e l e s o u t i l s n e c e s s a i r e s , l e s s o u r c e s
p a q u e t s d ' i n s t a l l . On p l a c e r a t o u t ca dans l e r e p e r t o i r e gnomepatch
Depuis l e r e p e r t o i r e p e r s o :
mkdir gnomepatch
cd gnomepatch
sudo apt −g e t i n s t a l l f a k e r o o t
sudo apt −g e t i n s t a l l d e v s c r i p t
sudo apt −g e t b u i l d −dep gnome−p a n e l
sudo apt −g e t b u i l d −dep l i b w n c k
apt −g e t source gnome−p a n e l
apt −g e t source l i b w n c k
et
E n s u i t e , r e c u p e r e r l e s p a t c h s de p u i s l e s i t e
h t t p s : // bugs . launchpad . n e t / ubuntu /+source / gnome−p a n e l /+bug / 187540
( j e l e s a i g a r d e s s u r mon d i s q u e )
D e t a r r e r paskma−patch . t a r en mettant t o u s l e s f i c h i e r s dans n o t r e
r e p e r t o i r e gnomepatch
I l f a u d r a p e u t e t r e m o d i f i e r l e s f i c h i e r s s i l e s v e r s i o n s s o n t mauvaises .
Pour moi , l i b w n c k en e t a i t a l a v e r s i o n 3 e t non 1 .
On patch :
patch −p0 < gnome−panel −paskma . patch
patch −p0 < gnome−panel −paskma−c h a g n e l o g . patch
patch −p0 < libwnck −paskma . patch
patch −p0 < libwnck −paskma−c h a g n e l o g . patch
gnome−panel − 2 . 2 2 . 2
d e b u i l d −us −uc
cd . .
cd
libwnck − 2 . 2 2 . 1
d e b u i l d −us −uc
cd . .
cd
On i n s t a l l e
sudo dpkg − i * . deb
Et l a c ' e s t de l a b a l l e
10.11 Mot de passe mise en veille
gcon f − e d i t o r
Se r e n d r e dans l a branche apps > gnome−power−manager > l o c k
Décocher l a c a se h i b e r n a t e pour d é s a c t i v e r l e mot de p a s s e l o r s de l a
s o r t i e du mode h i b e r n a t i o n .
Décocher l a c a se suspend pour d é s a c t i v e r l e mot de p a s s e l o r s de l a s o r t i e
du mode v e i l l e .
Décocher l a c a se gnome_k e y r i n g_h i b e r n a t e pour ne pas b l o q u e r l e mot de
p a s s e du t r o u s s e a u l o r s de l a s o r t i e du mode v e i l l e ( par exemple quand
on e s t c o n n e c t é au w i f i ) .
E. Branlard
94
CHAPTER 10. OTHERS
10.12 NetworkManager - wi au reveil apres mise en veille ou hibernation
gcon f − e d i t o r
Se r e n d r e dans l a branche apps > gnome−power−manager > g e n e r a l
sleep
/
network_
10.13 Histoire de memoire vive detectee
Compiler l e K e r n e l avec CONFIG_HIGHMEM64G=y ? ? ? ?
c a r i l s e b l r e a i t que 4Gb ne s u f f i s e n t pas .
10.14 Virer le Usplash splash screen demarrage ubuntu
sudo / boot / grub /menu . l s t
v i r e r l e s o p t i o n s q u i e t et s p l a s h
Pour p a s s e r au s p l a s h s c r e e n d ' xubuntu , i l f a u t a p r è s a v o i r t a p é ça ( c f l a
doc ) :
Code :
sudo update − a l t e r n a t i v e s −− c o n f i g u s p l a s h −artwork . s o
e t c h o i s i l e s p a s h d ' xubuntu , i l f a u t t a p e r c e t t e commande é g a l e m e n t q u i
génère l e spash s c r e e n
Code :
sudo dpkg− r e c o n f i g u r e l i n u x −image −$ ( uname − r )
e n s u i t e on peut s u p p r i m er / u s r / l i b / u s p l a s h / u s p l a s h −theme−ubuntu . s o
10.15 Optimisation - Preload
P r e l o a d e s t un "daemon a d a p t a t i f pour readahead " , q u i s e l a n c e en t a c h e de
fond s u r v o t r e système , q u i o b s e r v e q u e l programme vous u t i l i s e z l e
p l u s souvent , e t l e s met en c a c h e en vue d ' a c c é l é r e r l e temps de
chargement d e s a p p l i c a t i o n s . En u t i l i s a n t Preload , vous m e t t e r e z v o t r e
mémoire non u t i l i s é au t r a v a i l ( en g r o s e l l e s e r a u t i l i s é u t i l e m e n t ) ,
e t a m é l i o r e r l e s p e r f o r m a n c e s g é n é r a l de v o t r e o r d i n a t e u r de bureau .
I n s t a l l e r P r e l o a d s u r Ubuntu e s t f a i s a b l e f a c i l e m e n t avec l a commande :
sudo apt −g e t i n s t a l l p r e l o a d
10.16 Optimisation - Démarrer les applications plus rapidement avec
Prelink
sudo apt −g e t i n s t a l l p r e l i n k
sudo g e d i t / e t c / d e f a u l t / p r e l i n k
Changer l ' o p t i o n :
PRELINKING=unknown en PRELINKING=y e s
Pour l a n c e r P r e l i n k , t a p e r l a commande s u i v a n t e dans l a c o n s o l e :
sudo / e t c / c r o n . d a i l y / p r e l i n k
C e c i p r e n d r a q u e l q u e s temps à f i n i r ( a u t o u r de 10 − 15 minutes ) .
E. Branlard
95
CHAPTER 10. OTHERS
S i vous v o u l e z l a n c e r P r e l i n k à chaque f o i s que vos mettez à j o u r v o t r e
système , a j o u t e r un s c r i p t dans l e d o s s i e r / e t c / apt / apt . c o n f . d /
( quand i l d i t s c r i p t c ' e s t un f i c h i e r h e i n . . . ) , a p p e l l é l e S 9 9 p r e l i n k , e t
mettez l a l i g n e s u i v a n t e à l ' i n t é r i e u r :
DPkg : : Post −Invoke { " echo Running p r e l i n k , p l e a s e w a i t . . . ; / e t c / c r o n . d a i l y /
prelink " ;}
10.17 Optimisation - Suppression services
##Manually :
/etc/ i n i t . d
/etc/rc0 . d
/ etc /rcS . d
%%
%
Nouveau o u t i l , g r a p h i q u e mais b i e n p l u s complet : BUM
sudo a p t i t u d e i n s t a l l bum
%%
%
I n s t a l l a t o o l − sysv −rc −c o n f . I t i s a p e r l based boot p r o c e s s adjustment
tool .
Code :
sudo apt −g e t update
sudo apt −g e t i n s t a l l sysv −rc −c o n f
sudo sysv −rc −c o n f
a c p i d (D? )
a c p i −s u p p o r t
s u p p o r t de l ' a c p i ( g e s t i o n de l ' é n e r g i e )
alsa
s e r v e u r de son
alsa −u t i l s :
anacron (D) : s y n c h r o n i s a t i o n s
apmd
u s e f u l l f o r b a t t e r y monitor demon apm ( a n c i e n a c p i ) (
g e s t i o n de l ' é n e r g i e )
apparmor (D)
service , securite )
a p o r t (D)
( i n f o sur l e s crash )
atd (D)
daemon atd ( d i f f é r e n t de c r o n dans l e p r i n c i p e )
aumix (D? i f d i f f e r e n t than amixer ) : manager son en mode t e x t e
avahi −daemon (D? ) :
permet de d é c o u v r i r automatiquement l e s r e s s o u r c e s
r é s e a u e t de s ' y c o n n e c t e r
binfmt −s u p p o r t :
pour wine − u t i l i s e r d ' a u t r e s b i n format
b o o t c l e a n . sh
e f f a c e l e s r é p e r t o i r e s /tmp , / var / run e t / var / l o c k
b o o t l o g d (D)
un d e s p e r m i e r s s c r i p t s e x é c u t é , l a n c e l e daemon
bootlogd
b o o t m i s c . sh
e f f e c t u e d i v e r s e s t â c h e s , g e n r e s a u v e r l e r é s u l t a t de
dmesg dans / var / l o g / dmesg , a f f i c h e r l e motd , e t c )
c h e c k f s . sh
v é r i f i e s i l e s p a r t i t i o n s d é f i n i e s dans / e t c / f s t a b ont
besoins d ' être v é r i f i é e s ( fsck )
c h e c k r o o t . sh
v é r i f i e s i l a r a c i n e e s t ok , monte l e s swap d é f i n i s
dans / e t c / f s t a b , en c a s de problème boot en s i n g l e mode
c o n s o l e − s c r e e n . sh
i n i t i a l i s e l a c o n s o l e ( p o l i c e s notamment , d é f i n i par
c o n s o l e −t o o l s )
cpid
daemon a c p i ( g e s t i o n d ' é n e r g i e )
cron
(ON)
daemon crond , q u i l a n c e d e s t a c h e s de manière
périodique
cups
(D)
gestionnaire d ' impression
E. Branlard
96
CHAPTER 10. OTHERS
c u p s y s (D)
gestionnaire d ' impression
dbus −1
daemon dbus ( h t t p : //www. f r e e d e s k t o p . o r g / S o f t w a r e / dbus )
dhcdbd (ON) :
I n t e r f a c e D−Bus pour l e c l i e n t DHCP ISC
discover
e s s a y e de d é t e c t e r t o u t ton m a t é r i e l
dns− c l e a n
e f f a c e l e s f i c h i e r s / e t c / r e s o l v . c o n f l a i s s é e par ppp
evms
daemon q u i g è r e l e s t o c k a g e d ' une manière avancée
exim4
: g e s t i o n de m a i l −> p a q u e t s d e s t i n s t a l l é s
fancontrol :
( p a r t i e du paquet lm− s e n s o r s )
fam
F i l e A l t e r a t i o n Monitor , permet de n o t i f i e r l e s programme
d ' un changement s u r l e s f i c h i e r s ( g e n r e tu ouvre ton home dans
konqueror , dans un c o n s o l e tu e f f a c e un f i c h i e r dans ton home ,
k o n q u e r o r a f f i c h e r a immédiatement l a m o d i f i c a t i o n , s a n s b e s o i n de
r e c h a r g e r l e r é p e r t o i r e ) , a c t u e l l e m e n t r e m p l a c é par gamin
fetchmail
m a i l ? r é c u p é r e r d e s m a i l s s u r d e s s e r v e u r s d i s t a n t s ( pop /
imap )
gdm
g e s t i o n n a i r e de c o n n e x i o n g r a p h i q u e ( l e t r u c q u i vous
demande v o t r e l o g i n / p a s s )
h a l (ON) :
g e s t i o n n a i r e d e s p e r i p h e r i q u e s ( combiné à Udev / Dbus ) e s t
un système q u i permet d ' a u t o d e t e c t e r l e s p é r i p h é r i q u e s )
halt
pour a r r e t e r l e PC
hddtemp (D) : used by s e n s o r s u t i l s
hdparm
g e s t i o n d e s DD ( r é g l a g e d e s d i s q u e s dur , g e n r e
a c t i v e r l e DMA, m e t t r e en udma5 ) e t é t a t du r a i d v i a / p r o c / mdstat
hostname . sh
d e c l a r a t i o n de ton hostname ( à p a r t i r de / e t c /
hostname )
hotplug
l a n c e d i f f é r e n t s sous −s y s t è m e s h o t p l u g ( à p a r t i r
de / e t c / h o t p l u g e t / e t c / h o t p l u g . d ) g è r e t o u t c e q u i e s t d é t e c t i o n du
m a t é r i e l , comme l ' i n s e r t i o n d ' un m a t é r i e l , e t c ) , a s s e z complexe )
h w c l o c k f i r s t . sh
s y n c h r o n i s e l ' h o r l o g e m a t é r i e l l e avec l ' h o r l o g e
logicielle
hwclock . sh
ifupdown
i n i t i a l i s e l ' é t a t d e s i n t e r f a c e s ( a c t i v é e s ou non )
inetd
daemon i n e t d , s e r t à l a n c e r d ' a u t r e s s e r v i c e s (
s e r v e u r f t p , http , e t c ) de manière s p o r a d i q u e
i n i t r d − t o o l s . sh
s ' occupe de l ' i n i t r d ( l i b é r a t i o n e t r é c u p é r a t i o n
de l a mémoire u t i l i s é e par c e l u i − c i )
ivman (ON) :
l i k e h a l s u p p o r t automount o f d i f f e r e n t media
jabber :
j a c k d (D? ) :
s e r v e r de son p e r m e t t a n t c o n n e x i o n s au p e r i p h e r i q u e a u d i o
keyboard − :
keymap . sh
c h a r g e l e mappage c l a v i e r adéquat
k l o g d (D)
daemon q u i e n r e g i s t r e l e s m ess age s du noyau
l a p t o p −mode ( p a r s i n g t e t e de l e c t u r e , g e s t i o n d i s q u e pour economie d '
energie , batterie )
libdevmapper1 . 0 0
gère l e s f i c h i e r s périphériques né cés sa ir es à
libdevmapper
lm− s e n s o r s (D? ) :
l p d (D) :
printing service
lvm
g e s t i o n n a i r e de s t o c k a g e avancé
makedev
c r é e l e s f i c h i e r s de p é r i p h é r i q u e dans / dev
mdadm
monte l e s a r r a y s r a i d d é f i n i e s dans / e t c /
mdadm/mdadm . c o n f
mdadm− r a i d
l a n c e l e daemon q u i s u r v e i l l e l e s a r r a y s r a i d
module− i n i t − t o o l s ( S )
r é s o u d r e l e s dépendances e t c h a r g e r l e s modules
nécessaires
modutils
chargement d e s modules
mountover ( S )
m o u n t a l l . sh
montage d e s p a r t i t i o n ( s y s t è m e s de f i c h i e r s " l o c a u x "
i e non r é s e a u x d é f i n i s dans / e t c / f s t a b )
E. Branlard
97
CHAPTER 10. OTHERS
mountnfs . sh
monte l e s système de f i c h i e r s n f s e t samba f i g u r a n t
dans / e t c / f s t a b
mountvirtfs
montage f s v i r t u e l ( / proc , tmpfs , d e v p t s , / sys ,
usbfs )
networking
a c t i v a t i o n d e s i n t e r f a c e s r é s e a u x d é f i n i e s dans /
e t c / n e t w o r k i n g / i n t e r f a c e s et r è g l e q u e l q u e s a u t r e s t r u c s , g e n r e l e
f o r w a r d i n g , l a p r o t e c t i o n syn c o o k i e s , l ' a n t i − s p o o f i n g )
n f s −common (D? )
ntpdate
s y n c h r o n i s a t i o n de l ' h o r l o g e l o g i c i e l l e à l ' a i d e
d ' un s e r v e u r de temps v i a l e p r o t o c o l e ntp
n v i d i a −g l x
g e s t i o n du module p r o p r i é t a i r e n v i d i a
n v i d i a −k e r n e l
openbsd − i n e t d
(D)
gere l e s connexion reseau entrante
openvpn (D? )
:
q u e l q u e c h o s e en l i e n avec l e s s e r v e u r s
openbsd −i u n e t d (D)
: pour g e r e r c o n n e c t i o n ???
p c m c i a u t i ( S ) −> r i e n c a r s e r t a s e c o n n e c t e r a d a u t r e s pc
policikit :
portmap (2 − 5 : D? )
l a n c e l e portmapper , u t i l i s é e n t r e a u t r e par
nfs
postfix
s e r v e u r de c o u r r i e r
powernowd
daemon q u i g è r e l e s p r o c e s s e u r q u i peuvent c h a n g e r
de f r é q u e n c e
pppd−dns (D)
r e s t o r e l e f i c h i e r / e t c / r e s o l v . c o n f t e l qu ' i l é t a i t
avant l e l i e n r é s e a u é t a b l i t par ppp
ppp
démarre / a r r ê t e un l i e n ppp ( r t c ou a d s l ? )
p r o c p s . sh
d é f i n i t l e s v a r i a b l e s du noyau d e p u i s / e t c / s y s c t l . c o n f (
g e n r e l ' i p f o r w a r d i n g , i g n o r e r l e s icmp , e t c )
rc . local :
reboot
e x é c u t e l a commande r e b o o t
resolvconf :
r m n o l o g i n (D)
e f f a c e l e f i c h i e r / e t c / n o l o g i n s i n é c e s s a i r e ( empêche l e s
u s e r s de s e l o g g u e r e t a f f i c h e l e message contenu dans c e f i c h i e r )
r s y s l o g : un s y s l o g , u t i l e , s i n o n l e s mes sag es s ' a f f i c h e n t s o u v e n t en
console
r s y n c (D)
daemon de s y n c h r o n i s a t i o n de f i c h i e r s l o c a u x / d i s t a n t s
saned (D? ) :
s c a n n e r et r e s e a u
samba
daemon samba ( p a r t a g e r / v o i r d e s f i c h i e r s /
imprimantes s u r un r é s e a u n e t b i o s )
s c r e e n −c l e a n u p
e f f a c e l e s " p i p e s " l a i s s é s par l e l o g i c i e l s c r e e n
sendsigs
e n v o i d e s s i g n a u x KILL pour t u e r l e s p r o c e s s u s r e s t a n t s
a l ' extinction
single
e x e c u t é par i n i t quand tu r e n t r e en " s i n g l e mode"
skeleton
un exemple de s c r i p t à m e t t r e i c i
stop −b o o t l o g d ( 2 5 : D)
s t o p l e daemon b o o t l o g d
stop −b o o t l o g d − s i n g l e ( S : D)
sudo (D)
f a i t l e ménage dans l e s f i c h i e r s t e m p o r a i r e s de sudo
, make s u r e p r i v i l e g e s don ' t p e r s i s t a c r o s s r e b o o t s
sysklogd
l a n c e s y s l o g d , q u i sauve l e s m ess age s du
système dans / var / l o g
udev
daemon q u i c r é e de manière dynamique e t p e r s o n n a l i s é e d e s
l i e n s dans / dev
umountfs
démonte l e s swap e t t o u s l e s s y s t è m e s de f i c h i e r l o c a u x
umountnfs . sh
démonte t o u s l e s système de f i c h i e r e x c e p t é s l a r a c i n e
urandom
s a u v e g a r d e / r e s t a u r e l a " g r a i n e a l é a t o i r e " pour l e
g é n é r a t e u r de nombres a l é a t o i r e / dev / urandom , l e f i c h i e r e s t / var / l i b /
urandom / random−s e e d e t e s t r e s t a u r é / s a u v e g a r d é
wpa− i f u p d
winbind (D) : u t i l i s e r par samba pour s e c o n n e c t e r a d e s machines windows
et g e r e r l e s d r o i t s u t i l i s a t e u r s
E. Branlard
98
CHAPTER 10. OTHERS
x f r e e 8 6 −common
les sockets
i n i t i l i a s e l e s e r v e u r x f r e e ( xorg maintenant ) notamment
10.18 Optimisation - Cong reseau demarrage
La c o n f i g u r a t i o n r é s e a u r a l e n t i t un peu l e démarrage d ' Ubuntu .
Pour l e f i x e r , é d i t e z v o t r e f i c h i e r " / e t c / h o s t s " en t a p a n t l a commande :
sudo g e d i t / e t c / h o s t s
Vous d e v r i e z y v o i r l e s l i g n e s s u i v a n t e s :
127.0.0.1 localhost
127.0.1.1 toto
" t o t o " e s t l e nom de v o t r e machine ( v o t r e l o c a l h o s t name )
A j o u t e z dans l a p r e m i è r e l i g n e l e nom de v o t r e machine :
127.0.0.1 localhost toto
127.0.1.1 toto
Sauvegardez e t q u i t t e z g e d i t . Redémarrez v o t r e PC.
10.19 Optimisation - chargement polices
l e chargement de bcp de p o l i c e s r a l e n t i s l e systeme j e c r o i s
donc s i tu veux v i r e r d e s p o l i c e s i n u t i l e s . . . s t y l e tu f a i s j a m a i s de
t r a i t e m e n t de t e x t e . . .
tu peux s u p p r i m e r d e s p o l i c e s
a l o r s pour ca tu o u v r e s s y n a p t i c , tu c h e r c h e s t t f e t tu s up p r im e s t o u t e s
l e s polices sauf :
t t f −dejavu , t t f −opensymbol , t t f −bitream −v e r a
p u i s ds un t e r m i n a l tu t a p e s :
sudo f c −c a c h e − f −v
Voilà
!
10.20 Open oce optimization
Options −> Memory
Cache : 128 Mo
Memory p e r o b j e c t 32
Java −>d i s a b l e
open o f f i c e r a p i d e
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? i d =130569&p=1
10.21 Optimisation h t t p : // ubuntuforums . o r g / showthread . php? t =189192&h i g h l i g h t=improve+
performance
E. Branlard
99
CHAPTER 10. OTHERS
10.22 Debian - conseil
N' o u b l i e pas l a l i g n e s u i v a n t e dans ton / e t c / apt / s o u r c e s . l i s t de Lenny
pour l e multimedia :
deb h t t p : //www. debian −multimedia . o r g / l e n n y main
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? i d =221929&p=1
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? i d =4325
h t t p : // forum . ubuntu− f r . o r g / v i e w t o p i c . php? p i d =1008363
E. Branlard
100
Part II
Supplementary notes
101
Chapter
11
Conguration Files
11.1
/.bashrc
# ~/ . b a s h r c : e x e c u t e d by bash ( 1 ) f o r non− l o g i n s h e l l s .
# s e e / u s r / s h a r e / doc / bash / examples / s t a r t u p − f i l e s ( i n t h e p a c k a g e bash −doc )
# f o r examples
# I f not running i n t e r a c t i v e l y , don ' t do a n y t h i n g
[ −z " $PS1" ] && return
# don ' t p u t d u p l i c a t e l i n e s i n t h e h i s t o r y . See bash ( 1 ) f o r more o p t i o n s
export HISTCONTROL=i g n o r e d u p s
# . . . and i g n o r e same s u c e s s i v e e n t r i e s .
export HISTCONTROL=i g n o r e b o t h
# c h e c k t h e window s i z e a f t e r each command and , i f n e c e s s a r y ,
# u p d a t e t h e v a l u e s o f LINES and COLUMNS.
shopt − s c h e c k w i n s i z e
# make l e s s more f r i e n d l y f o r non− t e x t i n p u t f i l e s , s e e l e s s p i p e ( 1 )
[ −x / u s r / b i n / l e s s p i p e ] && e v a l " $ ( l e s s p i p e ) "
#K i l l i n g
#x s e t −b
PC BEEP
#########################################################
# ALIASES
#########################################################
# some more l s a l i a s e s
a l i a s l l =' l s − lhb '
a l i a s l s =' l s −F −− c o l o r=always −−group − d i r e c t o r i e s − f i r s t '
a l i a s l a =' l s −lAXh '
a l i a s l a g =' l s −lAgXh | grep '
a l i a s l s d =' l s − l | g r e p drwx '
a l i a s d i r =' l s − 1'
a l i a s l a d =' l s −lAh | g r e p drwx '
a l i a s cd . . = ' cd . . '
a l i a s g r e p =' g r e p −− c o l o r=always '
# systeme
a l i a s r e b o o t =' sudo r e b o o t '
102
CHAPTER 11. CONFIGURATION FILES
alias
alias
alias
alias
alias
alias
alias
alias
alias
alias
alias
#
v i g r u b =' sudo vim / boot / grub / grub . c f g '
v i x =' sudo vim / e t c /X11/ xorg . conf '
v i i n i t =' sudo vim / e t c / i n i t t a b '
g e d i t ='vim '
m y d i f f =' d i f f −a −b −B −w −y − i −− s u p p r e s s −common− l i n e s '
m y d i f f b =' d i f f −a −b −B −w −y − i '
mywget=' wget − r − l 5 −k −E '
d f =' d f −hT | e g r e p − i " f i l e | ^ / " '
duf ='du −−max−depth=1 −h '
R='R −−no−save '
RR='R −−no− i n i t − f i l e '
function
}
#
ff {
grep −I n r s i
$1
. /*
alias
f= f f
alias
alias
a s e a r c h =' t r a c k e r − s e a r c h
t s e a r c h =' t r a c k e r − s e a r c h
msearch =' t r a c k e r − s e a r c h
v s e a r c h =' t r a c k e r − s e a r c h
i s e a r c h =' t r a c k e r − s e a r c h
alias
network=" /home/ s h a r e / b i n / pyNeighborhood − 0.4 / pyNeighborhood "
alias
lhm='xmodmap −e " p o i n t e r = 3 2 1 4 5 7 6 8 9 " '
rhm='xmodmap −e " p o i n t e r = 1 2 3 4 5 6 7 8 9 " '
#
alias
alias
alias
alias
'
−t
−m
−v
−i
'
'
'
'
#A p t i t u d e
a l i a s update =' sudo a p t i t u d e update ; sudo a p t i t u d e s a f e −upgrade '
a l i a s i n s t =' sudo a p t i t u d e i n s t a l l '
a l i a s s e a r c h =' a p t i t u d e s e a r c h '
alias
l l s m o d =' lsmod
| g r e p " b43 \ | s s b \ | wl " '
#########################################################
# GVIM SINGLE INSTANCE
gv {
[ " $#" −eq " 0 " ] ; then
/ u s r / b i n / gvim −− servername GVIMLOCAL
function
if
else
i f echo " $ * " | g r e p −q −− "−− servername " ; then
# echo "Command a l r e a d y has −−servername use i t "
/ u s r / b i n / gvim $ *
else
#echo "Use d e f a u l t VIM s e r v e r VIMLOCAL"
/ u s r / b i n / gvim −− servername GVIMLOCAL −−remote −tab − s i l e n t
$
*
fi
fi
}
#a l i a s gvim=gv
a l i a s gvim='gvim −p −−remote −tab − s i l e n t '
E. Branlard
103
CHAPTER 11. CONFIGURATION FILES
#########################################################
# PROGRAM PATHS and VARIABLES
#########################################################
export MATLABPATH=/ home /manu/ C o n f i g / matlab
PS1 = ' \ [ [ 1m[ 3 3m\ ] \ u \ [ [ 3 2m\ ]@\ [ [ 3 3m\ ] \ h : \ [ [ 3 2m\ ] \w \ [ [ 3 3m\ ] \ $ \ [ [ 3 2m
\ ] \ [ [m\ ] '
export
#e x p o r t PS1 = ' \ [ \ 0 3 3 [ 1m\ ] \ [ \ 0 3 3 [ 1 ; 3 3m\ ] \ u : \ [ \ e [ 3 2 ; 1m\ ] \w \ [ \ e [ 3 3 ; 1m\ ] \ $
\ [ \ 0 3 3 [m\ ] '
#e x p o r t PS1 ="\033[33;40m[ \u@\h \w] \ \ $ \007 \ 0 3 3 [ 0m\007"
#e x p o r t PS1 = ' \ [ \ 0 3 3 [ 3 3 ; 4 0m\ ] [ \ u@\h \ [ \ e [ 3 3 ; 4 0m\ ] \w ] \ [ \ e [ 3 3 ; 1m\ ] \ $ \ [ \ 0 3 3 [m
\] '
# e n a b l e programmable c o m p l e t i o n f e a t u r e s ( you don ' t need t o e n a b l e
# t h i s , i f i t ' s a l r e a d y e n a b l e d i n / e t c / bash . b a s h r c and / e t c / p r o f i l e
# s o u r c e s / e t c / bash . b a s h r c ) .
i f [ − f / e t c / bash_c o m p l e t i o n ] ; then
. / e t c / bash_c o m p l e t i o n
fi
11.2
/.bash_prole
#i f [ ` t t y ` = " / dev / t t y 1 " ] ; t h e n
# s t a r t x&
#f i
# Load X11
#i f [ − z " $DISPLAY" ] ; t h e n
#e x p o r t PS1 = ' \ [ \ 0 3 3 [ 1m\ ] \ [ \ 0 3 3 [ 1 ; 3 3m\ ] \ u : \ [ \ e [ 3 2 ; 1m\ ] \w \ [ \ e [ 3 3 ; 1m\ ] \ $
\ [ \ 0 3 3 [m\ ] '
#s o u r c e . b a s h r c
PATH=$PATH: /home/manu/ C o n f i g / s c r i p t s /
if
[ ` ps − l e | g r e p x i n i t | wc − l ` == 0 ] ;
xinit ;
echo " " ;
echo "Bye Bye" ;
echo " "
source . b a s h r c
then
fi
# && [ $ ( t t y ) ==
# s t a r t x&
#f i
11.3
/ dev / t t y 1
] ; then
/.xinitrc
#############################
# This f i l e i s not used by nodm , s e e . x s e s s i o n
#############################
E. Branlard
104
CHAPTER 11. CONFIGURATION FILES
#i f [ −x / u s r / b i n / numlockx ]
#t h e n
#
/ u s r / b i n / numlockx on
#f i
#/ u s r / b i n / k e y t o u c h d&
# / home / s h a r e / C o n f i g /_MyScripts / cnx − v j k . sh
#/ e t c / i n i t . d / i n i t −cnx − v j k . sh&
/ u s r / b i n / xsetnumlock&
#xterm c o n f i g
xrdb ~/ . X d e f a u l t s
setxkbmap − o p t i o n t e r m i n a t e : c t r l _a l t_bksp
setxkbmap − o p t i o n compose : r a l t
x s e t b o f f #p c b i b
#b o o t c h a r t
exec x f c e 4 − s e s s i o n
#e x e c ck −launch − s e s s i o n x f c e 4 − s e s s i o n
#e x e c s t a r t x f c e 4
#b l a c k b o x
#icewm
#s a w f i s h
11.4
/.xsession
11.5
/.Xdefaults
xterm
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
xterm * faceName :
monospace : p i x e l s i z e =14
! xterm * dynamicColors :
true
! xterm * u t f 8 :
2
! xterm * e i g h t B i t I n p u t :
true
xterm * s c r o l l T t y K e y p r e s s : true
xterm * s c r o l l T t y O u t p u t :
false
xterm * s c r o l l B a r :
true
xterm * r i g h t S c r o l l B a r :
true
xterm * j u m p S c r o l l :
true
xterm * m u l t i S c r o l l :
true
xterm * background : b l a c k
xterm * f o r e g r o u n d : g r e e n
xterm * t i t l e : xterm
xterm * vt100 . geometry : 80 x28
XTerm* r e v e r s e V i d e o : on
XTerm* S a v e L i n e s : 1000
! xterm * iconPixmap :
/ home / s h a r e / C o n f i g /_Apparence / xapp . xbm
! xterm * iconMask :
/ home / s h a r e / C o n f i g /_Apparence / xapp−mask . xbm
!
!
Xcursor
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
E. Branlard
105
CHAPTER 11. CONFIGURATION FILES
Xcursor * theme : V a n i l l a −DMZ−AA
Xcursor . s i z e : 22
11.6
/.vimrc
set
nocompatible
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Indent
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" ' a u t o i n d e n t ' u s e s t h e i n d e n t from t h e p r e v i o u s l i n e .
" ' smartindent '
i s l i k e ' a u t o i n d e n t ' but a l s o r e c o g n i z e s some C s y n t a x t o
"
i n c r e a s e / r e d u c e t h e i n d e n t where a p p r o p r i a t e .
" ' c i n d e n t ' Works more c l e v e r l y than t h e o t h e r two and i s c o n f i g u r a b l e t o
"
d i f f e r e n t indenting s t y l e s .
" ' i n d e n t e x p r ' The most f l e x i b l e o f a l l : E v a l u a t e s an e x p r e s s i o n t o compute
"
t h e i n d e n t o f a l i n e . When non−empty t h i s method o v e r r i d e s
"
t h e o t h e r o n e s . See | i n d e n t − e x p r e s s i o n | .
s e t smartindent
set cindent
s e t t a b s t o p=4
s e t s h i f t w i d t h =4 " 4 c h a r a c t e r s f o r i n d e n t i n g
s e t e t " expand tab
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
" " " From vimrc example
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
" a l l o w b a c k s p a c i n g o v e r e v e r y t h i n g i n i n s e r t mode
s e t b a c k s p a c e=i n d e n t , e o l , s t a r t whichwrap += < , > ,[ ,]
s e t h i s t o r y =50
" keep 50 l i n e s o f command l i n e h i s t o r y
set r u l e r
" show t h e c u r s o r p o s i t i o n a l l t h e time
s e t mouse=a
" Only do t h i s p a r t when c o m p i l e d with s u p p o r t f o r autocommands .
i f has ( " autocmd " )
" Enable f i l e type d e t e c t i o n .
" Use t h e d e f a u l t f i l e t y p e s e t t i n g s , s o t h a t m a i l g e t s ' tw ' s e t t o 7 2 ,
" ' c i n d e n t ' i s on i n C f i l e s , e t c .
" Also l o a d i n d e n t f i l e s , t o a u t o m a t i c a l l y do language −dependent
indenting .
f i l e t y p e p l u g i n i n d e n t on
" Put t h e s e i n an autocmd group , s o t h a t we can d e l e t e them e a s i l y .
augroup vimrcEx
au !
" For a l l t e x t f i l e s s e t ' t e x t w i d t h ' t o 78 c h a r a c t e r s .
autocmd F il eT y p e t e x t s e t l o c a l t e x t w i d t h =78
" When e d i t i n g a f i l e , always jump t o t h e l a s t known c u r s o r p o s i t i o n .
" Don ' t do i t when t h e p o s i t i o n i s i n v a l i d o r when i n s i d e an e v e n t
handler
" ( happens when d r o p p i n g a f i l e on gvim ) .
autocmd BufReadPost *
\ i f l i n e ( " ' \ " " ) > 0 && l i n e ( " ' \ " " ) <= l i n e ( " $ " ) |
\
exe " normal ! g ` \ " " |
\ endif
augroup END
E. Branlard
106
CHAPTER 11. CONFIGURATION FILES
else
set autoindent
" always s e t a u t o i n d e n t i n g on
e n d i f " has ( " autocmd " )
" Convenient command t o s e e t h e d i f f e r e n c e between t h e c u r r e n t b u f f e r and
the
" f i l e i t was l o a d e d from , t h u s t h e c h a n g e s you made .
command D i f f O r i g v e r t new | s e t bt=n o f i l e | r # | 0d_ | d i f f t h i s
\ | wincmd p | d i f f t h i s
" D e t e c t f i l e t y p e nd u s e s y n t a x h i g h l i g h t i n g s y n t a x e n a b l e
syntax enable
s e t background=dark
" f i l e t y p e on
c o l o r ManuGreen
" s e t g u i o p t i o n s −=m " remove menu bar
" s e t g u i o p t i o n s −=T " remove t o o l b a r
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Editor general
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
s e t number " l i n e numbering
s e t l b r " l i n e break
" s p e l l check
set s p e l l
inoremap
inoremap
inoremap
inoremap
<M−h>
<M−j >
<M−k>
<M−l >
<L e f t >
<Down>
<Up>
<Right>
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Search
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" P r e s s F3 t o t o g g l e h i g h l i g h t i n g on / o f f , and show c u r r e n t v a l u e .
noremap <F3> : s e t h l s e a r c h ! h l s e a r c h ?<CR>
set h l s e a r c h
s e t i n c s e a r c h " do i n c r e m e n t a l s e a r c h i n g
s e t i g n o r e c a s e " i g n o r e c a se
s e t s m a r t c a s e " but don ' t i g n o r e i t , when s e a r c h s t r i n g c o n t a i n s u p p e r c a s e
letters
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Completion
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
s e t c o m p l e t e o p t=menu , l o n g e s t , p r e v i e w
s e t showcmd
" d i s p l a y i n c o m p l e t e commands a t t h e bottom o f t h e s c r e e n
s e t w i l d c h a r=<Tab> wildmenu wildmode= f u l l
s e t wildcharm=<C−Z>
s e t w i l d i g n o r e=* . o , *~ , * . cmo , * . cmi , * . a , * . cmx , * . cmxa , * . pdf
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Folding
E. Branlard
107
CHAPTER 11. CONFIGURATION FILES
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
h i g h l i g h t Folded c t e r m f g=y e l l o w ctermbg=NONE
" s e t f o l d t e x t=g e t l i n e ( v : f o l d s t a r t )
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Tabs
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" tab f i r e f o x − l i k e
nmap <C−t> : tabnew<CR>
nmap <C−S−tab> : t a b p r e v i o u s <CR>
nmap <C−tab> : tabnext<CR>
map <C−S−tab> : t a b p r e v i o u s <CR>
map <C−tab> : tabnext<CR>
imap <C−S−tab> <Esc >: t a b p r e v i o u s <CR>
imap <C−tab> <Esc >: tabnext<CR>
s e t s h o w t a b l i n e=2 " always t a b s v i s i b l e
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Buffers
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" B u f f e r s − e x p l o r e / next / p r e v i o u s : Alt −F12 , F12 , S h i f t −F12 .
nnoremap <s i l e n t > <M−F12> : BufExplorer <CR>
nnoremap <s i l e n t > <F12> : bn<CR>
nnoremap <s i l e n t > <S−F12> : bp<CR>
" Bluid in f e a t u r e s
" smart b u f f e r s w i t c h i n g p r e s s i n g : b tab o f F10
nnoremap <F10> : b <C−Z>
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Comment / Toggle comment
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
map <s i l e n t > <A−S−C> : c a l l ToggleComment (&f t )<CR>
nmap <s i l e n t >c c : c a l l LineCommenter ( )<Esc>
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Windows l i k e
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
s e t w i n a l t k e y s=no
" CTRL−X a r e Cut
vnoremap <C−X> "+x
inoremap <C−x> <C−o>x
noremap <C−x> x
" CTRL−C
vnoremap <C−C> "+y
" CTRL−V
map <C−V>
"+gP
cmap <C−V>
<C−R>+
" P a s t i n g b l o c k w i s e and l i n e w i s e s e l e c t i o n s i s not p o s s i b l e i n I n s e r t and
" V i s u a l mode w i t h o u t t h e +v i r t u a l e d i t f e a t u r e . They a r e p a s t e d a s i f
they
" were c h a r a c t e r w i s e i n s t e a d .
E. Branlard
108
CHAPTER 11. CONFIGURATION FILES
" Uses t h e p a s t e . vim a u t o l o a d s c r i p t .
exe ' inoremap <s c r i p t > <C−V>' p a s t e#p a s t e_cmd [ ' i ' ]
exe ' vnoremap <s c r i p t > <C−V>' p a s t e#p a s t e_cmd [ ' v ' ]
" Use CTRL−S f o r s a v i n g , a l s o i n I n s e r t mode
noremap <C−S>
: update<CR>
vnoremap <C−S>
<C−C>: update<CR>
inoremap <C−S>
<C−O>: update<CR>
" CTRL−Z i s Undo ; not i n c m d l i n e though
noremap <C−Z> u
inoremap <C−Z> <C−O>u
" CTRL−A i s S e l e c t a l l
noremap <C−A> gggH<C−O>G
inoremap <C−A> <C−O>gg<C−O>gH<C−O>G
cnoremap <C−A> <C−C>gggH<C−O>G
onoremap <C−A> <C−C>gggH<C−O>G
snoremap <C−A> <C−C>gggH<C−O>G
xnoremap <C−A> <C−C>ggVG
" CTRL−Tab i s Next window
" noremap <C−Tab> <C−W>w
" inoremap <C−Tab> <C−O><C−W>w
" cnoremap <C−Tab> <C−C><C−W>w
" onoremap <C−Tab> <C−C><C−W>w
"""
" CTRL−Tab i s Next window
" noremap <C−Tab> <C−W>w
" inoremap <C−Tab> <C−O><C−W>w
" cnoremap <C−Tab> <C−C><C−W>w
" onoremap <C−Tab> <C−C><C−W>w
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" Windows
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" N a v i g a t e between windows
"nmap <s i l e n t > <C−k> : wincmd k<CR>
"nmap <s i l e n t > <C−j > : wincmd j <CR>
"nmap <s i l e n t > <C−h> : wincmd h<CR>
"nmap <s i l e n t > <C−l > : wincmd l <CR>
" r e s i z e i n h o r i z o n t a l mode
map − <C−W>−
map + <C−W>+
" r e s i z e i n v e r t i c a l mode ALT−SHIFT − [<>]:
map <M−<> <C−W><
map <M−>> <C−W>>
imap <M−<> <C−W><
imap <M−>> <C−W>>
imap <C−w> <C−o><C−w>
" min win h e i g h t t o 0 , 1 d e f a u l t
s e t wmh=0
E. Branlard
109
CHAPTER 11. CONFIGURATION FILES
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " "
" " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " "
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" INSERT MODE TWEAKS and COPY PASTE TWEAKS
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" D e a l i n g with l o n g l i n e s a u t o m a t i c a l y . . .
nmap k g<Up>
nmap j g<Down>
" n a v i g a t e w i t h o u t l i f t i n g hand o f f o f k e y s
imap <C−space > <Plug>IMAP_JumpForward
imap <C−H> <L e f t >
imap <C−J> <C−o>g<Down>
imap <C−K> <C−o>g<Up>
imap <C−L> <Right>
imap <A−4> <C−o><End>
imap <A−0> <C−o><Home>
" duplicate line
inoremap <A−d> <C−o>yy<C−o>P<Down>
noremap <A−d> yyp
" inoremap <M−D> <C−o>yy<C−o>P<Down>
" inoremap <M−D> <C−o>yy<C−o>P<Down>
" noremap <M−D> yyp
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " "
" VIM−LATEX
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " "
" REQUIRED. This makes vim i n v o k e Latex − S u i t e when you open a t e x f i l e .
f i l e t y p e p l u g i n on
" IMPORTANT: win32 u s e r s w i l l need t o have ' s h e l l s l a s h ' s e t s o t h a t l a t e x
" can be c a l l e d c o r r e c t l y .
set s h e l l s l a s h
" IMPORTANT: g r e p w i l l sometimes s k i p d i s p l a y i n g t h e f i l e name i f you
" s e a r c h i n a s i n g e f i l e . This w i l l c o n f u s e Latex − S u i t e . S e t your g r e p
" program t o always g e n e r a t e a f i l e −name .
s e t g r e p p r g=g r e p \ −nH\ $*
" OPTIONAL: S t a r t i n g with Vim 7 , t h e f i l e t y p e o f empty . t e x f i l e s d e f a u l t s
to
" ' p l a i n t e x ' i n s t e a d o f ' tex ' , which r e s u l t s i n vim− l a t e x not b e i n g l o a d e d
.
" The f o l l o w i n g c h a n g e s t h e d e f a u l t f i l e t y p e back t o ' tex ' :
l e t g : t e x_f l a v o r =' l a t e x '
l e t g : Tex_Menus=0
l e t g : Tex_AutoFolding=0
l e t g : Tex_F o l d i n g=0
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
" Latex c o m p i l a t i o n
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
E. Branlard
110
CHAPTER 11. CONFIGURATION FILES
l e t g : Tex_DefaultTargetFormat = ' pdf '
l e t g : Tex_MultipleCompileFormats = ' '
l e t g : Tex_FormatDependency_pdf = ' '
l e t g : Tex_CompileRule_pdf = ' p d f l a t e x − i n t e r a c t i o n=nonstopmode $* ; '
l e t g : Tex_CompileRule_d v i = ' l a t e x −− i n t e r a c t i o n=nonstopmode $* ; '
l e t g : Tex_CompileRule_ps = ' d v i p s −Ppdf −o $* . ps $* . d v i ; '
l e t g : Tex_UseMakeFile = 1
l e t g : Tex_GotoError=0
" remember command f o r dynamicly c h a n g i n g warning l e v e l : TCLevel 3
l e t g : Tex_IgnoredWarnings =
\ ' / u s r / s h a r e ' . " \n" .
\ ' / texmf ' . " \n" .
\ ' U n d e r f u l l ' . " \n" .
\ ' O v e r f u l l ' . " \n" .
\ ' s p e c i f i e r changed to ' . " \n" .
\ ' You have r e q u e s t e d ' . "\n" .
\ ' M i s s i n g number , t r e a t e d a s z e r o . ' . " \n" .
\ ' There were u n d e f i n e d r e f e r e n c e s ' . " \n" .
\ ' C i t a t i o n %.%# u n d e f i n e d ' . " \ n " .
\ ' Label ' . " \n" .
\ ' Warning '
l e t g : Tex_I g n o r e L e v e l = 1
" Latex F o l d i n g
l e t g : Tex_F o l d e d S e c t i o n s =' s e c t i o n '
l e t g : Tex_FoldedEnvironments = ' '
l e t g : Tex_FoldedCommands = ' '
l e t g : Tex_FoldedMisc = ' '
"To put i n a * . l a t e x m a i n t o o v e r r i d e f o r a p r o j e c t
" l e t Tex_DefaultTargetFormat = ' pdf '
" l e t g : Tex_MultipleCompileFormats =' pdf '
" l e t Tex_FormatDependency_pdf = ' dvi , ps , pdf '
" l e t Tex_CompileRule_d v i = ' l a t e x −− i n t e r a c t i o n=nonstopmode $* '
" l e t Tex_CompileRule_ps = ' d v i p s −Ppdf −o $* . ps $* . d v i ; echo " Rule DVI>PS
d e f i n e d i n Main" ; r e a d A'
" l e t Tex_CompileRule_pdf = ' p s 2 p d f $* . ps ; echo " Rule PS>PDF d e f i n e d i n
Main" ; read A'
" l e t g : Tex_P r o j e c t S o u r c e F i l e s =' b i b /* . bib , t e x /* . tex '
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
" Sessions
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
"~ f u n c t i o n ! S a v e S e s s i o n ( )
"~
i f v : t h i s_s e s s i o n != " "
"~
echo " Saving . "
"~
exe ' m k s e s s i o n ! ' . ' " ' . v : t h i s_s e s s i o n . ' " '
"~
else
"~
echo "No S e s s i o n . "
"~
endif
"~ e n d f u n c t i o n
"~
"~ au VimLeave * : c a l l S a v e S e s s i o n ( )
"~
E. Branlard
111
CHAPTER 11. CONFIGURATION FILES
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
" Matlab
" " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "
" s o u r c e $VIMRUNTIME/ macros / m a t c h i t . vim
" autocmd BufEnter * .m c o m p i l e r m l i n t
11.7
/.conkyrc
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
${ c o l o r
g r e y }RAM Usage : $ c o l o r $mem/$memmax − $ memperc% $ {membar 4}
g r e y }Swap Usage : $ c o l o r $ swap /$ swapmax − $ swapperc% $ { swapbar 4}
$ { c o l o r g r e y }CPU Usage : $ c o l o r $ cpu% $ { cpubar 4}
${ c o l o r g r e y } P r o c e s s e s : $ c o l o r $ p r o c e s s e s
$ { c o l o r g r e y } Running : $ c o l o r $
running_p r o c e s s e s
$ hr
${ c o l o r g r e y } F i l e s y s t e m s :
/ $ c o l o r $ { f s_used / } /$ { f s_s i z e / } $ { f s_bar 6 / }
$ { c o l o r g r e y } Networking :
Up : $ c o l o r $ { upspeed e t h 0 } $ { c o l o r g r e y } − Down : $ c o l o r $ { downspeed e t h 0 }
$ hr
$ { c o l o r g r e y }Name
PID
CPU% MEM%
$ { c o l o r l i g h t g r e y } $ { t o p name 1} $ { t o p p i d 1} $ { t o p cpu 1} $ { t o p mem 1}
$ { c o l o r l i g h t g r e y } $ { t o p name 2} $ { t o p p i d 2} $ { t o p cpu 2} $ { t o p mem 2}
$ { c o l o r l i g h t g r e y } $ { t o p name 3} $ { t o p p i d 3} $ { t o p cpu 3} $ { t o p mem 3}
$ { c o l o r l i g h t g r e y } $ { t o p name 4} $ { t o p p i d 4} $ { t o p cpu 4} $ { t o p mem 4}
${ c o l o r
background no
# Use X f t ?
u s e_x f t y e s
x f t f o n t DejaVu Sans : s i z e =8
xftalpha 0.6
#t e x t_b u f f e r_s i z e 2048
t e x t_b u f f e r_s i z e 2048
# Update i n t e r v a l i n s e c o n d s
update_i n t e r v a l 1
# This i s t h e number o f t i m e s Conky w i l l u p d a t e b e f o r e q u i t t i n g .
# S e t t o z e r o t o run f o r e v e r .
t o t a l_run_times 0
# Create own window i n s t e a d o f u s i n g d e s k t o p ( r e q u i r e d i n n a u t i l u s )
own_window y e s
own_window_t r a n s p a r e n t y e s
own_window_type normal
own_window_h i n t s undecorated , below , s t i c k y , s k i p_t a s k b a r , s k i p_p a g e r
# Use d o u b l e b u f f e r i n g ( r e d u c e s f l i c k e r , may not work f o r e v e r y o n e )
d o u b l e_b u f f e r y e s
# minimum s i z e o f t e x t area
minimum_s i z e 230 0
maximum_width 230
E. Branlard
112
CHAPTER 11. CONFIGURATION FILES
# Draw s h a d e s ?
draw_s h a d e s no
# Draw o u t l i n e s ?
draw_o u t l i n e no
# Draw b o r d e r s around t e x t
draw_b o r d e r s no
# Stippled borders ?
s t i p p l e d_b o r d e r s 0
# b o r d e r margins
b o r d e r_margin 4
# border width
b o r d e r_width 1
# D e f a u l t c o l o r s and a l s o b o r d e r c o l o r s
d e f a u l t_c o l o r w h i t e
#d e f a u l t_shade_c o l o r b l a c k
#d e f a u l t_o u t l i n e_c o l o r g r e y
own_window_c o l o u r w h i t e
# Text a l i g n me n t , o t h e r p o s s i b l e v a l u e s mr , b l e t c . . .
alignment t r
# Gap between b o r d e r s o f s c r e e n and t e x t
# same t h i n g as p a s s i n g −x a t command l i n e
gap_x 35
gap_y 35
# S u b t r a c t f i l e system b u f f e r s from used memory?
no_b u f f e r s y e s
# s e t t o y e s i f you want a l l t e x t t o be i n u p p e r c a s e
u p p e r c a s e no
# number o f cpu s a m p l e s t o a v e r a g e
# set to 1 to d i s a b l e averaging
cpu_avg_s a m p l e s 1
# number o f n e t s a m p l e s t o a v e r a g e
# set to 1 to d i s a b l e averaging
n e t_avg_s a m p l e s 1
# Force UTF8? n o t e t h a t UTF8 s u p p o r t r e q u i r e d XFT
o v e r r i d e_u t f 8_l o c a l e y e s
# Add s p a c e s t o keep t h i n g s from moving a b o u t ? This o n l y a f f e c t s
#c e r t a i n o b j e c t s .
u s e_s p a c e r none
#$ nodename − $ sysname $ k e r n e l on
#$ s t i p p l e d_hr
#$ { c o l o r l i g h t g r e y } Uptime : $ c o l o r
loadavg
E. Branlard
$ machine
$ uptime
${ c o l o r
l i g h t g r e y }− Load : $ c o l o r
$
113
CHAPTER 11. CONFIGURATION FILES
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
#~
${ f o n t
a r i a l b l a c k : s i z e =5: b o l d } $ { c o l o r #2E313F}CPU$ { c o l o r #838383} $ {
a l i g n r } $ f r e q_g GHz $ { c o l o r b l a c k } / $ { c o l o r #838383} $ cpu%
$ { c o l o r #2E313F}RAM: $ { c o l o r #838383} $ { a l i g n r } $mem $ { c o l o r b l a c k } / $ {
c o l o r #838383} $ memperc%
$ c o l o r $ s t i p p l e d_hr
$ { c o l o r #2E313F} F i l e s y s t e m s :
$ { c o l o r #2E313F} /
$ { a l i g n r } $ { c o l o r #838383} $ { f s_used / } $ { c o l o r
b l a c k } / $ { c o l o r #838383} $ { f s_s i z e / }
$ { c o l o r #2E313F} s t u f f
$ { a l i g n r } $ { c o l o r #838383} $ { f s_used / media / s t u f f }
$ { c o l o r b l a c k } / $ { c o l o r #838383} $ { f s_s i z e / media /Win}
$ { c o l o r #2E313F}Windows
$ { a l i g n r } $ { c o l o r #838383} $ { f s_used / media / win
} $ { c o l o r b l a c k } / $ { c o l o r #838383} $ { f s_s i z e / media / DataWin}
${ c o l o r
l i g h t g r e y }CPU Temperature : $ { acpitemp }
l i g h t g r e y }RAM Usage : $ c o l o r $mem/$memmax − $ memperc% $ {membar}
${ c o l o r l i g h t g r e y } P r o c e s s e s : $ c o l o r $ p r o c e s s e s
$ { c o l o r g r e y } Running : $
c o l o r $ running_p r o c e s s e s
#~ $ { c o l o r l i g h t g r e y } $ s t i p p l e d_hr
#~ $ { c o l o r l i g h t g r e y } F i l e s y s t e m s :
#~ / $ c o l o r $ { f s_used / } /$ { f s_s i z e / } $ { f s_bar / }
#~ $ s t i p p l e d_hr
#~ k g t k j t r k r t k j
#~ $ { c o l o r }Name
PID
CPU% MEM%
#~ $ { c o l o r #ddaa00 } $ { t o p name 1} $ { t o p p i d 1} $ { t o p cpu 1} $ { t o p mem 1}
#~ $ { c o l o r l i g h t g r e y } $ { t o p name 2} $ { t o p p i d 2} $ { t o p cpu 2} $ { t o p mem 2}
#~ $ { c o l o r l i g h t g r e y } $ { t o p name 3} $ { t o p p i d 3} $ { t o p cpu 3} $ { t o p mem 3}
#~ $ { c o l o r l i g h t g r e y } $ { t o p name 4} $ { t o p p i d 4} $ { t o p cpu 4} $ { t o p mem 4}
#~ $ { c o l o r }Mem u s a g e
#~ $ { c o l o r #ddaa00 } $ { t o p_mem name 1} $ { t o p_mem p i d 1} $ { t o p_mem cpu 1} $ {
t o p_mem mem 1}
#~ $ { c o l o r l i g h t g r e y } $ { t o p_mem name 2} $ { t o p_mem p i d 2} $ { t o p_mem cpu 2}
$ { t o p_mem mem 2}
#~ $ { c o l o r l i g h t g r e y } $ { t o p_mem name 3} $ { t o p_mem p i d 3} $ { t o p_mem cpu 3}
$ { t o p_mem mem 3}
#~ $ { c o l o r l i g h t g r e y } $ { t o p_mem name 4} $ { t o p_mem p i d 4} $ { t o p_mem cpu 4}
$ { t o p_mem mem 4}
#~ $ s t i p p l e d_hr
#~
#~ $ { c o l o r orange }FORTUNE $ { hr 2} $ c o l o r
#~ $ { e x e c i 120 f o r t u n e − s | f o l d −w50}
#~
#~
#~ $ { c o l o r #ddaa00 } Port ( s ) $ { a l i g n r }#Connections
#~ $ c o l o r Inbound : $ { t c p_portmon 1 32767 count } Outbound : $ { t c p_portmon
32768 61000 count } $ { a l i g n r }ALL: $ { t c p_portmon 1 65535 count }
#~ $ { c o l o r #ddaa00 } Inbound Connection $ { a l i g n r } L o c a l S e r v i c e / Port $ c o l o r
#~ $ { t c p_portmon 1 32767 r h o s t 0} $ { a l i g n r } $ { t c p_portmon 1 32767
l s e r v i c e 0}
#~ $ { t c p_portmon 1 32767 r h o s t 1} $ { a l i g n r } $ { t c p_portmon 1 32767
l s e r v i c e 1}
#~ $ { t c p_portmon 1 32767 r h o s t 2} $ { a l i g n r } $ { t c p_portmon 1 32767
l s e r v i c e 2}
#~ $ { t c p_portmon 1 32767 r h o s t 3} $ { a l i g n r } $ { t c p_portmon 1 32767
l s e r v i c e 3}
#~ $ { c o l o r #ddaa00 } Outbound Connection $ { a l i g n r } Remote S e r v i c e / Port $ c o l o r
${ c o l o r
E. Branlard
114
CHAPTER 11. CONFIGURATION FILES
#~
#~
#~
#~
$ { t c p_portmon
32768 61000 r h o s t
r s e r v i c e 0}
$ { t c p_portmon 32768 61000 r h o s t
r s e r v i c e 1}
$ { t c p_portmon 32768 61000 r h o s t
r s e r v i c e 2}
$ { t c p_portmon 32768 61000 r h o s t
r s e r v i c e 3}
0}
$ { a l i g n r } $ { t c p_portmon
32768 61000
1}
$ { a l i g n r } $ { t c p_portmon
32768 61000
2}
$ { a l i g n r } $ { t c p_portmon
32768 61000
3}
$ { a l i g n r } $ { t c p_portmon
32768 61000
#$ { c o l o r orange }LOGGING $ { hr 2} $ c o l o r
#$ { e x e c i 30 t a i l −n3 / var / l o g / messages | f o l d −w50}
#$ { c o l o r l i g h t g r e y }Swap Usage : $ c o l o r $ swap /$ swapmax − $ swapperc% $ { swapbar
}
#$ { c o l o r l i g h t g r e y } Networking :
#Down : $ { c o l o r #8844 ee } $ { downspeed e t h 1 } k / s $ { c o l o r l i g h t g r e y } $ { o f f s e t
100}Up : $ { c o l o r #22 c c f f } $ { upspeed e t h 1 } k / s
#$ { c o l o r #0000 f f } $ { downspeedgraph e t h 1 32 ,175 f f 0 0 0 0 0000 f f } $ { c o l o r #22
c c f f } $ { u p s p e e d g r a p h e t h 1 32 ,175 0000 f f f f 0 0 0 0 }
TEXT
$ { f o n t B i t s t r e a m Vera Sans Mono : s i z e =8}$ { c o l o r y e l l o w } Date $ { hr 2} $ { c o l o r
white }
$ { a l i g n c 17} $ { f o n t A r i a l Black : s i z e =16} $ { time %H:%M} $ { f o n t }
$ { a l i g n c } $ { time %A %d %B %Y}
${ c o l o r
w h i t e } $ { f o n t B i t s t r e a m Vera Sans Mono : s i z e =8}$ { e x e c p i 60 DJS=` d a t e
+%_d ` ; c a l | sed ' / . / ! d ' | sed ' 1 d '
| sed ' s /$/
/
' | f o l d −w 21 | sed −n ' / ^ . \ { 2 1 \ } /p ' | sed ' s /^/$ { a l i g n c } / ' | sed / "
$DJS " / s / " $DJS " / " " ' $ { c o l o r tan2 } ' " $DJS" ' $ { c o l o r w h i t e } ' " " / }
# DAXX0009
# FRXX1262
### METEO
$ { c o l o r y e l l o w } $ { e x e c i 120 ~/ . conky / meteo . sh DAXX0009}Météo à $ { e x e c i
120 ~/ . conky / meteo2 . sh " V i l l e " } $ { hr 2}
${ c o l o r w h i t e }
Aujourd ' h u i : $ { e x e c i 120 ~/ . conky / meteo2 . sh " Température
aujourd ' h u i " }
$ { f o n t weather : s i z e =40} $ { v o f f s e t −8}$ { e x e c i 120 ~/ .
conky / meteo2 . sh " C o n d i t i o n s aujourd ' h u i " } $ { f o n t } $ { v o f f s e t −26}
${ c o l o r w h i t e }
Vent : $ { e x e c i 120 ~/ . conky / meteo2 . sh " Vent aujourd ' h u i "
}
${ c o l o r w h i t e }
Lever du s o l e i l : $ { e x e c i 120 ~/ . conky / meteo2 . sh " Lever
du s o l e i l " }
${ c o l o r w h i t e }
Coucher du s o l e i l : $ { e x e c i 120 ~/ . conky / meteo2 . sh "
Coucher du s o l e i l " }
${ c o l o r w h i t e }
Demain : $ { e x e c i 120 ~/ . conky / meteo2 . sh " Température
demain " }
$ { f o n t weather : s i z e =32} $ { v o f f s e t −8}$ { e x e c i 120 ~/ . conky /
meteo2 . sh " C o n d i t i o n s demain " } $ { f o n t B i t s t r e a m Vera Sans Mono : s i z e =8} $
{ v o f f s e t −12}
### SYSTEM
$ { c o l o r y e l l o w } $ { f o n t B i t s t r e a m Vera Sans Mono : s i z e =8}System $ { hr 2}
$ { c o l o r w h i t e }Power : $ { c o l o r #FFFB00} $ { a c p i a c a d a p t e r } $ { c o l o r #DBAA82}( $
b a t t e r y_p e r c e n t %)$ { a l i g n r } $ { c o l o r # f f f f f f } $ { cpubar cpu1 5 ,50 00 f f 0 0
00 f f 0 0 }
$ { c o l o r w h i t e }RAM: $ { c o l o r #FFFB00} $mem$ { c o l o r b l a c k } $ { c o l o r #DBAA82}( $
memperc%) $ { a l i g n r } $ { c o l o r # f f f f f f } $ { v o f f s e t −3}$ { cpubar cpu2 5 ,50
E. Branlard
115
CHAPTER 11. CONFIGURATION FILES
0000 f f 00 f f 0 0 }
v o f f s e t 3} $ { c o l o r w h i t e }Pc : $ { c o l o r #FFFB00} $ { t o p name 1} $ { a l i g n r } $ {
c o l o r #FFFFFF}Cpu : $ { cpugraph 10 ,50 0000 f f 00 f f 0 0 }
${ c o l o r w h i t e }
P r o c e s s e s : ${ c o l o r y e l l o w }$ p r o c e s s e s ${ a l i g n r } ${ c o l o r
w h i t e } Running : $ { c o l o r y e l l o w } $ r u n n i n g_p r o c e s s e s
${
### NETWORK
$ { c o l o r y e l l o w } Network $ { hr 2}
$ { c o l o r w h i t e }WAN IP : $ a l i g n r $ { c o l o r y e l l o w } $ { e x e c i 600 ~/ . conky / Wanip . sh
}
$ { c o l o r w h i t e }LAN IP : $ a l i g n r $ { c o l o r y e l l o w } $ { addr e t h 1 }
$ { c o l o r w h i t e }Down : $ { f o n t Monospace : s i z e =8}$ { c o l o r y e l l o w } $ { downspeedf
e t h 1 }kb / s $ a l i g n r $ { c o l o r w h i t e } Up : $ { c o l o r y e l l o w } $ { u p s p e e d f e t h 1 }kb /
s
$ { c o l o r w h i t e } Inbound : $ { c o l o r y e l l o w } $ { t c p_portmon 1 32767 count } $
a l i g n r $ { c o l o r w h i t e }Outbound : $ { c o l o r y e l l o w } $ { t c p_portmon 32768
61000 count } $ { a l i g n r }
### HDD
$ { c o l o r y e l l o w }HDD $ { hr 2}
${ c o l o r w h i t e }
ROOT: $ { c o l o r y e l l o w } $ { f s_f r e e_p e r c /}% ( $ { f s_f r e e / } ) $ {
a l i g n r } $ { c o l o r w h i t e } $ { f s_bar 5 , 5 0 / }
${ c o l o r w h i t e }
HOME: $ { c o l o r y e l l o w } $ { f s_f r e e_p e r c /home}% ( $ { f s_f r e e /
home } ) $ { a l i g n r } $ { c o l o r w h i t e } $ { f s_bar 5 , 5 0 /home}
${ c o l o r w h i t e }
DATA:
$ { c o l o r y e l l o w } $ { f s_f r e e_p e r c / media / DataWin}% ( $ {
f s_f r e e / media / DataWin } ) $ { a l i g n r } $ { c o l o r w h i t e } $ { f s_bar 5 , 5 0 / media /
DataWin}
### LOGS
$ { c o l o r y e l l o w } $ { f o n t B i t s t r e a m Vera Sans Mono : s i z e =8}Log $ { hr 2}
$ { c o l o r w h i t e } $ { e x e c i 10 t a i l −n6 / var / l o g / me ssa ges | c u t −c 45 −}
### TODO
$ { c o l o r y e l l o w } $ { f o n t B i t s t r e a m Vera Sans Mono : s i z e =8}To do $ { hr 2}
$ { c o l o r w h i t e } $ { e x e c i 600 c a t / media / DataWin / P r o j e t s /TODO. c }
11.8 /etc/apt/sources.list
## s q u e e z e
deb h t t p : // f t p . us . d e b i a n . o r g / d e b i a n s q u e e z e main c o n t r i b non− f r e e
deb− s r c h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / s q u e e z e main c o n t r i b non− f r e e
## s q u e e z e m u l t i m e d i a
deb h t t p : // m i r r o r . home−dn . n e t / debian −multimedia s q u e e z e main non− f r e e
deb− s r c h t t p : // m i r r o r . home−dn . n e t / debian −multimedia s q u e e z e main non− f r e e
## s q u e e z e s e c u r i t y
deb h t t p : // s e c u r i t y . d e b i a n . o r g / s q u e e z e / u p d a t e s main c o n t r i b non− f r e e
deb− s r c h t t p : // s e c u r i t y . d e b i a n . o r g / s q u e e z e / u p d a t e s main c o n t r i b non− f r e e
# squeeze update
deb h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / s q u e e z e −u p d a t e s main c o n t r i b non− f r e e
E. Branlard
116
CHAPTER 11. CONFIGURATION FILES
deb− s r c h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / s q u e e z e −u p d a t e s main c o n t r i b non−
free
# proposed a d d i t i o n s f o r a 6.0 point r e l e a s e
deb h t t p : // f t p . us . d e b i a n . o r g / d e b i a n s q u e e z e −proposed −u p d a t e s main c o n t r i b
non− f r e e
#s k y p e
deb h t t p : // download . skype . com/ l i n u x / r e p o s / d e b i a n / s t a b l e non− f r e e
deb h t t p : // m o z i l l a . d e b i a n . n e t / s q u e e z e −b a c k p o r t s i c e w e a s e l − 4.0
################################################
## wheezy
deb h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / wheezy main c o n t r i b non− f r e e
deb− s r c h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / wheezy main c o n t r i b non− f r e e
## wheezy m u l t i m e d i a
deb h t t p : //www. debian −multimedia . o r g wheezy main non− f r e e
deb− s r c h t t p : //www. debian −multimedia . o r g / wheezy main
## wheezy s e c u r i t y
deb h t t p : // s e c u r i t y . d e b i a n . o r g / wheezy / u p d a t e s main c o n t r i b non− f r e e
deb− s r c h t t p : // s e c u r i t y . d e b i a n . o r g / wheezy / u p d a t e s main c o n t r i b non− f r e e
################################################
## s i d
deb h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / s i d main c o n t r i b non− f r e e
deb− s r c h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / s i d main c o n t r i b non− f r e e
## s i d m u l t i m e d i a
deb h t t p : // m i r r o r . home−dn . n e t / debian −multimedia s i d main
deb− s r c h t t p : // m i r r o r . home−dn . n e t / debian −multimedia s i d main
#e x p e r i m e n t a l
deb h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / e x p e r i m e n t a l main c o n t r i b non− f r e e
deb− s r c h t t p : // f t p . us . d e b i a n . o r g / d e b i a n / e x p e r i m e n t a l main c o n t r i b non−
free
11.9 /etc/apt/preferences
Package : *
Pin : r e l e a s e o=apt − b u i l d
Pin− P r i o r i t y : 989
##################################################
### S t a b l e
##################################################
Package : *
Pin : r e l e a s e o=Debian , a=s q u e e z e −updates , l=Debian
Pin− P r i o r i t y : 985
Package : *
Pin : r e l e a s e o=Debian , a=s t a b l e , l=Debian − S e c u r i t y
E. Branlard
117
CHAPTER 11. CONFIGURATION FILES
Pin− P r i o r i t y : 984
Package : *
Pin : r e l e a s e o=U n o f f i c i a l Multimedia Packages , a=s t a b l e , l=U n o f f i c i a l
Multimedia Packages
Pin− P r i o r i t y : 981
Package : *
Pin : r e l e a s e o=Debian , a=s t a b l e , l=Debian
Pin− P r i o r i t y : 982
##################################################
### T e s t i n g
##################################################
Package : *
Pin : r e l e a s e o=Debian , a=t e s t i n g , l=Debian − S e c u r i t y
Pin− P r i o r i t y : 98
Package : *
Pin : r e l e a s e o=U n o f f i c i a l Multimedia Packages , a=t e s t i n g , l=U n o f f i c i a l
Multimedia Packages
Pin− P r i o r i t y : 97
Package : *
Pin : r e l e a s e o=Debian , a=t e s t i n g , l=Debian
Pin− P r i o r i t y : 96
#####################################################
### U n s t a b l e
#####################################################
Package : *
Pin : r e l e a s e o=U n o f f i c i a l Multimedia Packages , a=u n s t a b l e , l=U n o f f i c i a l
Multimedia Packages
Pin− P r i o r i t y : 50
Package : *
Pin : r e l e a s e o=Debian , a=u n s t a b l e , l=Debian
Pin− P r i o r i t y : 50
####################################################
### E x p e r i m e n t a l
####################################################
Package : *
Pin : r e l e a s e o=U n o f f i c i a l Multimedia Packages , a=e x p e r i m e n t a l , l=U n o f f i c i a l
Multimedia Packages
Pin− P r i o r i t y : 10
Package : *
Pin : r e l e a s e o=Debian , a=e x p e r i m e n t a l , l=Debian
Pin− P r i o r i t y : 10
E. Branlard
118
Chapter
12
Shell scripts
12.1 pm-inhibit.py
#! / u s r / b i n / python
import dbus
import time
#import os
import s i g n a l , s y s
if
l e n ( s y s . argv ) != 3 :
s y s . s t d e r r . w r i t e ( ' Usage : pm− i n h i b i t . py <appname> <r e a s o n >\n ' )
sys . exit ( 1 )
d e f s i g h a n d l e r ( signum , frame ) :
dev . U n I n h i b i t ( c o o k i e )
exit ( )
bus = dbus . Bus ( dbus . Bus .TYPE_SESSION )
d e v o b j = bus . g e t_o b j e c t ( ' o r g . f r e e d e s k t o p . PowerManagement ' , ' / o r g /
f r e e d e s k t o p / PowerManagement / I n h i b i t ' )
dev = dbus . I n t e r f a c e ( devobj , " o r g . f r e e d e s k t o p . PowerManagement . I n h i b i t " )
c o o k i e = dev . I n h i b i t ( s y s . argv [ 1 ] , s y s . argv [ 2 ] )
# g o i n g away from dbus when d i e i n g s h o u l d be enough , b u t be s u r e
s i g n a l . s i g n a l ( s i g n a l .SIGTERM, s i g h a n d l e r )
print cookie
while
1 == 1 :
time . s l e e p ( 3 0 )
12.2 pdfAutoRename
#!
/ b i n / sh
i i n * . pdf ; do
""
echo "
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
";
f i l e b a s e=$ { i %. * } ;
for
echo
119
CHAPTER 12. SHELL SCRIPTS
INFO=` p d f i n f o " $ " i 2>/ dev / n u l l ` ;
FIRSTPAGE=` p d f t o t e x t − f 1 − l 1 " $ i " − | head −c 1 0 0 0 | t r −d ' [ * ] ' ` ;
T i t l e =` echo $INFO | awk −F " : " ' / T i t l e / { p r i n t $ 2 } ' `
Author =` echo $INFO | awk −F " : " ' / Author / { p r i n t $ 2 } ' `
S u b j e c t =` echo $INFO | awk −F " : " ' / S u b j e c t / { p r i n t $ 2 } ' `
Date=` echo $FIRSTPAGE | g r e p −E −o −− c o l o r=none " ( 1 8 | 1 9 | 2 0 ) [0 − 9]{2} " | x a r g s
| c u t −c 1 − 4`
### D i s p l a y i n f o r m a t i o n
echo F i l e i s : $ { i %. * } ;
echo T i t l e : $ T i t l e
echo Author : $ Author
echo S u b j e c t : $ S u b j e c t
echo Date : $ Date
### P r e d i f i n e d scheme
t i t l e =" − $ Date − " ` p d f t o t e x t − f 1 − l 1 " $ i " − | t r −d ' [ * ] ' | awk ' ! /
[ 0 − 9 . ] / ' | awk ' / . / ' | t r ' \ n ' ' ' | head −c 1 0 0 `
t i t l e R i s 1=" − $ Date − " ` p d f t o t e x t − f 1 − l 1 " $ i " − | t r −d ' [ * ] ' | awk ' ! /
Ris / ' | awk ' / . / ' | awk ' ! / [ , ] / ' | t r ' \ n ' ' ' | head −c 1 0 0 `
t i t l e R i s 2=" − $ Date − " ` p d f t o t e x t − f 1 − l 1 " $ i " − | t r −d ' [ * ] ' | awk ' ! /
Ris / ' | awk ' / [ A−Za−z0 − 9 . ] / ' | awk ' / . / ' | awk ' ! / [ , ] / ' | t r ' \ n ' ' ' |
head −c 1 0 0 `
t i t l e s a n d i a=" − $ Date − " ` p d f t o t e x t − f 1 − l 1 " $ i " − | t r −d ' [ * ] ' | awk '
! / [ 0 − 9 . ] / ' | awk ' ! /SANDIA REPORT/ ' | awk ' ! / U n l i m i t e d R e l e a s e / ' | awk ' /
. / ' | t r −d ' \ n ' | head −c 1 0 0 `
t i t l e b e g i n=" − $ Date − " ` echo $FIRSTPAGE | c u t −c 1 0 0 `
t i t l e u p p e r=" − $ Date − " ` echo $FIRSTPAGE | g r e p −E −o −− c o l o r=none " [ A−Z
] { 2 } [ A−Z ] * " | x a r g s | c u t −c 1 − 100 `
titleECN =` p d f t o t e x t − f 1 − l 1 " $ i " − | awk ' ! / [ 0 − 9 . ] / ' | awk ' / . / ' | t r ' \
n ' ' ' | head −c 6 4 | t r ' ' '_ ' `
### Making a c h o i c e
nchosen =1;
i f t e s t " ` echo $FIRSTPAGE | c u t −c − 11` " = "WIND ENERGY"
then
"Wind Energy P u b l i c a t i o n "
Date=` p d f t o t e x t − f 1 − l 1 " $ i " − | awk −F " P u b l i s h e d " 'NR < 2 { p r i n t
2 } ' | g r e p −E −o −− c o l o r=none " ( 1 8 | 1 9 | 2 0 ) [0 − 9]{2} " `
T i t l e =` p d f t o t e x t − f 1 − l 1 " $ i " − |awk 'NR==5 { p r i n t $ 0 } ' `
Author =` p d f t o t e x t − f 1 − l 1 " $ i " − |awk 'NR==6 { p r i n t $ 0 } ' | t r −d ' [ :
punct : ] ' | c u t −c 1 − 30 `
t i t l e c h o s e n=" $ Author − $ Date − $ T i t l e "
nchosen=5
e l i f t e s t " ` echo $FIRSTPAGE | c u t −c − 11`" = "ECN"
echo
$
then
t i t l e c h o s e n=titleECN
nchosen=8
e l i f [ −n " ` echo $ S u b j e c t | g r e p " J o u r n a l " ` " ]
then
"JOURNAL OF FLUID MEACHANICS"
Year=` echo $INFO | awk −F " : | " ' / C r e a t i o n D a t e / { p r i n t
}'`
t i t l e c h o s e n=$ Author " − " $ Year " − " $ T i t l e
nchosen=5b
e l i f [ −n " ` echo $FIRSTPAGE | g r e p " Ris " ` " ]
echo
$NF
then
echo
E. Branlard
"RISO INSIDE"
120
CHAPTER 12. SHELL SCRIPTS
if
[ ` expr l e n g t h " $ t i t l e R i s 1 " ` − g t 12 ]
then
t i t l e c h o s e n=$ t i t l e R i s 1
nchosen =2;
else
t i t l e c h o s e n=$ t i t l e
nchosen =1;
fi
e l i f [ −n " ` echo
$FIRSTPAGE |
g r e p "SANDIA" ` " ]
then
"SANDIA INSIDE"
t i t l e c h o s e n=$ t i t l e s a n d i a
nchosen=4
e l i f [ −n " ` echo $ S u b j e c t | g r e p " J o u r n a l " ` " ]
echo
then
"JOURNAL OF FLUID MEACHANICS"
Year=` echo $INFO | awk −F " : | " ' / C r e a t i o n D a t e / { p r i n t
t i t l e c h o s e n=$ Author " − " $ Year " − " $ T i t l e
nchosen=5b
e l i f [ −n " $ T i t l e " ]
echo
$NF}
'`
then
t i t l e c h o s e n=$ T i t l e ;
nchosen =5;
else
t i t l e c h o s e n=$ t i t l e ;
nchosen =1;
fi
if
[ ` expr l e n g t h " $ t i t l e " ` − l t 7 ]
then
nchosen =0;
t i t l e c h o s e n=" $ f i l e b a s e "
fi
t i t l e p d f i n f o=$ Author " −
$ Date
− "$ T i t l e
### User i n t e r a c t
echo "− C h o i c e s : "
echo 1 − $ t i t l e
echo 2 − $ t i t l e R i s 1
echo 3 − $ t i t l e R i s 2
echo 4 − $ t i t l e s a n d i a
echo 5 − $ t i t l e p d f i n f o
echo 6 − $ t i t l e b e g i n
echo 7 − $ t i t l e u p p e r
echo 8 − $ titleECN
echo " "
echo " $ nchosen )−>" $ t i t l e c h o s e n
echo " "
echo "−Type e n t e r f o r d e f a u l t , number f o r c h o i c e , 0 f o r n o t h i n g "
read c h o i c e
i f [ −n " $ c h o i c e " ]
then
echo
" Using c h o i c e $ c h o i c e "
in
d e s t=" $ f i l e b a s e " ; ;
d e s t=" $ t i t l e " ; ;
d e s t=" $ t i t l e R i s 1 " ; ;
d e s t=" $ t i t l e R i s 2 " ; ;
d e s t=" $ t i t l e s a n d i a " ; ;
c a se $ c h o i c e
0)
1)
2)
3)
4)
E. Branlard
121
CHAPTER 12. SHELL SCRIPTS
5 ) d e s t=" $ t i t l e p d f i n f o " ; ;
6 ) d e s t=" $ t i t l e b e g i n " ; ;
7 ) d e s t=" $ t i t l e u p p e r " ; ;
8 ) d e s t=" $ titleECN " ; ;
esac
else
" Using d e f a u l t : "
d e s t=$ t i t l e c h o s e n
echo
fi
# echo "mv $ i $ d e s t "
mv " $ i " " $ d e s t . pdf "
done
12.3 alarmaniac
#! / b i n / sh
cd / home /manu/ C o n f i g / b i n / Alarmaniac /
java −j a r alarmaniac . j a r
12.4 pdfocr
#! / b i n / bash
echo " Usage : p d f 2 o c r . sh FILE . pdf l a n g "
i f [ −e tmp ] ;
then
echo
echo
echo
read
" F o l d e r tmp/ e x i s t s − Continue anyway ? " ;
" YES : P r e s s Enter " ;
" NO : P r e s s C t r l+C " ;
reply
else
mkdir tmp
fi
" "
"− E n t e r i n g f o l d e r tmp"
cd tmp
ERRORS=0
echo
echo
" "
"− B u r s t i n g with p d f t k . . . "
p d f t k " . . /$ 1 " b u r s t dont_ask
echo
echo
echo
for
" "
f i n pg_* . pdf
do
"− Pre− p r o c e s s i n g $ f . . . " ;
c o n v e r t − q u i e t −monochrome − n o r m a l i z e − d e n s i t y 300 " $ f " " $ f . png" ;
echo
done
echo
for
" "
f i n pg_* . png
do
"− P r o c e s s i n g $ f . . . "
c o n v e r t " $ f " " $ f . bmp"
echo " Merging BMP and hOCR i n t o PDF f i l e . . . "
echo
E. Branlard
122
CHAPTER 12. SHELL SCRIPTS
c u n e i f o r m − l $ 2 − f h o c r −o " $ f . html " " $ f . bmp"
c o n v e r t − b l u r 0 . 4 " $ f " " $ f . bmp"
OUT=$ ?
h o c r 2 p d f − i " $ f " − s −o " $ f . pdf " < " $ f . html "
OUT=` expr $ ? + $OUT`
i f [ $OUT − g t 127 ] ;
then
echo " $ f " >> . . / e r r o r s . l o g ;
ERRORS=` expr $ERRORS + 1 ` ;
cp " $ { f%%. png} " " $ f . pdf "
fi
rm
− f " $ f . bmp"
done
" "
"− Binding with p d f t k . . . "
p d f t k pg_* . png . pdf output " . . /$1−OCR. pdf "
echo
echo
echo
[
if
" "
$ERRORS
−g t 0 ] ;
then
echo
cat
"− Number o f e r r o r s
. . /errors . log
$ERRORS"
fi
echo
"Done , s h o u l d I d e l e t e a l l t h e temporary f i l e s ? "
echo
" YES : P r e s s Enter " ;
" NO : P r e s s C t r l+C " ;
reply
echo
read
rm
− r pg_*
12.5 backupSyst
#! / b i n / sh
#i n i t i a l i z a t i o n
HOME=/home/manu
f o l d e r=backup_data /
mydate=$ ( d a t e +%Y−%m−%d−%H%M)
f o l d e r=$ f o l d e r $ mydate
mkdir −p $ f o l d e r
cd $ f o l d e r
#c r e a t i n g a r b o r e s c e n c e
mkdir −p home/ c o n f i g
mkdir −p home/ l o c a l / s h a r e / rhythmbox
mkdir −p e t c / network
mkdir −p l o g
mkdir e t c / e v e n t . d
mkdir e t c / grub . d /
mkdir e t c / c r o n . d a i l y /
mkdir e t c / c r o n . weekly /
mkdir e t c /X11
E. Branlard
123
CHAPTER 12. SHELL SCRIPTS
mkdir e t c / apt
mkdir e t c / texmf
mkdir e t c / samba
mkdir e t c / d e f a u l t
mkdir e t c / s s h
mkdir e t c / apache2
mkdir e t c / l o g r o t a t e . d
mkdir −p l i b / l s b /
mkdir e t c / p r o f t p d
mkdir e t c / f a i l 2 b a n
#mkdir −p e t c /gdm/ I n i t /
# l i s t e des paquets
dpkg −−get − s e l e c t i o n s > l i s t e −p a q u e t s . dpkg
#home f o l d e r
cp $HOME/ . b a s h r c home / b a s h r c
cp $HOME/ . bash_ p r o f i l e home / bash_ p r o f i l e
cp $HOME/ . vimrc home / vimrc
cp $HOME/ . x i n i t r c home / x i n i t r c
cp $HOME/ . X d e f a u l t s home / X d e f a u l t s
cp $HOME/ . c o n k y r c home / c o n k y r c
cp $HOME/ . a s o u n d r c home / a s o u n d r c
cp − r $HOME/ . c o n f i g / * home / c o n f i g /
cp $HOME/ . l o c a l / s h a r e / rhythmbox / p l a y l i s t s . xml home / l o c a l / s h a r e / rhythmbox /
p l a y l i s t s . xml
#system
cp / e t c / f s t a b e t c / f s t a b
cp / e t c / modules e t c / modules
#cp / e t c / e v e n t . d / t t y 1 e t c / e v e n t . d / t t y 1
cp / e t c / i s s u e e t c / i s s u e
cp / e t c / i n i t t a b e t c /
cp / e t c / s u d o e r s e t c
cp / e t c / group e t c /
cp / e t c / passwd e t c / passwd
cp / e t c / c r o n . d a i l y / * e t c / c r o n . d a i l y /
cp / e t c / c r o n . weekly / * e t c / c r o n . weekly /
cp / e t c / l o g r o t a t e . c o n f e t c / l o g r o t a t e . c o n f
cp / e t c / l o g r o t a t e . d / r s y s l o g e t c / l o g r o t a t e . d / r s y s l o g
cp / e t c / network / i n t e r f a c e s e t c / network / i n t e r f a c e s
cp / e t c / X11 / xorg . c o n f
e t c /X11/ xorg . c o n f
cp / e t c / apt / s o u r c e s . l i s t e t c / apt / s o u r c e s . l i s t
cp / e t c / apt / p r e f e r e n c e s e t c / apt / p r e f e r e n c e s
#cp / b o o t / g r u b /menu . l s t menu . l s t
cp / boot / grub / grub . c f g grub . c f g
cp / e t c / grub . d / * e t c / grub . d /
cp / e t c / s y s c t l . c o n f e t c /
cp / e t c / d e f a u l t / r c S e t c / d e f a u l t / r c S
cp / l i b / l s b / i n i t − f u n c t i o n s l i b / l s b /
#programs
E. Branlard
124
CHAPTER 12. SHELL SCRIPTS
cp / e t c / l a t e x 2 h t m l
. conf etc/
. c n f e t c / texmf / texmf . c n f
cp / e t c / samba /smb . c o n f e t c / samba /
cp −R / e t c / apache2 / * e t c / apache2 /
cp / e t c / s s h / s s h d_c o n f i g e t c / s s h /
#cp / e t c /gdm/ I n i t / D e f a u l t e t c /gdm/ I n i t / D e f a u l t
cp / e t c / p r o f t p d / p r o f t p d . c o n f e t c / p r o f t p d /
cp / e t c / p r o f t p d / msg / * e t c / p r o f t p d
cp / e t c / f a i l 2 b a n / j a i l . l o c a l e t c / f a i l 2 b a n
cp / e t c / texmf / texmf
#p r o c e s s u s i n i t
cp −R / e t c / i n i t . d e t c / i n i t . d
cp −R / e t c / r c 0 . d e t c / r c 0 . d
cp −R / e t c / r c 1 . d e t c / r c 1 . d
cp −R / e t c / r c 2 . d e t c / r c 2 . d
cp −R / e t c / r c 3 . d e t c / r c 3 . d
cp −R / e t c / r c 4 . d e t c / r c 4 . d
cp −R / e t c / r c 5 . d e t c / r c 5 . d
cp −R / e t c / r c 6 . d e t c / r c 6 . d
cp −R / e t c / r c S . d e t c / r c S . d
#l o g s
cp / var / l o g / dmesg l o g / dmesg
cp / var / l o g / daemon . l o g l o g / daemon . l o g
cp / var / l o g / me ssa ges l o g / me ssa ges
cp / var / l o g / s y s l o g l o g / s y s l o g
cp / var / l o g / kern . l o g l o g / kern . l o g
cp / var / l o g / a p t i t u d e l o g /
#G i v i n g r i g h t s t o a l l f i l e s
cd . . / . . /
chown −R manu : manu $ f o l d e r
12.6 shrinkFig2
#! / b i n / sh
#############################################################
# S h r i n k Fig
#############################################################
# D e s c r i p t i o n : S h r i n k F i g u r e t o 60%
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies : image magick
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
#############################################################
for i
do
m o g r i f y − r e s i z e 60%
$i
done
12.7 topdf
E. Branlard
125
CHAPTER 12. SHELL SCRIPTS
#!
if
/ b i n / bash
[
$#
− eq 0 ]
then
F i l e s=* . j p g
F i l e s=" $ F i l e s "
else
l=$@
B u f f=" "
First =''
for i in
$l
do
[
if
!
` echo
$i
| g r e p −E " [ . ] [ a−zA−Z ] { 3 , 4 } $ " ` = " " ]
then
F i l e=" $ B u f f $ i "
B u f f=" "
F i r s t=" "
F i l e 2 =` echo $ F i l e | t r ' ' '_ ' `
#
i f [ $ F i l e != $ F i l e 2 ]
then
mv
"$ F i l e "
$File2
fi
#
F i l e s=" $ F i l e s
$File2 "
else
if
[ −z
${ F i r s t }
]
then
B u f f=" $ i "
F i r s t="no"
else
B u f f=" $ B u f f
$i
"
fi
fi
#
done
echo
$Files
F i l e O u t =` echo
$Files
fi
| g r e p −Eo " ^ [ a−Z0 −9\_ − ] * [ . ] " | t r '_ ' ' ' ` " pdf "
echo $ F i l e O u t
convert
$Files
"$ F i l e O u t "
12.8 xsetnumlock.c
#i n c l u d e <X11/ e x t e n s i o n s / XTest . h>
#i n c l u d e <X11/ keysym . h>
/
*
Requires :
a p t i t u d e i n s t a l l l i b x c b −keysyms1 −dev l i b x t s t −dev
Compiled with :
g c c − I / u s r / i n c l u d e /X11 −L/ u s r / l i b /X11 −o xsetnumlock xsetnumlock . c −lX11 −
l X t s t */
E. Branlard
126
CHAPTER 12. SHELL SCRIPTS
i n t main ( v o i d )
{
D i s p l a y * d i s p = XOpenDisplay (NULL) ;
if
( d i s p == NULL)
return
1;
XTestFakeKeyEvent ( d i s p , XKeysymToKeycode ( d i s p , XK_Num_Lock ) ,
True , CurrentTime ) ;
XTestFakeKeyEvent ( d i s p , XKeysymToKeycode ( d i s p , XK_Num_Lock ) ,
F a l s e , CurrentTime ) ;
XCloseDisplay ( disp ) ;
return
}
0;
12.9 ifort-setup
#! / b i n / bash
source / opt / i n t e l / Compiler / 1 1 . 1 / 069 / b i n / i f o r t v a r s
. sh
ia32
12.10 convertEnc
#! / b i n / bash
#
# Conversion de t o u t e une a r b o r e s c e n c e d ' un encodage dans un a u t r e .
# Exemple d ' u t i l i s a t i o n :
# mise a j o u r de sa d i s t r i b u t i o n Linux de i s o −8859−1 v e r s UTF−8
#
# N e c e s s i t e : convmv e t i c o n v
#
# Utilisation :
# $ . / convertEnc . sh Documents / D i v e r s
#
# IMPORTANT : f a i t e s une c o p i e de v o s donnees e t t r a v a i l l e z s u r c e t t e
copie ! !
# ( Je ne peux e t r e tenu r e s p o n s a b l e s i vous corrompez v o s donnees , s o y e z
prudents )
#
# Ce s c r i p t ne demande qu ' a e t r e a m e l i o r e . . .
#
## P r o t e c t i o n c o n t r e l e s e s p a c e s ( JacquesF −> g u i l l e m e t s a u t o u r d e s
v a r i a b l e s ou c e l a n ' e t a i t pas f a i t )
#
# S e b a s t i e n de B o i s s i e u ( c ) 2006
# $ Id : convertEnc . sh , v 1 . 8 . 2 . 1 2007 / 03 / 17 2 2 : 3 9 : 2 9 s e b a s t i e n Exp $
# L i c e n c e : GPL 2
FROM=" i s o −8859 −1"
TO="UTF−8"
echo
" C o n v e r s i o n de
$FROM
en
$TO"
# Procedure pour renommer un f i c h i e r s i nom d e j a e x i s t a n t
renomme ( )
E. Branlard
127
CHAPTER 12. SHELL SCRIPTS
{
nbe=0
num="_$ nbe "
nouvnom=" $ 1 "
while [ −e " $ nouvnom" ] ;
do
l e t nbe=nbe+1
num="_$ nbe "
nouvnom=" $ 1 $num"
done
export
}
nouvnom
# Conversion r e c u r s i v e d e s noms de f i c h i e r s e t r e p e r t o i r e s
c o n v e r t_names ( )
{
echo " C o n v e r s i o n d e s NOMS de f i c h i e r s e t r e p e r t o i r e s "
#convmv −r − f $FROM − t $TO −−qfrom −− q t o −− n o t e s t " $ 1"
convmv − r − f $FROM − t $TO −− n o t e s t " $ 1 "
echo " "
}
# Routine de c o n v e r s i o n du contenu d ' un f i c h i e r
do_c o n v e r t ( )
{
f i c =" $ 1 "
echo "
Fichier $ f i c "
# L e c t u r e du t y p e mime
encForm=` f i l e − b i " $ f i c " | awk −F " c h a r s e t=" ' { p r i n t $ 2 } ' `
if [ !
" $ encForm" = " " ] ; then
# l e f i c h i e r p o s s e d e un c h a r s e t
echo "
−> $ encForm"
i f [ ! " $ encForm" = " $TO" ] ; then
# ce c h a r s e t e s t d i f f e r e n t de c e l u i v i s e
# nom du f i c h i e r c o n v e r t i t e m p o r a i r e
renomme " $ f i c "_" $TO"
nouv_ f i c =" $ nouvnom"
# la conversion
i c o n v − f " $ encForm" − t $TO " $ f i c " −o " $ nouv_ f i c "
# r e u s s i t e ou e c h e c de l a commande c r u c i a l e ?
s t a t u s=$ ?
i f [ $ s t a t u s == 0 ] ; then
# Pour c o n s e r v e r l a / l e s d a t e ( s ) :
touch − r " $ f i c " " $ nouv_ f i c "
# Pour c o n s e r v e r l e p r o p r i e t a i r e
chown −− r e f e r e n c e " $ f i c " " $ nouv_ f i c "
# pour c o n s e r v e r l e s d r o i t s :
chmod −− r e f e r e n c e " $ f i c " " $ nouv_ f i c "
# on e c r a s e l ' a n c i e n f i c h i e r par l e nouveau
i f [ −w " $ f i c " ] ; then
### JacquesF
### Sur mes t e s t s , s i l e f i c h i e r n ' e s t pas a c c e s s i b l e en
ecriture
### un mv − f s u r l e f i c h i e r remplace p o u r t a n t c e l u i − c i (
d r o i t s d ' e c r i t u r e dans l e r e p e r t o i r e )
mv − f " $ nouv_ f i c " " $ f i c "
else
echo
echo
E. Branlard
"Le f i c h i e r $ f i c n ' e s t pas a c c e s s i b l e en e c r i t u r e "
"Le f i c h i e r c o n v e r t i s e nomme $ nouv_ f i c "
128
CHAPTER 12. SHELL SCRIPTS
fi
else
echo
echo
"
"
−> Echec :
$ nouv_ f i c
$fic
corrompu ? "
conserve . "
fi
fi
fi
}
# Conversion r e c u r s i v e du contenu d e s f i c h i e r s t e x t e
c o n v e r t_c o n t e n t ( )
{
#echo " Conversion du contenu d e s f i c h i e r s "
i f [ −d " $ 1 " ] ; then
# c ' e s t un r e p e r t o i r e
i f [ −x " $ 1 " ] ; then
# On p e u t e n t r e r dans l e r e p e r t o i r e
echo " En tree dans : $ 1 "
### P r o t e c t i o n s i l e r e p e r t o i r e c o n t i e n t un e s p a c e
chemin_o r i g=" ` pwd ` "
cd −− " $ 1 "
# l i s t e c o m p l e t e ( avec f i c h i e r s c a c h e s )
# A t t e n t i o n : s i l i s t e t r o p l o n g u e ca p e u t p l a n t e r
# p a s s e r par x a r g s −−> man x a r g s
f o r f i c i n ` l s * . * | xargs ` ; do
i f [ $ f i c != " . " −a $ f i c != " . . " ] ; then
b a s e_ f i c =$ ( basename −− " $ f i c " )
#echo " $ f i c −> $ b a s e_ f i c "
echo " Analyse de : $ b a s e_ f i c "
# recursivite
i f [ −d " $ b a s e_ f i c " ] ; then
# S i r e p e r t o i r e , on e x e c u t e l a p r o c e d u r e d e s s u s
c o n v e r t_c o n t e n t " $ b a s e_ f i c "
else
# s i n o n on f a i t l a c o n v e r s i o n
do_c o n v e r t " $ b a s e_ f i c "
fi
fi
done
" S o r t i e de :
" $ chemin_o r i g "
echo
cd
$1 "
else
echo
" En tree INTERDITE dans :
$1 "
fi
else
# On f a i t l a c o n v e r s i o n s u r l e f i c h i e r
do_c o n v e r t " $ 1 "
fi
}
#=======================================
# Debut e x e c u t i o n
i f [ $# − g t 0 ] ; t h e n
### A l e r t e a v a n t lancement du s c r i p t
clear
E. Branlard
129
CHAPTER 12. SHELL SCRIPTS
−e " \n\nATTENTION : ne t r a v a i l l e z j a m a i s s u r l e s donnees d '
origine !"
echo −e " \ nEtes −vous c e r t a i n de v o u l o i r m o d i f i e r c e s f i c h i e r s ? "
echo −e " \ tAppuyez s u r C t r l −C pour a n n u l e r ou s u r Return pour
continuer \c"
read Tempo
echo
echo
### Fin de l ' a l e r t e
# pour l ' i n s t a n t on ne c o n s i d e r e que l e 1 e r argument
echo " Sur : $ 1 "
echo " "
###
On n ' e s t pas a l ' a b r i d ' un r e p e r t o i r e avec d e s e s p a c e s dans l e
nom
c o n v e r t_names " $ 1 "
echo "============="
# Remarque : s i $ 1 e s t un r e p e r t o i r e dont l e nom a e t e c o n v e r t i
# l e contenu de $ 1 e s t o b s o l e t e .
# on l e c o n v e r t i :
nom=$ ( echo " $ 1 " | i c o n v − f $FROM − t $TO)
c o n v e r t_c o n t e n t " $nom"
echo
" Fini "
else
" Utilisation :"
" $ 0 chemin / r e p e r t o i r e "
### A l e r t e par p r e c a u t i o n
echo "Ne t r a v a i l l e z j a m a i s s u r l e s donnees d ' o r i g i n e mais s e u l e m e n t
s u r une c o p i e de c e l l e s − c i "
echo
echo
fi
12.11 xfce4ToggleDesktop
#! / b i n / sh
i f xprop − r o o t
_NET_SHOWING_DESKTOP| e g r e p '= 1 ' ;
wmctrl −k o f f ;
then
else
wmctrl −k on ;
fi
12.12 keywordsSetUp
#! / b i n / bash
SAVEIFS=$ IFS
IFS=$ ( echo −en " \n\b" )
echo
for
" Converting pdfs "
i i n ` f i n d −name " * . php" − p r i n t f '%h /%f \n '
2>
/ dev / n u l l
`
do
"−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
" Keywords $ i " ;
echo "−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
cp $ i " $ i . tmp"
c a t " $ i . tmp" | awk ' $ 0 ! ~ NAME=" keywords " { p r i n t $ 0 } ; $ 0
keywords " { p r i n t "<META NAME=\" keywords \ " CONTENT=\"
KEYWORDSSHOULDGOHERE\ ">" } ' >$ i
echo
echo
E. Branlard
~
NAME="
130
CHAPTER 12. SHELL SCRIPTS
rm
done ;
" $ i . tmp"
IFS=$SAVEIFS
12.13 pdfocr-tess
#! / b i n / bash
echo " u s a g e : p d f o c r . sh document . pdf \ " a u t h o r \ " \" t i t l e \ " "
# Adapted from h t t p : // b l o g . k o n r a d v o e l k e l . de / 2010 / 01 / l i n u x −ocr −and−pdf −
problem − s o l v e d /
# NOTE: This s c r i p t has been s u b s t a n t i a l l y m o d i f i e d / s i m p l i f i e d from t h e
original .
# This v e r s i o n does not a l l o w r o t a t i o n , l a n g u a g e s e l e c t i o n or c r o p p i n g .
# Those p a r a m e t e r s were a l l r e q u i r e d i n t h e o r i g i n a l , b u t I don ' t r e a l l y
need them .
# I f you can t h i n k o f a way t o make them o p t i o n a l , p l e a s e s h a r e .
# This v e r s i o n a l s o u s e s T e s s e r a c t , which I f i n d t o be s u b s t a n t i a l l y more
# a c c u r a t e than Cuneiform f o r E n g l i s h t e x t .
# u s a g e examples :
#echo " InfoKey : Author " > i n . i n f o
#echo " I n f o V a l u e : $ 2" >> i n . i n f o
#echo " InfoKey : T i t l e " >> i n . i n f o
#echo " I n f o V a l u e : $ 3" >> i n . i n f o
#echo " InfoKey : C r e a t o r " >> i n . i n f o
#echo " I n f o V a l u e : PDF OCR scan s c r i p t " >> i n . i n f o
#p d f j o i n −− f i t p a p e r −− t i d y −− o u t f i l e " $ 1 . ocr1 . p d f " " pg_*− ocr . p d f "
#rm − f pg_*
#p d f t k " $ 1 . ocr1 . p d f " u p d a t e_i n f o doc_d a t a . t x t o u t p u t " $ 1 . ocr2 . p d f "
#p d f t k " $ 1 . ocr2 . p d f " u p d a t e_i n f o i n . i n f o o u t p u t " $1− ocr . p d f "
#rm − f " $ 1 . ocr1 . p d f " " $ 1 . ocr2 . p d f " doc_d a t a x . t x t i n . i n f o
#! / b i n / bash
echo " Usage : p d f 2 o c r . sh FILE . pdf l a n g "
i f [ −e tmp ] ;
then
echo
echo
echo
read
" F o l d e r tmp/ e x i s t s − Continue anyway ? " ;
" YES : P r e s s Enter " ;
" NO : P r e s s C t r l+C " ;
reply
else
mkdir tmp
fi
" "
"− E n t e r i n g f o l d e r tmp"
cd tmp
ERRORS=0
echo
echo
" "
"− B u r s t i n g with p d f t k . . . "
p d f t k " . . /$ 1 " b u r s t dont_ask
echo
echo
echo
for
" "
f i n pg_* . pdf
do
echo "− Pre − p r o c e s s i n g $ f . . . " ;
# c o n v e r t − q u i e t −monochrome − n o r m a l i z e − d e n s i t y 300 " $ f " " $ f . png " ;
c o n v e r t − q u i e t − d e n s i t y 300 −depth 8 " $ f " " $ f . t i f "
E. Branlard
131
CHAPTER 12. SHELL SCRIPTS
done
echo
for
" "
f i n pg_* . t i f
do
"− P r o c e s s i n g $ f . . . "
t e s s e r a c t "$ f " "$ f " h o c r
echo " Merging BMP and hOCR i n t o PDF f i l e . . . "
h o c r 2 p d f − i " $ f " −o " $ f −o c r . pdf " <" $ f . html "
OUT=$ ?
i f [ $OUT − g t 127 ] ;
echo
then
echo " $ f " >> . . / e r r o r s . l o g ;
ERRORS=` expr $ERRORS + 1 ` ;
cp " $ { f%%. png} " " $ f . pdf "
fi
done
" "
"− Binding with p d f t k . . . "
p d f t k pg_* . png . pdf output " . . /$1−OCR. pdf "
echo
echo
echo
[
if
" "
$ERRORS
−g t 0 ] ;
then
echo
cat
"− Number o f e r r o r s
. . /errors . log
$ERRORS"
fi
echo
"Done , s h o u l d I d e l e t e a l l t h e temporary f i l e s ? "
echo
" YES : P r e s s Enter " ;
" NO : P r e s s C t r l+C " ;
reply
echo
read
rm
− r pg_*
12.14 GETAPTKEY
#! / b i n / sh
# @(#) TITLE MESSAGE: R e c u p e r a t i o n d e s c l e s GPG e t e x p o r t a t i o n v e r s a p t
# @(#) F e i l o n g v e r s i o n 05 / 01 / 2009
# @(#) S y n t a x e : GETKEY KEY
# @(#) MACHINE VM DEBIAN l e n n y
i f [ $ ( i d −u ) != " 0 " ] ; then
echo “Seul r o o t peut e x e c u t e r c e s h e l l ⠀  >&2
exit 1
fi
if
[
echo
exit
$#
−ne 1 ] ; t h e n
“syntaxe : GETKEY <v o t r e c l e >”
1
fi
gpg ⠀ “ k e y s e r v e r hkp : //wwwkeys . eu . pgp . n e t –recv −k e y s $ 1
i f [ $ ? −ne 0 ] ; then
echo ” Une e r r e u r e s t survenu pendant l e téléchargement de l a clé”
exit 1
E. Branlard
132
CHAPTER 12. SHELL SCRIPTS
fi
gpg –armor –export $ 1 | apt −key add −
i f [ $ ? −ne 0 ] ; then
echo ” Une e r r e u r e s t survenu pendant l’export de l a c l à © v e r s apt”
exit 1
fi
apt −g e t update
12.15 rhythmboxstart
#! / b i n / sh
#l a u n c h i n g
rhythmbox&
#a f t e r a w h i l e u s i n g t h e c l i e n t t o p l a y
s l e e p 2 ; rhythmbox− c l i e n t −− p l a y −− h i d e&
12.16 rhythmboxstartlong
#! / b i n / sh
#l a u n c h i n g
rhythmbox&
#a f t e r a w h i l e u s i n g t h e c l i e n t t o p l a y
s l e e p 2 0 ; rhythmbox− c l i e n t −− p l a y −− h i d e&
12.17 showTag
#! / u s r / b i n / python
#############################################################
# Show Tag
#############################################################
# Description : n o t i f y audio t a g s
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies :
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
# Note :
#############################################################
import mutagen
import o p t p a r s e
import s u b p r o c e s s
parser = optparse . OptionParser ( )
( o p t i o n s , a r g s ) = p a r s e r . p a r s e_a r g s ( )
d e f getKey ( audio , key ) :
try :
f=a u d i o [ key ] . pop ( ) . encode ( ' u t f − 8 ')
e x c e p t KeyError :
p r i n t " caught "
f=""
return ( f )
a u d i o=mutagen . F i l e ( a r g s [ 0 ] , e a s y=True )
E. Branlard
133
CHAPTER 12. SHELL SCRIPTS
a r t i s t=getKey ( audio , ' a r t i s t ' )
album=getKey ( audio , ' album ' )
s o n g t i t l e=getKey ( audio , ' t i t l e ' )
g e n r e=getKey ( audio , ' genre ' )
y e a r=getKey ( audio , ' date ' )
print ar t is t
print songtitle
p r i n t album
print genre
print year
s u b p r o c e s s . c a l l ( [ " n o t i f y −send " , a r t i s t+" \n"+s o n g t i t l e+" \n"+album+" \n"+g e n r e
+" \n"+y e a r ] )
12.18 4terms
#! / b i n / sh
x f c e 4 −t e r m i n a l
x f c e 4 −t e r m i n a l
x f c e 4 −t e r m i n a l
x f c e 4 −t e r m i n a l
−T
−T
−T
−T
T4
T1
T3
T2
−−geometry
−−geometry
−−geometry
−−geometry
80 x26+800+450 &
80 x26+84+0 &
80 x26+800+0 &
80 x26+84+450 &
12.19 ECN-RenameByTitle.sh
#!
/ b i n / bash
i i n * . pdf ; do
""
echo "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−" ;
echo $ { i %. * } ;
t i t l e =` p d f t o t e x t − f 1 − l 1 $ i − | awk ' ! / [ 0 − 9 . ] / ' | awk ' / . / ' | t r ' \ n ' '
' | head −c 6 4 | t r ' ' '_ ' `
mv " $ i " " $ { i %. * }_$ t i t l e . pdf "
for
echo
done
12.20 compilWebVersion
#! / b i n / bash
unalias grep
########################################################################
# Preliminary t e s t s
########################################################################
i f [ $# == 0 ]
then
echo
exit
;
"No arguments
!"
;
fi
c p t =` l s / u s r / b i n 2>/ dev / n u l l | g r e p gawk | wc − l `
i f [ $ c p t == 0 ]
then
echo
exit
E. Branlard
;
" I n s t a l l gawk
!"
;
134
CHAPTER 12. SHELL SCRIPTS
fi
c p t =` l s / u s r / b i n 2>/ dev / n u l l | g r e p l a t e x 2 h t m l | wc − l `
i f [ $ c p t == 0 ]
then
echo
exit
;
" I n s t a l l latex2html
!"
;
fi
#
echo
cd $ 1
" Entering f o l d e r
$1 "
#
" Trying * r e p o r t * . t e x "
c p t =` l s * e p o r t * . t e x 2>/ dev / n u l l | wc − l `
echo $ c p t
i f [ $ c p t −ne 1 ]
echo
then
if
[
$cpt
−g t 0 ]
then
l s *eport* . tex
" Ambiguity on t h e main f i l e name
exit ;
echo
!"
else
" Trying * . t e x "
c p t =` l s * . t e x 2>/ dev / n u l l | wc − l `
echo $ c p t
i f [ $ c p t −ne 1 ]
echo
then
l s * . tex
" Ambiguity on t h e main f i l e name
exit ;
echo
!"
else
f =` echo * . tex ` ;
fi
fi
else
f =` echo * e p o r t * . tex ` ;
fi
""
"Main f i l e : $ f "
cp $ f $ { f / t e x / backuptex }
t i t l e =` g r e p t i t l e a $ f | awk −v FS=" [ { } ] " ' { p r i n t $ 4 } ' | xargs `
echo " T i t l e : $ t i t l e \n"
echo " "
echo " P r e s s ENTER i f e v e r y t h i n g ' s OK , C t r l+C o t h e r w i s e "
echo
echo
read
########################################################################
# Removing p d f
########################################################################
echo "##################################################################"
echo " C o n v e r t i n g pdf t o png"
echo "##################################################################"
rm * . pdf 2>/ dev / n u l l
. . / pdf2pngCleanUp
E. Branlard
135
CHAPTER 12. SHELL SCRIPTS
########################################################################
# l a t e x work
########################################################################
echo "##################################################################"
echo " Formatting "
echo "##################################################################"
" Modifying f i g u r e width "
g r e p −nHFR \\\newcommand{\\\ f i t f i g } . /* > tmp . tmp
f f =`gawk −F : ' { p r i n t $ 1 } ' tmp . tmp `
i f ` t e s t −e $ f f `
echo
then
sed
− i " s / {\\\ f i t f i g }\[1\]{[#0 − 9\\\ a−zA−Z ] * } / {\\\ f i t f i g } [ 1 ] { 1 4 cm} / g "
$ff
fi
"Commenting x c o l o r "
g r e p −nHR . * { x c o l o r } . /* > tmp . tmp
f f =`gawk −F : ' { p r i n t $ 1 } ' tmp . tmp `
i f ` t e s t −e $ f f `
echo
then
sed
− i " s / . * u s e p a c k a g e . * { x c o l o r } */%\\\ u s e p a c k a g e [ t a b l e ] { x c o l o r }
/g " $ f f
fi
" Modifying f o r p a r s h a p e "
g r e p −nHR . * \\\ p a r s h a p e . /* > tmp . tmp
f f =`gawk −F : ' { p r i n t $ 1 } ' tmp . tmp `
i f ` t e s t −e $ f f `
echo
then
sed
− i " s / . * \\\ p a r s h a p e /%/ g "
$ff
fi
tmp . tmp
" Modifying $ f f o r u n d e f i n e d commands b e f o r e \ b e g i n { document } "
o l d_v a l u e=" . * \\\ b e g i n { document } " ;
new_v a l u e=" \\\newcommand{\\\ r o w c o l o r s } [ 3 ] { } \\\ renewcommand {\\\
a r r a y r u l e c o l o r } [ 1 ] { } \\\ renewcommand {\\\ rhead } [ 1 ] { } \\\ renewcommand {\\\
h y p e r s e t u p } [ 1 ] { } \\\ renewcommand {\\\ l s t s e t } [ 1 ] { } \\\ renewcommand {\\\
framebox } [ 1 ] { # 1 } \\\ renewcommand {\\\ s c r i p t } [ 1 ] { } \\\ renewcommand {\\\
command } [ 1 ] { } \\\ renewcommand {\\\ d t u t e x t } [ 1 ] { # 1 \ \ \ par } \\\ b e g i n {
document } " ;
sed − i " s /$ o l d_v a l u e /$ new_v a l u e / g " $ f
rm
echo
"##################################################################"
" Running p d f l a t e x a f i r s t time on $ f "
echo "##################################################################"
pdflatex $f
echo
echo
"##################################################################"
" Running b i b t e x on $ f "
echo "##################################################################"
f f =* . aux
bibtex $ f f
echo
echo
E. Branlard
136
CHAPTER 12. SHELL SCRIPTS
"##################################################################"
" Running p d f l a t e x a s e c o n d time on $ f "
echo "##################################################################"
pdflatex $f
echo
echo
########################################################################
# l a t e x 2 html and p o s t f o r m a t t i n g
########################################################################
echo "##################################################################"
echo "Now Running l a t e x 2 h t m l "
echo "##################################################################"
" Running l a t e x 2 h t m l on f o l d e r $ 1 "
l a t e x 2 h t m l −html_v e r s i o n 4 . 0 , ISO −8859 −1 − a d d r e s s " " − s p l i t 2
mkdir − t " $ t i t l e "
echo
$f
−d i r
$1
−
"Done . I f r e s u l t s a r e bad , check t h a t t h e package x c o l o r has been
commented . "
echo
" Formatting "
− r $ 1 " $1−bkp"
cd $ 1
rename " s / html / php / g " * . html
sed − i " s / [ . ] html / . php / g " * . php
sed − i " s :< /HEAD> : : g " * . php
echo
cp
o l d_v a l u e="<BODY >" ;
new_v a l u e="<? i n c l u d e ( ' . . /_i n c l u d e s / haut . php ' ) ;? > " ;
sed − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
o l d_v a l u e="<ADDRESS>" ;
new_v a l u e="<? i n c l u d e ( ' . . /_i n c l u d e s / bas . php ' ) ; ?>" ;
sed − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
o l d_v a l u e="</ADDRESS>" ;
new_v a l u e=" " ;
sed − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
o l d_v a l u e="</ADDRESS>" ;
new_v a l u e=" " ;
sed − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
########################################################################
# Keywords
########################################################################
echo "##################################################################"
echo " Keywords "
echo "##################################################################"
keywords =` c a t * php * | sed −e : a −e ' s / <[^>] *>// g ; /</N; // ba ' | t r ' ' ' \ n '
| t r −d ' [ : punct : ] ' | g r e p −v ' [ ^ a−z ] ' | g r e p −E ' [ a−z ] { 3 , } ' | t r ' [ :
upper : ] ' ' [ : l o w e r : ] ' | g r e p −v −w −E ' t h e | and | f o r | from | with | used | which |
a r e | t h a t | t h i s | w i l l | can | been | s h o u l d | u s i n g | a l l | one | two | t h r e e | has | taken |
where | made | a l s o | t h u s | though | have | when | not | such | f i g u r e | t a b l e | t h e s e | c o u l d
| s e e n | g i v e n | nbsp | l e s | d e s | from | d i f f e r e n t | e s t | dans | une | our | q u i | between |
next | would | s o n t | i t s | s e e | son | p l u s | c a se | que | pour | s u i v a n t | nous | par | s u r |
each | but | than | o n l y | o t h e r | main | f i g u r e s | t a b l e s | more | t h e r e | v a l u e | v a l u e s |
were | was | low | h i g h | around | s i n c e | v e r y | o r d e r | p e r | i n t o | f i r s t | b e c a u s e | found |
E. Branlard
137
CHAPTER 12. SHELL SCRIPTS
them | done | good | t h e i r | r e a l l y | h e r e | g o t | b i g | b e t t e r | w e l l | away | shown | o v e r |
l i k e | while | w i t h i n | t a k e | due | any | then | under | same | much | most | both | s e c o n d |
l o t | u s e | g e t | pas | mais | a l o r s | peut | p l o t | l e f t | r i g h t ' | s o r t | uniq −c | s o r t
−rn | head −50 | sed ' s / ' [ \ 0 − 9] ' // g ' | x a r g s | sed ' s / [ \ ] / , / g ' `
echo
" Keywords :
$ keywords "
. . / . . / keywordsSetUp . sh
o l d_v a l u e ='KEYWORDSSHOULDGOHERE' ;
new_v a l u e=" $ keywords " ;
sed − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
cd
../
#f i n a l c l e a n i n g
t e x c l e a n 2>/ dev / n u l l
12.21 formatWebVersion
#! / b i n / sh
#~
#~ cd D e b i a n u e l
#~ cp −r d e b i a n u e l d e b i a n u e l −bkp
#~
#~ cd d e b i a n u e l
#~
#~
#~ rename " s / html / php / g " * . html
#~ s e d − i " s / [ . ] html / . php / g " * . php
#~ s e d − i " s :< /HEAD> : : g " * . php
#~
#~
#~ o l d_v a l u e="<BODY >";
#~ new_v a l u e ="<? i n c l u d e ( ' . . /_i n c l u d e s / haut . php ' ) ;? >";
#~ s e d − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
#~
#~ o l d_v a l u e="<ADDRESS>";
#~ new_v a l u e ="<? i n c l u d e ( ' . . /_i n c l u d e s / b a s . php ' ) ; ?>";
#~
#~ s e d − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
#~
#~
#~ o l d_v a l u e="</ADDRESS>";
#~ new_v a l u e ="";
#~ s e d − i " s : $ o l d_v a l u e : $ new_v a l u e : g " * . php
#~
#~
#~
12.22 audioInfo
E. Branlard
138
CHAPTER 12. SHELL SCRIPTS
#! / b i n / bash
#############################################################
# a u d i o I n f o : p r i n t s a u d i o i n f o , metadata , b i t r a t e
#############################################################
# Description :
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies :
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
# Note :
#############################################################
Duration =` ffmpeg − i " $@" 2>&1 | g r e p Duration | awk −F" : | , " ' { p r i n t $ 3 " : "
i n t ($4) } ' `
MetaData=` ffmpeg − i " $@" 2>&1 | g r e p −E " a r t i s t | t i t l e | album | g e n r e |TYER"
| awk −F : ' { p r i n t "
"$ 2 } ' `
Stream =` ffmpeg − i " $@" 2>&1 | g r e p Stream |
$ 4 " \n
"$ 5 } ' `
awk
−F , ' { p r i n t
B i t r a t e =` ffmpeg − i " $@" 2>&1 | awk ' / b i t r a t e : / { p r i n t
$6 "
$ 1 " \n
"$2
$3
"$ 7 } ' `
#x a r g s −0
echo $ Duration
echo $ Stream
echo $ MetaData
Out="MetaData :
$ MetaData
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Length : $ Duration
Bitrate : $Bitrate
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Audio :
$ Stream "
n o t i f y −send − t 3000 − i gnome−volume− c o n t r o l " $ Out"
12.23 unix2win
#! / b i n / bash
#############################################################
# unix2win :
#############################################################
# D e s c r i p t i o n : mv i n p u t f i l e s from u n i x format t o windows c o m p a t i b l e
format
# Written by : Emmanuel Branlard
# Date : May 2011
# Dependencies :
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
# Example :
#
f i n d . /* − t y p e f − e x e c d i r unix2win {} \ ;
#############################################################
#############################################################
for f i l e ;
do
n e w f i l e =` echo
E. Branlard
$
file |
sed
−e ' s / [ ^ a−Z_0 − 9\.
/ − ] // g
' ;`
139
CHAPTER 12. SHELL SCRIPTS
if
[ [ "$ f i l e "
!=
"$ n e w f i l e " ] ]
then
echo $
file ;
echo $ n e w f i l e
mv
;
"$ f i l e " "$ n e w f i l e " ;
fi
done
12.24 svg2png
#! / b i n / bash
#################################################
# WHAT i s s v g 2 p n g ?
# S c r i p t t o c o n v e r t s v g f i l e s t o png
# s v g 2 p n g does not modify t h e f i l e which you s e l e c t , i t c r e a t e s a new f i l e
.
# I t cannot c o n v e r t a d i r e c t o r y b u t you can s e l e c t s e v e r a l f i l e s .
#################################################
#
INFO
# Author : yeKcim − yeknan@yahoo . f r − h t t p : // yeknan . f r e e . f r
# L i c e n c e : GNU GPL
# Dependency
#
zenity
#
inkscape
# Based on
# WOM_a u d i o c o n v e r t e r
# History
#
1 5 . 0 1 . 2 0 0 6 : v0 . 1 : F i r s t p u b l i c v e r s i o n
# Install
#
Put on ~/ . gnome2 / n a u t i l u s − s c r i p t s /
#
In a c o n s o l e : chmod u+x ~/ . gnome2 / n a u t i l u s − s c r i p t s / s v g 2 p n g
v e r s i o n=" 0 . 1 "
#################################################
# TRADUCTIONS
###### D e f a u l t = E n g l i s h #####
t i t l e =" svg2png " $ v e r s i o n " "
p l e a s e s e l=" P l e a s e s e l e c t a t l e a s t one f i l e . "
n o s e l e c=" " $ t i t l e " c o n v e r t s svg t o png . " $ p l e a s e s e l " "
nobin=" Program i n k s c a p e i s not i n s t a l l e d , p l e a s e i n s t a l l ! "
warning="Warning"
c h o i x=" Export type ? "
drawing=" Drawing "
canvas=" Canvas "
e x p o r t o f=" P i c t u r e t o c o n v e r t : "
c a se $LANG i n
######## Français ########
fr* )
t i t l e =" svg2png " $ v e r s i o n " "
p l e a s e s e l=" Merci de s à ƒ  © l e c t i o n n e r au moins un f i c h i e r . "
n o s e l e c=" " $ t i t l e " permet de c o n v e r t i r d e s svg en png . " $ p l e a s e s e l " "
warning=" A t t e n t i o n "
nobin="Le programme i n k s c a p e n ' e s t pas i n s t a l l à ƒ  © , v e u i l l e z l '
installer !"
c h o i x="Type d ' e x p o r t ? "
drawing=" D e s s i n "
E. Branlard
140
CHAPTER 12. SHELL SCRIPTS
canvas=" Page "
e x p o r t o f=" Image Ã
esac
convertir : " ; ;
#################################################
# PROGRAMME
######## Test dépendance ########
which i n k s c a p e 2>/ dev / n u l l
i f [ $ ? != 0 ]
then
z e n i t y −− e r r o r −− t i t l e =" $ t i t l e " −− t e x t=" $ nobin "
0
exit
fi
#### Pas de f i c h i e r s sélectionné ###
i f [ $# − eq 0 ] ; t h e n
z e n i t y −− e r r o r −− t i t l e =" $ warning " −− t e x t=" $ n o s e l e c "
exit 1
fi
######## Page / image ? ########
while [ ! " $ c h o i x u t i l i s a t e u r " ] # Réafficher l a fenêtre t a n t que l '
u t i l i s a t e u r n ' a pas f a i t de c h o i x
do
c h o i x u t i l i s a t e u r =` z e n i t y −− t i t l e " $ t i t l e " −− l i s t −−column=" $ e x p o r t o f "
canvas $ drawing −− t e x t " $ c h o i x " `
###### Choix −> S o r t i e b o u c l e ######
if
[ $ ? != 0 ] ; then
exit 1
fi
[
$?
−ne 0 ]
&& e x i t
$
2 # Annulation
done
[
if
$choixutilisateur
==
$ drawing
type="−− export −area −drawing "
;
];
then
fi
######## Résolution ? ########
while [ ! " $ r e s o l u t i o n " ] # Réafficher l a fenêtre t a n t que l '
u t i l i s a t e u r n ' a pas f a i t de c h o i x
do
r e s o l u t i o n =` z e n i t y −− e n t r y −− t i t l e " $ t i t l e " −− t e x t " Résolution : " −−
entry − t e x t " 90 " `
###### Choix −> S o r t i e b o u c l e ######
if
[ $ ? != 0 ] ; then
exit 1
fi
[
$?
−ne 0 ]
&& e x i t
2 # Annulation
done
######## Export png ########
while [ $# − g t 0 ] ; do
p i c t u r e=$ 1
png_ f i l e =` echo " $ p i c t u r e " | sed ' s / \ . \w*$/ . png / ' `
i n k s c a p e $type −−export−d p i=" $ r e s o l u t i o n " −−export−png=" $ png_ f i l e " " $
picture "
shift
done
E. Branlard
141
CHAPTER 12. SHELL SCRIPTS
12.25 toCover
#! / b i n / sh
# toCover , f o r renaming album t h u m b n a i l i n music l i b r a r y
# t a k e s a p i c t u r e i n argument , and copy i t t o c o v e r . j p g . . .
a=$ 1
echo " $ a "
path =` dirname " $ a " `
echo " $ path "
cp " $ a " " $ path / c o v e r . j p g "
echo " "
12.26 texclean
#!
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
rm
/ b i n / bash
* . aux
* . toc
* . log
* . bbl
* . out
* . cb
* . blg
*. lot
*. lof
* . tps
* . maf
*. ilg
* . glo
* . mtc *
* . ptc*
* . bmt
* . idx
* . ind
* . snm
* . nav
* . cb2
12.27 DEFAULT
#! / b i n / bash
#############################################################
# Default script :
#############################################################
# Description :
# Written by : Emmanuel Branlard
# Date : Oct 2009
# Dependencies :
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
# Note : To s e p a r a t e ' f i l e . pdf ' i n t o s i n g l e page f i l e s :
#
pdftk f i l e . pdf burst
#############################################################
echo " S c r i p t name i s
[$0] "
echo " This P r o c e s s ID i s
[ $$ ] "
echo " This Parameter Count i s [ $ #]"
E. Branlard
142
CHAPTER 12. SHELL SCRIPTS
" A l l Parameters
[ $@] "
"The FLAGS a r e
[ $ − ]"
#############################################################
#sh s y n t a x
# i f [ $# − eq 0 ] ; t h e n echo "No arguments " ; f i
# E x p r e s s i o n comparison : ! EX1 −a Ex2 , Ex1 −o Ex2
# S t r i n g comp : S1 = S2 , S1 !=S2
# I n t comp :
I1 −ne I2
#bash s y n t a x
#i f [ $# == 0 ] ; t h e n echo "No arguments " ; f i
# for f in *
# do
# echo " $ f "
# done
echo
echo
12.28 shrinkFig
#! / b i n / sh
#############################################################
# S h r i n k Fig
#############################################################
# D e s c r i p t i o n : S h r i n k F i g u r e t o 40%
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies : image magick
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
#############################################################
for i
do
m o g r i f y − r e s i z e 40%
$i
done
12.29 tomp3
#! / b i n / sh
#############################################################
# To MP3
#############################################################
# D e s c r i p t i o n : au2mp3 m4a2mp3 wma2mp3 mp32mp3 f l v 2 m p 3 anything2mp3
# Written by : Emmanuel Branlard
# Date : Feb 2011
# Dependencies : ffpmeg , lame , sox , f a a d , mplayer
# L i c e n s e : F e e l f r e e t o modify and a d a p t i t
#############################################################
for i
do
# Out F i l e
j =` echo " $ i " | t r '_ ' ' ' `
j=$ { j %. * } . mp3
if
[ −f
$j
]
then
echo
else
if
E. Branlard
" File exists
$j
−> s k i p p i n g "
[ [ " $ i " == * . au ] ]
143
CHAPTER 12. SHELL SCRIPTS
then
sox " $ i " " $ i " . wav
ffmpeg − i " $ i " . wav −vn − a c o d e c libmp3lame −y " $ j "
rm " $ i " . wav
e l i f [ [ " $ i " == * . m4a ] ]
then
f a a d −o − " $ i " | lame −h −b 192 − " $ j "
[ [ " $ i " * . wav ] ]
elif
then
lame " $ i " " $ j "
[ [ " $ i " == * .wma ] ]
elif
then
elif
#wma > mp3 Rip w i t h Mplayer / encode w i t h LAME
mplayer −vo n u l l −vc dummy − a f r e s a m p l e =44100 −ao
pcm : waveheader " $ i " ;
lame " audiodump . wav" " $ j " ;
rm " audiodump . wav"
[ [ " $ i " == * . mid * ] ]
then
#
echo To be done
[ [ " $ i " == * . mp3 ] ]
elif
then
#mp3 > mp3
lame " $ i " " audiodump . mp3"
mv " audiodump . mp3" " $ j "
rm " audiodump . mp3"
else
ffmpeg − i " $ i " −vn −ab 128 k −ac 2 − a r 44100 −y " $ j
">/ dev / n u l l
fi
fi
done
12.30 pdfBind
#!
if
/ b i n / bash
[
$#
− eq 0 ]
then
F i l e s=* . pdf
F i l e s=" $ F i l e s "
else
l=$@
B u f f=" "
First =''
for i in
$l
do
if
[
!
` echo
$i
| g r e p −E " [ . ] [ a−zA−Z ] { 3 , 4 } $ " ` = " " ]
then
F i l e=" $ B u f f $ i "
B u f f=" "
F i r s t=" "
F i l e 2 =` echo $ F i l e | t r ' ' '_ ' `
#
i f [ $ F i l e != $ F i l e 2 ]
then
E. Branlard
144
CHAPTER 12. SHELL SCRIPTS
mv
"$ F i l e "
$File2
fi
#
F i l e s=" $ F i l e s
$File2 "
else
if
[ −z
${ F i r s t }
]
then
B u f f=" $ i "
F i r s t="no"
else
B u f f=" $ B u f f
$i
"
fi
fi
done
#
echo
$Files
F i l e O u t =` echo
$Files
fi
| g r e p −Eo " ^ [ a−Z0 −9\_ − ] * [ . ] " | t r '_ ' ' ' ` " Bind . pdf "
echo $ F i l e O u t
pdftk
$Files
cat
output " $ F i l e O u t "
12.31 DoBootchart
#! / b i n / sh
#i n i t i a l i z a t i o n
HOME=/home/manu
f o l d e r=/home/manu/ C o n f i g / s c r i p t s / B o o t c h a r t
mydate=$ ( d a t e +%Y−%m−%d−%H%M)
cd $HOME
bootchart
cp
b o o t c h a r t . png
$ f o l d e r / b o o t c h a r t $ mydate
. png
12.32 cnx-vjk.expect
#!
/usr/bin/ expect
set
−f
f o r c e_c o n s e r v a t i v e 1 ;
set timeout 2
spawn s s h −T − l LOGIN HOST
e x p e c t " password : $ "
send "MOTDEPASSE\n"
interact
12.33 pdfAlternRotation
E. Branlard
145
CHAPTER 12. SHELL SCRIPTS
#! / b i n / sh
#############################################################
# Altern Rotation :
#############################################################
# R o t a t e by 180 d e g r e e s e v e r y o t h e r page o f a p d f
# w r i t t e n by Emmanuel Branlard
# Oct 2009
# This s c r i p t u s e s p d f t k
# F e e l f r e e t o modify and a d a p t i t
# To s e p a r a t e ' f i l e . pdf ' i n t o s i n g l e page f i l e s :
#
pdftk f i l e . pdf burst
#############################################################
echo ' Every o t h e r pdf f i l e i n t h e c u r r e n t d i r e c t o r y w i l l be r o t a t e d '
echo ' Warning : do a backup o f t h e pdf f i l e s f i r s t '
echo '
P r e s s C t r l+C t o c a n c e l '
echo '
P r e s s Enter t o Continue ' ;
read r e p l y
j =0
# l o o p i n g on a l l p d f f i l e s i n t h e f o l d e r
f o r i i n * . pdf ; do
j =` expr $ j + 1 ` ;
p r i n t f ' F i l e %d : %s ' $ j $ i
i f [ ` expr $ j % 2 ` −eq 0 ] ; then
p r i n t f ' −> R o t a t i n g . . .
';
cp $ i $ i . bkp
p d f t k $ i . bkp c a t 1S output $ i
rm $ i . bkp
fi
echo
''
done
echo
echo
echo
read
'Do you want t o c o n c a t e n a t e t h e f i l e ? '
' P r e s s C t r l+C t o c a n c e l '
' P r e s s Enter t o Continue ' ;
reply
' Binding . . . '
p d f t k * . pdf c a t output
echo
echo
bind .
pdf
"Done . F i l e ' bind . pdf ' c r e a t e d "
12.34 syncStorage
#! / b i n / sh
# S o u l d be run as u s e r
#v a r i a b l e s
OPTS="−av "
DEST=/ media / S t o r a g e
##############
# DATAWIN
##############
SRC=/ media / DataWin
E. Branlard
146
CHAPTER 12. SHELL SCRIPTS
#w i t h o u t d e l e t i o n
r s y n c $OPTS $SRC/ Etudes /
r s y n c $OPTS $SRC/ Images /
$DEST/ Etudes /
$DEST/ Images /
#w i t h d e l e t e p r o p a g a t i o n
r s y n c $OPTS −− d e l e t e $SRC/ C o n f i g / $DEST/ C o n f i g /
r s y n c $OPTS −− d e l e t e $SRC/ Data / $DEST/ Data /
r s y n c $OPTS −− d e l e t e $SRC/ I n f o r m a t i q u e / $DEST/ I n f o r m a t i q u e /
r s y n c $OPTS −− d e l e t e $SRC/ Musique / $DEST/ Musique /
r s y n c $OPTS −− d e l e t e " $SRC/ Musique − Data / " " $DEST/ Musique − Data / "
r s y n c $OPTS −− d e l e t e " $SRC/ Musique C l a s s i q u e / " " $DEST/ Musique C l a s s i q u e / "
r s y n c $OPTS −− d e l e t e $SRC/ P r o j e t s / $DEST/ P r o j e t s /
r s y n c $OPTS −− d e l e t e $SRC/Work/ $DEST/Work/
##############
# Linux
##############
SRC=/home/manu
#w i t h o u t d e l e t i o n
r s y n c $OPTS $SRC/ S i t e s /
$DEST/ S i t e s /
#w i t h d e l e t e p r o p a g a t i o n
r s y n c $OPTS −− d e l e t e $SRC/ C o n f i g / " $DEST/ C o n f i g − Linux / "
12.35 pdfFind
#!
/ b i n / bash
echo
" Looking f o r " $ 1
SAVEIFS=$ IFS
IFS=$ ( echo −en " \n\b" )
for
i i n ` f i n d −name " * . pdf " − p r i n t f '%h /%f \n '
2>
/ dev / n u l l
`
do
"−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
"$ i " ;
echo "−−−−−−−−−−−−−−−−−−−−−−−−−−−−"
p d f t o t e x t $ i − | g r e p −− c o l o r=always
# s t r i n g s "$ i " | g r e p $1
done ;
IFS=$SAVEIFS
echo
echo
E. Branlard
$1
147
Chapter
13
Debian
13.1 Install Debian from scratch
########################################################################
### Au cas , c o n f i g u r a t i o n du r e s e a u a l a main − I n t e r f a c e E t h e r n e t
########################################################################
# s i l e r e s e a u e t h 0 n ' a p p a r a i t pas en f a i s a n t i f c o n f i g , a l o r s
vim / e t c / network / i n t e r f a c e s
#a j o u t e r
#a l l o w − h o t p l u g e t h 0
#i f a c e e t h 0 i n e t dhcp
#
#l a commande i f u p e t h 0 r e v e i l l e l ' i n t e r f a c e ( i n t e r f a c e up )
########################################################################
### Au cas , c o n f i g u r a t i o n du r e s e a u a l a main − I n t e r f a c e WIRELESS
########################################################################
# pour a v o i r l e w i f i , avec c l e f w i f i r a l i n k usb : w i r e l e s s − t o o l s e t
firmware − r a l i n k
# modprobe r t 7 3 u s b ( s i pas a u t o m a t i q u e )
### Tout d ' abord , methode pas a pas , e n s u i t e on c o n f i g u r e
interfaces
; ifconfig
#( v i r e r e t h 0 avec i f c o n f i g e t h 0 down )
# i w c o n f i g ( wlan0 d e v r a i t y e t r e )
# m e t t r e en r o u t e l a c l e f
; i f c o n f i g wlan0 up
# f a i r e un l i s t i n g
; i w l i s t wlan0 s c a n
# Configurer l e essid
; i w c o n f i g wlan0 e s s i d WANADOO−F658
# Mettre en mode managed s i pas d e j a
; i w c o n f i g wlan0 mode managed
# Configure c l e f
; i w c o n f i g wlan0 key XXXXXXXXXXXXXXXXXXX
# ou , d i f f e r e n c e ??
; i w c o n f i g wlan0 key r e s t r i c t e d XXXXXXXXXXXXXXXXXXX
# e n f i n on a c t i v e l ' i n t e r f a c e
; i f u p wlan0
### C o n f i g u r e r par l e f i c h i e r
148
/ e t c / network /
CHAPTER 13. DEBIAN
#R e s t r e i n d r e l e s p e r m i s s i o n s d ' a c c é s à / e t c / network / i n t e r f a c e s , pour
é v i t e r de d i v u l g u e r l a c l e f mot de p a s s e
# chmod 0600 / e t c / network / i n t e r f a c e s
#
# WEP
#auto wlan0
#i f a c e wlan0 i n e t dhcp
#
w i r e l e s s − e s s i d Mon_EssiD
#
w i r e l e s s −key 1234567890ABCDEF
#
# WPA
# i n s t a l l e r w p a s u p p l i c a n t pour g e r e r l e s o p t i o n s wpa−*
#Ouvrir / e t c / network / i n t e r f a c e s dans un é d i t e u r :
# vim / e t c / network / i n t e r f a c e s
# E n t r e r l e s données de v o t r e r é s e a u sans f i l ; SSID e t C l e f WPA . Par
exemple :
#auto wlan0
#i f a c e wlan_maison i n e t dhcp
#
wpa− s s i d NomRéseau
#
wpa−p s k Mot−Passe −C l e f −WPA
#La commande auto montera l ' i n t e r f a c e sans f i l automatiquement au
démarrage du s y s t è m e . La commenter ou l a supprimer s i ce f o n c t i o n n e m e n t
n ' e s t pas d é s i r e r .
# S a u v e g a r d e r e t s o r t i r de l ' é d i t e u r .
# Monter v o t r e i n t e r f a c e . Cela démarrera wpa_s u p p l i q u a n t en a r r i è r e p l a n
# i f u p wlan0=wlan_maison
########################################################################
### M o d i f i e r l e s s o u r c e s e t a j o u t e r c o n t r i b e t non f r e e
########################################################################
# vim / e t c / a p t / s o u r c e s . l i s t
## s q u e e z e s e c u r i t y
#deb h t t p : // f t p . f r . d e b i a n . org / d e b i a n / l e n n y main c o n t r i b non− f r e e
#deb − s r c h t t p : // f t p . f r . d e b i a n . org / d e b i a n / l e n n y main c o n t r i b non− f r e e
#deb h t t p : // s e c u r i t y . d e b i a n . org / l e n n y / u p d a t e s main c o n t r i b non− f r e e
#deb − s r c h t t p : // s e c u r i t y . d e b i a n . org / l e n n y / u p d a t e s main c o n t r i b non− f r e e
#deb h t t p : //www. debian −m u l t i m e d i a . org / l e n n y main c o n t r i b non− f r e e
#deb h t t p : //www. b a c k p o r t s . org / d e b i a n lenny − b a c k p o r t s main c o n t r i b
#gpg −− k e y s e r v e r p g p k e y s . mit . edu −−recv −key 778978 B00F7992B0
#gpg −− e x p o r t −−armor 778978 B00F7992B0 | sudo apt −key add −
########################################################################
### I n s t a l l e r Lynx pour n a v i g u e r s u r i n t e r n e t au c a s ou
########################################################################
aptitude i n s t a l l lynx
# Une f o i s l ' i n s t a l l a t i o n d e b i a n terminee , i n s t a l l e r un s e r v e u r x : ( nv
pour n v i d i a , a t i s i n o n )
# Pour une i n s t a l l minimale , b i e n comprendre l e s dependances du s e r v e u r X
E. Branlard
149
CHAPTER 13. DEBIAN
# => l i r e l e s i n f o s d ' a p t i t u d e , ca prend du temp de p r e n d r e en main l '
i n t e r f a c e d ' a p t i t u d e , mais on s ' y f a i t
# s i on ne comprend pas t r o p a p t i t u d e , t a p e r #a p t i t u d e show nom−du−paquet ,
e t l i r e l e s dependances
# Ce l i e n e s t peut − e t r e u t i l e : h t t p : // forum . ubuntu − f r . org / v i e w t o p i c . php ?
i d =86307&p=17
########################################################################
### Methode b o u r r i n , pour a v o i r une d e b i a n + f l u x b o x f o n c t i o n e l l e
########################################################################
#S i on v e u t e t r e t r a n q u i l e on i n s t a l l e Xorg ou x−window−system −c o r e ( j e ne
sais plus trop la difference )
#Xorg depend de x− s e r v e r −xorg , xauth , x i n i t , x11 −apps , x f o n t s −base , xterm
#a p t i t u d e i n s t a l l x o r g xterm
#dpkg − r e c o n f i g u r e x s e r v e r −x o r g
##on t e n t e de l a n c e r l e s e r v e u r x , on a j u s t e un t e r m i n a l dans un c o i n
#s t a r t x
##on i n s t a l l e un g e s t i o n n a i r e de f e n e t r e
#apt − g e t i n s t a l l f l u x b o x
#s t a r t x
########################################################################
### Methode pas a pas
########################################################################
#S i on v e u t f a i r e ca e t a p e par e t a p e pour une c o n f i g minimum , f a u t s '
accrocher , c ' e s t vraiment h i s t o i r e d ' e t r e minimaliste
# mais ca a i d e a comprendre l e s d i f f e r e n t e s c o u c h e s e t s u r t o u t ca apprend
a i n s t a l l e r j u s t e ce dont on a b e s o i n ( au l i e u d e s g r o s p a q u e t s )
# Les p a q u e t s − c o r e c o n t i e n n e n t l e minimum , l e s p a q u e t s − a l l , s o n t d e s
fourres tout
# par c o n t r e , j e ne me s o u v i e n s p l u s t r o p ce que j ' a i f a i t
# V o i l a ce que j e c r o i s a v o i r f a i t : ( a chaque e t a p e , e s s a y e r de l a n c e r l e
s e r v e r x ( s t a r t x , q u i e s t f o u r n i t par x i n i t ) e t r e g a r d e r ce qu ' i l d i t )
#s e r v e u r X de b a s e
a p t i t u d e i n s t a l l x− s e r v e r −xorg − c o r e
#e t ca , ca r e s t e un mystere , e s s a y e r sans au d e b u t
#a p t i t u d e i n s t a l l x−window−system −c o r e
#a p t i t u d e i n s t a l l x11 − s e s s i o n − u t i l s
#a p t i t u d e i n s t a l l x s e r v e r −xorg − i n t e l
#o u t i l s n e c e s s a i r e s au lancement du s e r v e r x , comme s t a r t x
a p t i t u d e i n s t a l l xauth x i n i t
# a p p l i c a t i o n s x ( obscure )
a p t i t u d e i n s t a l l x11−apps
#LES INPUTS : x s e r v e r −xorg −i n p u t − a l l : t o u s l e s i n p u t ( c l a v i e r , s o u r i s ,
t r u c s dans l e g e n r e s i j e me s o u v i e n s b i e n )
# s i on e s t t a t i l l o n on p e u t c u s t o m i s e r pour e v i t e r d ' i n s t a l l e r t o u s l e s
input :
sudo a p t i t u d e i n s t a l l x s e r v e r −xorg −input −mouse x s e r v e r −xorg −input −kbd
#LES OUTPUTS: nv : p i l o t e s g r a p h i q u e l i b r e s pour n v i d i a ( ca e v i t e d '
i n s t a l l e r x s e r v e r −xorg −v i d e o − a l l )
a p t i t u d e i n s t a l l x s e r v e r −xorg −vid eo −nv
E. Branlard
150
CHAPTER 13. DEBIAN
# c o n f i g u r e r l e s e r v e u r x e t p r e n d r e en compte l e s bons d r i v e r s
dpkg− r e c o n f i g u r e x s e r v e r −xorg
#p o l i c e s de b a s e n é c e s s a i r e s
#a p r i o r i , on p e u t s e p e r m e t t r e d ' i n s t a l l e r t o u t e s l e s a u t r e s p o l i c e s
s c a l a b l e , 100 d p i 75 d p i e t c . . . : x f o n t s −100 dpi , x f o n t s − s c a l a b l e
a p t i t u d e i n s t a l l x f o n t s −b a s e
# xterm ( t e r m i n a l de base , pas b e s o i n d e s a u t r e s e m u l a t e u r s de terminaux ,
i l est tres bien )
a p t i t u d e i n s t a l l xterm
#a ce s t a d e s t a r t x d e v r a i t marcher , meme sans g e s t i o n n a i r e de f e n e t r e ! ! !
( on a j u s t e un t e r m i n a l dans un c o i n )
#ca s e r t a r i e n d ' a l l e r p l u s l o i n t a n t que ca marche pas !
#e n s u i t e on p e u t s ' i n t e r r e s s e r au g e s t i o n n a i r e de f e n e t r e ( windows manager
(wm) ) comme : f l u x b o x , xfwm ( c e l u i d ' x f c e 4 ) , p l u s l o u r d : gnome
# i n s t a l l de f l u x b o x ( ca v a u t l e coup d ' e s s a y e r , e t ca c o u t e pas grand
chose )
aptitude i n s t a l l fluxbox
#Lancer l e s e r v e u r x :
startx
#Pour gnome , a t t e n t i o n c ' e s t l o u r d , pour decomposer gnome v o i r p l u s l o i n (
j e n ' ai jamais f a i t ) )
a p t i t u d e i n s t a l l gnome− c o r e
#Pour gnome , g e s t i o n n a i r e de l o g i n , pas o b l i g a t o i r e
a p t i t u d e i n s t a l l gdm
#Pour de l a b u r e a u t i q u e ( t r e s i m p o r t a n t pour t o u t ce q u i e s t montage ,
p o l i c y k i t e t compagnie )
a p t i t u d e i n s t a l l h a l dbus udev
#S y n a p t i c pour a i d e r a i n s t a l l e r :
aptitude i n s t a l l synaptic
########################################################################
### n i v i d i a p r o p r i e t a i r e , deux methodes k i f f k i f f
########################################################################
a p t i t u d e i n s t a l l l i n u x −h e a d e r s − `uname −r `
a p t i t u d e i n s t a l l n v i d i a −g l x
a p t i t u d e i n s t a l l n v i d i a −s e t t i n g s
# c o n f i g u r a t i o n m a n u e l l e du s e r v e u r x
nano / e t c /X11/ xorg . c o n f
#Pour i n s t a l l e r v r a i m e n t f a c i l e m e n t e t d u r a b l e m e n t l e s d r i v e r s n v i d i a s u r
d e b i a n ( a v o i r non− f r e e aux s o u r c e s ) :
# l ' i n s t a l l a t i o n s e f a i t a l ' a i d e du module − a s s i s t a n t (m−a )
a p t i t u d e i n s t a l l module− a s s i s t a n t
m−a p r e p a r e
m−a a− i n v i d i a
a p t i t u d e i n s t a l l n v i d i a −g l x
E. Branlard
151
CHAPTER 13. DEBIAN
#c o n f i g a u t o m a t i q u e du s e r v e u r x e t c h o i s i r " n v i d i a " comme d r i v e r
dpkg− r e c o n f i g u r e x s e r v e r −xorg
########################################################################
### l a s u i t e c ' e s t un peu en vrac , ce n ' e s t pas de moi
########################################################################
Paquets n e c e s s a i r e s ( en p l u s du x−window−system −c o r e , b i e n s u r ) pour un
gnome minimal :
− gnome− a p p l e t s : s i n o n pas de t a b l e a u de bord
− n a u t i l u s : s i n o n pas d ' i c o n e s u r l e bureau ( e t pas de n a v i g a t i o n i n t e r n e )
− gnome− s e s s i o n : ca semble l o g i q u e
− x s c r e e n s a v e r : pour ne pas s e f a i r e i n s u l t e r au demarrage de gnome
− m e t a c i t y ( ou s a w f i s h ou a u t r e ) : s i n o n pas de g e s t i o n n a i r e de f e n e t r e
En p l u s , j e c o n s e i l l e au moins l e paquet xterm , c ' e s t quand meme b i e n
p r a t i q u e une c o n s o l e s o u s gnome .
Peut− e t r e a u s s i gnome−audio , mais j e ne s u i s pas s u r .
##################################################
# xfce leger
##################################################
xfwm + thunar + mousepad
##################################################
# gnome
##################################################
J ' a i r e f a i t une s y n t h è s e d e s p a q u e t s u t i l e s p r o p r e s à gnome
#Pour e v i t e r gnome−c o r e
Paquets n e c e s s a i r e s ( en p l u s du x−window−system −c o r e , b i e n s u r ) pour un
gnome minimal :
− gnome− a p p l e t s : s i n o n pas de t a b l e a u de bord
− n a u t i l u s : s i n o n pas d ' i c o n e s u r l e bureau ( e t pas de n a v i g a t i o n i n t e r n e )
− gnome− s e s s i o n : ca semble l o g i q u e
− x s c r e e n s a v e r : pour ne pas s e f a i r e i n s u l t e r au demarrage de gnome
− m e t a c i t y ( ou s a w f i s h ou a u t r e ) : s i n o n pas de g e s t i o n n a i r e de f e n e t r e
En p l u s , j e c o n s e i l l e au moins l e paquet xterm , c ' e s t quand meme b i e n
p r a t i q u e une c o n s o l e s o u s gnome .
Peut− e t r e a u s s i gnome−audio , mais j e ne s u i s pas s u r .
Les o u t i l s d ' a d m i n i s t r a t i o n g r a p h i q u e s i n d i s p e n s a b l e s :
− s y n a p t i c : i n t e r f a c e g r a p h i q u e à a p t i t u d e , permet l a g e s t i o n d e s p a q u e t s
− gnome−system − t o o l s : g e s t i o n d e s u t i l i s a t e u r s , c o n f i g u r a t i o n de l '
horloge , c o n f i g u r a t i o n réseau , etc .
− gnome−system −monitor : g e s t i o n d e s p r o c e s s u s t o u r n a n t s u r l e système ,
permet de v o i r l a c h a r g e CPU, l a c h a r g e mémoire , e t c .
− gnome−volume−manager : montage automatique d e s médias ( cd−rom ,
d i s q u e t t e s . . . ) e t é v e n t u e l l e m e n t lancement automatique de ceux − c i
− gnome−cups −manager : a j o u t / s u p p r e s s i o n d ' imprimantes
E. Branlard
152
CHAPTER 13. DEBIAN
− gnome− c o n t r o l − c e n t e r : c o n f i g u r a t i o n de l ' a c c e s s i b i l i t é , d e s p o l i c e s du
bureau , d e s p r o p r i é t é s s o u r i s / c l a v i e r , du volume s o n o r e , de l a
r é s o l u t i o n grap hiqu e , d e s thèmes de bureau , e t c .
Les o u t i l s g r a p h i q u e s u t i l e s :
− gnome− n e t t o o l : i n t e r f a c e g r a p h i q u e aux o u t i l s r é s e a u x : i f c o n f i g , ping ,
n e t s t a t u s , t r a c e r o u t e , p o r t s c a n n i n g , DNS lookup , f i n g e r , whois
− a l a c a r t e : g e s t i o n d e s menus gnome ( a j o u t / s u p p r e s s i o n d ' e n t r é e s )
− gnome− u t i l s : f o r m a t e r l e s d i s q u e t t e s , f a i r e d e s s c r e e n s h o t s , . . .
− gnome−media : l e c t e u r de CD, e n r e g i s t r e u r de son , r é g l a g e du volume
− gcon f − e d i t o r : permet de m o d i f i e r l a c o n f i g u r a t i o n de c e r t a i n s
programmes
− gnome−power−manager : g e s t i o n de l ' a r r ê t de l ' é c r a n /HDD, mise en v e i l l e
− gnome−k e y r i n g −manager : g e s t i o n du t r o u s s e a u
Remarque : l e paquet gnome−desktop −environment e s t une t r è s bonne b a s e
pour l e s p a q u e t s u t i l e s de gnome . I l r e p r e n d l a m a j o r i t é d e s p a q u e t s c i
− d e s s u s ( i l ne l u i manque que a l a c a r t e e t gnome−cups −manager ) , avec en
p l u s l a g e s t i o n a r c h i v e s ( z i p / t a r ) pour n a u t i l u s ( f i l e − r o l l e r ) , un
v i s u a l i s e u r de pdf ( e v i n c e ) , l a c a l c u l a t r i c e . . . I l c o n t i e n t é g a l e m e n t
d e s programmes q u i p o u r r a i e n t ê t r e i n u t i l e s comme E v o l u t i o n , d e s j e u x
. . . A vous de f a i r e l e t r i .
Les o u t i l s / programmes p l u s ou moins c é l è b r e s e t l e s p e t i t s « p l u s » :
− gnome−themes : d i v e r s thèmes pour gnome
− x s c r e e n s a v e r e t x s c r e e n s a v e r − g l : é c o n o m i s e u r s d ' é c r a n s ( mieux que gnome
−s c r e e n s a v e r )
− gtkorphan : permet de s u p p r i m e r l e s p a q u e t s o r p h e l i n s s o u v e n t ( e t pas
toujours ! ) i n u t i l e s
− gnome−mount : a j o u t e à N a u t i l u s d e s r a c c o u r c i s pour ( dé ) monter e t
é j e c t e r l e s médias
− gimp : l e c é l è b r e o u t i l s de c r é a t i o n g r a p h i q u e
− o p e n o f f i c e . org : l a s u i t e l i b r e é q u i v a l e n t e à Microsoft O f f i c e
− b r a s e r o : l o g i c i e l de g r a v u r e
13.2 Program list
#############################
### i n s t a l l r a p i d e , copy p a s t e dans l e t e r m i n a l
#############################
#en v r a c
aptitude i n s t a l l \
xpdf mirage x s c r e e n s a v e r gimp g p i c v i e w x f i g f −s p o t \
nano vim geany \
u n z i p z i p b z i p 2 t a r eterm b r a s e r o g c a l c t o o l Gmount− i s o \
a l s a − u t i l s n t f s −3g numlockx network −manager−gnome sysv −rc −c o n f p r e l o a d
p r e l i n k gnome−system −monitor \
o p e n o f f i c e . o r g wine \
g x i n e v l c amarok a u d a c i t y t i m i d i t y \
octave k i l e e c l i p s e t e x l i v e \
i c e w e a s e l amule amsn t r a n s m i s s i o n f i l e z i l l a
pidgin jabber \
jumpnbump \
#############################
E. Branlard
153
CHAPTER 13. DEBIAN
### i n s t a l l un peu p l u s d e t a i l l e e , avec moins d ' a p p l i c a t i o n s
#############################
#i n s t a l l a t i o n du g e s t i o n a i r e de f i c h i e r ( thunar , pour x f c e ) e t d ' e d i t e u r s
t e x t e ( nano , vim en t e r m i n a l , geany , b i e n sympa j e l e p r e f e r e a g e d i t )
a p t i t u d e i n s t a l l thunar nano vim geany
# Navigateur
aptitude i n s t a l l iceweasel
#i n s t a l l a t i o n de n t f s −3g pour g e r e r l e s p a r t i t i o n s NTFS
a p t i t u d e i n s t a l l n t f s −3g
# i n s t a l l l e c t e u r pdf ( evince b e t t e r )
a p t i t u d e i n s t a l l xpdf
#i n s t a l l v i s i o n n e u s e d ' image mirage
a p t i t u d e i n s t a l l mirage
#i n s t a l l s c r e e n s a v e r
aptitude i n s t a l l xscreensaver
#L e c t e u r Multimedia g x i n e : Un peu " l o u r d " ( ~20Mo de ram ) v r a i l e c t e u r
#a p t i t u d e i n s t a l l g x i n e
#q u e l q u e s f o n c t i o n n a l i t e s p r a t i q u e s :
a p t i t u d e i n s t a l l numlockx u n z i p z i p b z i p 2 t a r
#Eterm : t e r m i n a l sympa / u s r / b i n / Eterm , v o i r p l u s l o i n pour c o n f i g
c a r a c t e r e s a c c e n t u e s , pour t u n n i n g du fond d ' ecran : ( v o i r f i c h i e r
dedie )
#a p t i t u d e i n s t a l l eterm
# Audio
a p t i t u d e i n s t a l l alsa −u t i l s
#Open o f f i c e
aptitude i n s t a l l o p e n o f f i c e . org
# gimp
a p t i t u d e i n s t a l l gimp
#gnome network manager
a p t i t u d e i n s t a l l network −manager−gnome
#o u t i l s i n t e r n e t
a p t i t u d e i n s t a l l t r a n s m i s s i o n amule
# autologin leger
#a p t i t u d e i n s t a l l m i n g e t t y
#g e e k e r avec l e s s e r v i c e s
a p t i t u d e i n s t a l l s y s t −rc −c o n f
aptitude i n s t a l l \
xpdf mirage x s c r e e n s a v e r gimp g p i c v i e w x f i g f −s p o t \
u n z i p z i p b z i p 2 t a r eterm b r a s e r o g c a l c t o o l \
a l s a − u t i l s n t f s −3g numlockx network −manager−gnome sysv −rc −c o n f p r e l o a d
p r e l i n k gnome−system −monitor \
E. Branlard
154
CHAPTER 13. DEBIAN
o p e n o f f i c e . o r g wine \
g x i n e v l c amarok a u d a c i t y t i m i d i t y \
octave k i l e e c l i p s e \
i c e w e a s e l amule amsn t r a n s m i s s i o n f i l e z i l l a
jumpnbump \
E. Branlard
pidgin jabber lilypond \
155
Chapter
14
Fluxbox
14.1 Install Debian with Fluxbox
#############################
###I n s t a l l a t i o n du s e r v e u r X, a r e v o i r
#############################
# b o u r r i n x−window−system −c o r e xterm
# dpkg − r e c o n f i g u r e x s e r v e r −x o r g
# apt − g e t i n s t a l l f l u x b o x
# startx
# v o i r d e t a i l s d e s p a q u e t s dans a p t i t u d e
#
x−window−system −c o r e x s e r v e r −xorg − i n t e l , x11 − s e s s i o n − u t i l s x f o n t s
−100 d p i x f o n t s − s c a l a b l e
# pour s u r i l f a u t minimum x i n i t ( s t a r t x ) , xauth , x s e r v e r −xorg −v i d e o −nv
d e s i n p u t s , l e s x11 −apps
a p t i t u d e i n s t a l l x−window−system − c o r e x i n i t xauth x s e r v e r −xorg −vid eo −nv
x s e r v e r −xorg −input −mouse x s e r v e r −xorg −input −kbd x11−apps
#i n s t a l l a t i o n de l ' e m u l a t i o n du t e r m i n a l
a p t i t u d e i n s t a l l xterm
#i n s t a l l a t i o n de n v i d i a proprement
m−a p r e p a r e
m−a a− i n v i d i a
a p t i t u d e i n s t a l l n v i d i a −g l x
# c o n f i g u r a t i o n de X, c h o i s i r n v i d i a comme d r i v e r ! ! !
dpkg− r e c o n f i g u r e x s e r v e r −xorg
#i n s t a l l a t i o n du windows manager
aptitude i n s t a l l fluxbox
#on p e u t l a n c e r x
startx
14.2 Notes on Fluxbox
\ s e c t i o n { Fluxbox e t power manager
dans l e . f l u x b o x de home , r a j o u t e r :
gnome−power−manager &
156
CHAPTER 14. FLUXBOX
14.3 Tuning Fluxbox Appearence
D' a p r e s l e w i k i de debian − f a c i l e . o r g
###################################################
##S t a r t u p : l e f i c h i e r . f l u x b o x / s t a r t u p
###################################################
I f you have network manager , j u s t s t i c k "nm− a p p l e t &" i n t h e s t a r t u p f i l e
( but make s u r e i t s b e f o r e t h e " e x e c / u s r / l o c a l / b i n / f l u x b o x . . . . " l i n e ) .
I t works f o r me .
I had t o add "gnome−k e y r i n g −daemon &" a l o n g with "nm− a p p l e t &" i n o r d e r t o
g e t w i f i with WEP t o work and not c o n s t a n t l y ask f o r t h e WEP key t o be
re − e n t e r e d .
x s c r e e n s a v e r −n o s p l a s h
idesk &
nm− a p p l e t&
wmlaptop&
numlockx&
&
Now I have t o g e t t h e f r o n t a u d i o k e y s on my l a p t o p t o s t a r t working . . .
I used a c o m b i n a t i o n o f xmodmap and k e y b i n d i n g s , i n c o n j u n c t i o n with
alsamixer .
my . xmodmaprc c o n t a i n s
! v o l up
keycode 176 = XF86AudioRaiseVolume
! v o l down
keycode 174 = XF86AudioLowerVolume
! v o l mute
keycode 160 = XF86AudioMute
( check t h e k e y c o d e s f o r your b u t t o n s u s i n g xev ) and
XF86AudioMute : ExecCommand amixer s e t Master
XF86AudioLowerVolume : ExecCommand amixer s e t
XF86AudioRaiseVolume : ExecCommand amixer s e t
i n . f l u x b o x / k e y s . Hope t h i s h e l p s ; check t h e
then
I have
toggle
Master 5%−
Master 5%+
xmodmap man page
for
more .
###################################################
##Mettre son fond d ' écran s o u s f l u x b o x
###################################################
#f b s e t b g n e c e s s i t e eterm
#s i n o n a l l e r v o i r l e f i c h i e r . f l u x b o x / s t a r t u p
f b s e t b g −f
/ chemin / de / v o t r e / fond
d ' ecran
#s a u v e g a r d e r l e s i n f o s E d i t e r ~/ . f l u x b o x / i n i t e t l u i a j o u t e r c e t t e l i g n e :
s e s s i o n . s c r e e n 0 . rootCommand : f b s e t b g − l
###################################################
## I c o n e s s u r l e bureaux
E. Branlard
157
CHAPTER 14. FLUXBOX
###################################################
#I n s t a l l a t i o n de i d e s k
apt −g e t i n s t a l l i d e s k
#Créer l e d o s s i e r . i d e s k t o p , pour c o n t e n i r l e s . l n k .
mkdir ~/ . i d e s k t o p
table Icon
Caption : xchat
I c o n : /home/ syb / . i d e s k t o p / i c o n e s / xchat . xpm
X: 32
Y: 66
Command : xchat
end
#Lancer i d e s k à chaque démarrage de f l u x b o x e d i t e r
decommenter ou a j o u t e r l a l i g n e i d e s k
idesk
~/ .
fluxbox/startup et
###################################################
## Tunning de t h u n a r
###################################################
T e l e c h a r g e r un theme :
h t t p : //www. gnome−l o o k . o r g / c o n t e n t / show . php / Vista − I n s p i r a t e ? c o n t e n t =28352
b z i p 2 + t a r −x v f
C o p i e r " Vista − I n s p i r a t e_1 . 0 " dans =====>/ u s r / s h a r e / i c o n s
Dans c e r e p e r t o i r e i l y a un f i c h i e r " i n d e x . theme " dans l e q u e l c e t r o u v e
l e nom du théme "Name=Vista − I n s p i r a t e_1 . 0 "
J ' ouvre avec un é d i t e u r l e f i c h i e r . g t k r c − 2.0 s i t u e r dans /home/ u s e r /
Je r a j o u t e > gtk −i c o n −theme−name = " Vista − I n s p i r a t e_1 . 0 "
Ce q u i me permet de g a r d e r l e théme q u i g é r e l e s boutons , l e s o n g l e t s ,
l e s b a r r e de d é f i l e m e n t ,
mais de c h a n g e r l e s i c o n n e s d e s f i c h i e r s e t r é p e r t o i r e s dans thunar .
I l e s t p o s s i b l e que c e message :
bad image i n d e x
( thunar : c h i f f r e q u e l c o n q u e ( ou PID ) ) : Gtk−WARNING ** : I c o n c a c h e ' / u s r /
s h a r e / i c o n s / h i c o l o r / i c o n −theme . cache ' i s i n v a l i d
Et / ou q u e l q u e c h o s e dans l e g e n r e de :
( thunar : c h i f f r e q u e l c o n q u e ( ou PID ) ) : Gtk−WARNING ** : E r r o r l o a d i n g theme
i c o n f o r s t o c k ; I c o n ' gnome− f s −home ' not p r e s e n t i n theme
Apparait
On peu l e c o r r i g é par un :
sudo gtk −update −i c o n −c a c h e − f / u s r / s h a r e / i c o n s / h i c o l o r /
E. Branlard
158
Chapter
15
Languages and programs
15.1 Unix
l i n u x commands
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
du −sh FOLDER/FILE : d i s k u t i l i s a t i o n , r e a d a b l e by human , s : i n c l u d e
subfolders
d f −a l : d i s k s p a c e
* s o r t S o r t s l i n e s i n a s c e n d i n g , d e s c e n d i n g and unique o r d e r
* grep Searches for r e g u l a r e x p r e s s i o n s in s t r i n g s or f i l e s
* basename S t r i p s t h e path from a path s t r i n g t o l e a v e j u s t t h e
filename
* dirname Removes t h e f i l e from a path s t r i n g t o l e a v e j u s t t h e
*
*
*
*
*
*
*
*
*
*
*
pathname
c u t Chops up a t e x t s t r i n g by c h a r a c t e r s o r f i e l d s
wc Count t h e c h a r a c t e r s , words , o r l i n e s
[ ( test ) ] Predicate or c o n d i t i o n a l p r o c e s s o r
t r ' a ' ' b ' Transform c h a r a c t e r s
expr Simple a r i t h m e t i c p r o c e s s o r
bc B a s i c C a l c u l a t o r
eval E v a l u a t e v a r i a b l e s
echo Output s t r i n g s
date Create date s t r i n g s
nawk Manipulate t e x t s t r i n g s
head | t a i l A c c e s s l i n e s i n f i l e s
FORLOOPS/ FIND / XARGS and SPACECHARACTERS
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
SHELL SCRIPTS NOTES
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Conditionnals t e s t s are in bracket [ ]
See man t e s t f o r d e t a i l s , l i k e :
E x p r e s s i o n comparison : ! EX1 −a Ex2 , Ex1 −o Ex2
S t r i n g comp : S1 = S2 , S1 !=S2
I n t comp :
I 1 −ne I 2
IF
:
159
CHAPTER 15. LANGUAGES AND PROGRAMS
if
[]
||
WARNING
[]
!!
&&
[]
then
...
elif
[]
then
you need s p a c e s around [ and =
...
else
...
fi
!!!!!!!!!!
STANDARD IN , STANDARD OUT
| : PIPE
. / c o m p i l e_a s t r a 2>&1 | t e e l o g . loG
deadbbg
h t t p : //www. o n l i n e c o m p u t e r b o o k s . com/
15.2 Awk
awk
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
awk i s a p a t t e r n s c a n n i n g and p r o c e s s i n g l a n g u a g e .
By d e f a u l t i t r e a d s s t a n d a r d i n p u t and w r i t e s s t a n d a r d output .
Usage : awk − f p r o g f i l e [ −− ] f i l e
Usage : awk ' program ' f i l e
Usage : . / a w k f s c r i p t
−F ,
: f i e l d s e p a r a t o r comma ( , )
−F " ; "
: f i e l d s e p a r a t o r semicolumn ( ; )
−F " ; | , " : f i e l d s e p a r a t o r semicolumn o r comma ( ; )
#f i r s t 1000 l i n e s
awk 'NR<1000 { p r i n t } ' r a d i a l . i n i >r a d i
#l i g n e s p a i r e s
NR % 2 == 1 { p r i n t
$0
}
#a f f i c h e l e numero de l i g n e
{ p r i n t NR, $ 0 }
# First three f i e l d s
awk −F , 'NR>1 { p r i n t
$1 ,$2 ,$3;}
# Not matching a p a t t e r n
awk ' ! / D i s t r i b u t i o n / { p r i n t
$0
' tab . c s v > tab2
} ' d r i f t . in
# Cut a l i n e e v e r y 20 f i e l d s
awk −F , ' { f o r ( i =1; i<=NF; i=i +1){ i f ( ( i %20)==0
){
p r i n t f $ i " ; " } } p r i n t f " \n"
} ' p . c s v >r . c s v
printf
$i
" ; \ n"
} else {
# p r i n t sum o f f i r s t r e c o r d
awk ' { sum += $ 1 } ; END { p r i n t sum } ' f i l e
E. Branlard
160
CHAPTER 15. LANGUAGES AND PROGRAMS
−F= 'NR<10 { f o r ( i =1; i<=NF; i ++){ p r i n t f
awk
#p r i n t f "&NEWRUN\n
$i
"=" } ; p r i n t " " } ' d r i f t . i n
D i s t r i b u t i o n =' $ b u n c h d i r /$ 3 '\ n" | t e e
$2>/ dev / n u l l
#awk 'BEGIN{IGNORECASE=1; FS=" ,|="}; / d i s t r i b u t i o n / { f o r ( i =1; i <NF; i=i +2){
i f ( $ i ~/ d i s t r i b u t i o n / ) {} e l s e { p r i n t " " , $ i ,"=" , $ ( i +1)} }
} NR>1 &&
/ d i s t r i b u t i o n / { p r i n t } ' $ c a s e d i r /$ 2 > $ t e m p B u f f e r
#c a t $ t e m p B u f f e r | t e e −a $2>/ dev / n u l l
awk
#!
'BEGIN{IGNORECASE=1; FS=" ,|= " } ; / d i s t r i b u t i o n / { f o r ( i =1; i <NF; i=i +2){
( $ i ~/ d i s t r i b u t i o n / ) { s p l i t (ARGV[ 2 ] , a , "=" ) ; p r i n t a [ 1 ] = a [ 2 ; ] } e l s e {
p r i n t " " , $ i , "=" , $ ( i +1)} }
} NR>1 && ! / d i s t r i b u t i o n / { p r i n t } ' $
c a s e d i r /$ 2 D i s t r i b u t i o n =\' $ b u n c h d i r /$ 3\'> $ 2
!
if
/ b i n / awk
BEGIN {
IGNORECASE=1
FS=" ,|= "
s p l i t (ARGV[ 2 ] , a , "=" ) ;
b=t o l o w e r ( a [ 1 ] )
}
$0 ~
b { f o r ( i =1; i <NF; i=i +2){ i f ( $ i ~b ) { s p l i t (ARGV[ 2 ] , a , "=" ) ; p r i n t " " , a
[ 1 ] , "=" , a [ 2 ] ; } e l s e { gsub ( " " , " " , $ i ) ; p r i n t " " , $ i , "=" , $ ( i +1)} }
}
$0 !~ b { p r i n t }
15.3 Vim
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
LESSON 1 SUMMARY
1 . The c u r s o r i s moved u s i n g e i t h e r t h e arrow k e y s o r t h e h j k l k e y s .
h ( left )
j ( down )
k ( up )
l ( right )
2 . To s t a r t Vim from t h e s h e l l prompt
3 . To
exit
Vim type :
OR type :
<ESC>
<ESC>
:q!
: wq
type :
<ENTER>
<ENTER>
4 . To d e l e t e t h e c h a r a c t e r a t t h e c u r s o r
5 . To i n s e r t o r append t e x t type :
i
type i n s e r t e d t e x t
<ESC>
A
type appended t e x t
<ESC>
E. Branlard
vim FILENAME <ENTER>
type :
to trash a l l changes .
to save the changes .
x
i n s e r t b e f o r e the cursor
append a f t e r t h e l i n e
161
CHAPTER 15. LANGUAGES AND PROGRAMS
NOTE: P r e s s i n g <ESC> w i l l p l a c e you i n Normal mode o r w i l l c a n c e l
an unwanted and p a r t i a l l y completed command .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
LESSON 2 SUMMARY
1 . To d e l e t e from t h e c u r s o r upto t h e next word type :
2 . To d e l e t e from t h e c u r s o r t o t h e end o f a l i n e type :
3 . To d e l e t e a whole l i n e type :
dd
dw
d$
4 . To r e p e a t a motion prepend i t with a number :
2w
5 . The format f o r a change command i s :
operator
[ number ]
motion
where :
o p e r a t o r − i s what t o do , such a s d f o r d e l e t e
[ number ] − i s an o p t i o n a l count t o r e p e a t t h e motion
motion
− moves o v e r t h e t e x t t o o p e r a t o r on , such a s
$ ( t o t h e end o f l i n e ) , e t c .
6 . To move t o t h e s t a r t o f t h e l i n e u s e a z e r o :
7 . To undo p r e v i o u s a c t i o n s , type :
To undo a l l t h e c h a n g e s on a l i n e ,
To undo t h e undo ' s , type :
type :
w ( word ) ,
0
u ( lowercase u)
U ( c a p i t a l U)
CTRL−R
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
LESSON 3 SUMMARY
1 . To put back t e x t t h a t has j u s t been d e l e t e d , type
p . This p u t s
the
d e l e t e d t e x t AFTER t h e c u r s o r ( i f a l i n e was d e l e t e d i t w i l l go on
the
l i n e below t h e c u r s o r ) .
2 . To r e p l a c e t h e c h a r a c t e r under t h e c u r s o r ,
c h a r a c t e r you want t o have t h e r e .
type
r
and
then
the
3 . The change o p e r a t o r a l l o w s you t o change from t h e c u r s o r t o where t h e
motion t a k e s you . eg . Type c e t o change from t h e c u r s o r t o t h e end
of
t h e word , c $ t o change t o t h e end o f a l i n e .
4 . The format
c
for
change i s :
[ number ]
motion
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
LESSON 4 SUMMARY
1 . CTRL−G
displays
G moves
number G moves
gg moves
E. Branlard
your l o c a t i o n i n t h e f i l e and t h e f i l e s t a t u s .
t o t h e end o f t h e f i l e .
t o t h a t l i n e number .
to the f i r s t l i n e .
162
CHAPTER 15. LANGUAGES AND PROGRAMS
2 . Typing / f o l l o w e d by a p h r a s e s e a r c h e s FORWARD f o r t h e p h r a s e .
Typing ? f o l l o w e d by a p h r a s e s e a r c h e s BACKWARD f o r t h e p h r a s e .
A f t e r a s e a r c h type n t o f i n d t h e next o c c u r r e n c e i n t h e same
direction
or N to search in the opposite d i r e c t i o n .
CTRL−O t a k e s you back t o o l d e r p o s i t i o n s , CTRL− I t o newer p o s i t i o n s .
3 . Typing
.
4 . To
To
To
To
To
%
while
t h e c u r s o r i s on a ( , ) , [ , ] , { , o r } g o e s t o i t s match
s u b s t i t u t e new f o r t h e f i r s t o l d i n a l i n e type
s u b s t i t u t e new f o r a l l ' old ' s on a l i n e type
s u b s t i t u t e p h r a s e s between two l i n e #' s t y p e
s u b s t i t u t e a l l o c c u r r e n c e s i n t h e f i l e type
ask f o r c o n f i r m a t i o n each time add ' c '
: s / o l d / new
: s / o l d / new / g
:#,# s / o l d / new / g
:% s / o l d / new / g
:% s / o l d / new / gc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
LESSON 6 SUMMARY
1 . Type
Type
o
O
t o open a l i n e BELOW t h e c u r s o r and s t a r t I n s e r t mode .
t o open a l i n e ABOVE t h e c u r s o r .
2 . Type
Type
a
A
t o i n s e r t t e x t AFTER t h e c u r s o r .
t o i n s e r t t e x t a f t e r t h e end o f t h e l i n e .
3 . The
e
command
4 . The
y
o p e r a t o r yanks ( c o p i e s ) t e x t ,
5 . Typing a c a p i t a l
moves t o t h e end o f a word .
R
p
puts ( pa s te s ) i t .
e n t e r s R e pl ac e mode
until
<ESC>
i s pressed .
6 . Typing " : s e t xxx " s e t s t h e o p t i o n " xxx " . Some o p t i o n s a r e :
' ic ' ' ignorecase '
i g n o r e upper / l o w e r c a se when s e a r c h i n g
' is ' ' incsearch '
show p a r t i a l matches f o r a s e a r c h p h r a s e
' hls ' ' hlsearch '
h i g h l i g h t a l l matching p h r a s e s
You can e i t h e r u s e t h e l o n g o r t h e s h o r t o p t i o n name .
7 . Prepend "no" t o s w i t c h an o p t i o n o f f :
: set n o i c
15.4 Language C++
\ s e c t i o n { I n t e r f a c e g r a p h i q u e GTK : GTK+ en C , GTKmm en C++}
h t t p : // forums . c o d e b l o c k s . o r g / i n d e x . php? t o p i c =3181.0
Dans Codeblocks , v o i r P r o j e c t −> B u i l d o p t i o n s
Compiler o p t i o n s
` pkg− c o n f i g gtk + −2.0 −− c f l a g s `
` pkg− c o n f i g gtkmm − 2.4 −− c f l a g s `
Si glade :
` pkg− c o n f i g gtkmm − 2.4 libglademm − 2.4 −− c f l a g s `
E. Branlard
163
CHAPTER 15. LANGUAGES AND PROGRAMS
Linker option :
` pkg− c o n f i g gtk + −2.0 −− l i b s `
` pkg− c o n f i g gtkmm − 2.4 −− l i b s `
Si glade :
` pkg− c o n f i g gtkmm − 2.4 libglademm − 2.4 −− l i b s `
\ s e c t i o n {Un m a k e f i l e p r o p r e GTKmm}
CC=g++
CFLAGS=−Wall −W −g ` pkg− c o n f i g gtkmm − 2.4 libglademm − 2.4 −− c f l a g s `
LFLAGS=`pkg− c o n f i g gtkmm − 2.4 libglademm − 2.4 −− l i b s `
OBJECTS=main . o a p p l i c a t i o n . o
HEADERS=a p p l i c a t i o n . hpp
TARGET=h e l l o w o r l d
all :
$ (TARGET)
$ (TARGET)
$ (CC)
: $ (OBJECTS)
−o $ (TARGET)
$ (LFLAGS)
$ (OBJECTS)
%.o : %. c c
$ (CC) $ (CFLAGS) −c $< −o $@
clean :
rm − f $ (OBJECTS) $ (TARGET) *~
\ s e c t i o n { h e r i t a g e de gtk : : window}
c l a s s F e n e t r e : p u b l i c Gtk : : Window
{
public :
Fenetre () ;
private :
};
Gtk : : VBox * v ;
Gtk : : Button b1 , b2 ;
Gtk : : La be l * l ;
G l i b : : RefPtr xml ;
Fenetre : : Fenetre () :
v(0) ,
b1 ( "Ok" ) ,
b2 ( " Annule " ) ,
l (0)
E. Branlard
164
CHAPTER 15. LANGUAGES AND PROGRAMS
{
on c h a r g e l e f i c h i e r
xml = Gnome : : Glade : : Xml : : c r e a t e ( " f e n e t r e . g l a d e " ) ;
//
on r é c u p è r e d e s p o i n t e u r s s u r l e s é l é m e n t s de l ' i n t e r f a c e
xml−>g e t_w i d g e t ( " vbox1 " , v ) ;
xml−>g e t_w i d g e t ( " l a b e l 1 " , l ) ;
//
on d é p l a c e l a VBox de l ' i n s t a n c e g é n é r é e par l e f i c h i e r g l a d e
vers la f e n ê t r e courante
xml−>r e p a r e n t_w i d g e t ( " vbox1 " , * t h i s ) ;
//
//
on c o n n e c t e deux boutons
b1 . s i g n a l_c l i c k e d ( ) . c o n n e c t ( SigC : : s l o t ( * t h i s ,
;
b2 . s i g n a l_c l i c k e d ( ) . c o n n e c t ( SigC : : s l o t ( * t h i s ,
;
//
&Gtk
: : Window : : h i d e ) )
&Gtk
: : Window : : h i d e ) )
on a j o u t e l e s deux boutons p r é c é d e n t s dans n o t r e VBox q u i
appartient à cette instance
v−>add ( b1 ) ;
v−>add ( b2 ) ;
//
//
on a f f i c h e t o u t l e monde
v−>show_ a l l _c h i l d r e n ( ) ;
//
}
i n t main ( i n t argc , c h a r ** argv )
{
Gtk : : Main a p p l i c a t i o n (&argc ,
Fenetre f ;
a p p l i c a t i o n . run ( f ) ;
}
E. Branlard
&argv )
;
165
Chapter
16
Makeles
16.1 Fortran
########################################################################
### General s y n t a x
# t a r g e t : dependencies
#
command
#
### V a r i a b l e s : i n a command :
# $@ : t a r g e t name
# $< : c u r r e n t ( f i r s t ) dependency
# $ˆ : a l l dependency , even i n o t h e r f o l d e r s ( c f VPATH)
# $ ? : dependency t h a t have been m o d i f i e d ( were not up t o d a t e )
# $* : t a r g e t name w i t h o u t e x t e n s i o n (%)
# * : l i k e in a s h e l l , * . c * . o
# In t a r g e t and dependency
# % : p a r t i c u l a r t a r g e t or r u l e
#
# Functions $ ()
# SRC:= $ ( w i l d c a r d * . o )
########################################################################
FC
= ifort
CC
= gcc
FFLAGS
= −g
CFLAGS
= −D f 2 c F o r t r a n
LDFLAGS
=
INCLS
=
BINNAME
=
NWTCLIB
= . . / . . /NWTC_Lib / S o u r c e /
INFLOWLIB = . . / . . / InflowWind / S o u r c e /
PATHSEP
=:
########################################################################
SRC=$ ( w i l d c a r d * . f 9 0 )
OBJ= $ ( p a t s u b s t %. f90 , % . o , $ (SRC) )
all :
$ (OBJ)
init :
@echo
@echo
$ (SRC)
$ (OBJ)
166
CHAPTER 16. MAKEFILES
@( cd
@( cd
$ (NWTCLIB)
;
$ (INFLOWLIB)
$ (MAKE)
;
all ) ;
all ) ;
$ (MAKE)
clean :
* . mod * . o
rm
%.o : %. f 9 0
$ (FC) $ (FFLAGS)
$ ( INCLS )
−c
$<
− I $ (NWTCLIB) − I $ (INFLOWLIB)
AeroDyn . o : SharedTypes . o AeroMods . o AeroSubs . o
AeroSubs . o : GenSubs . o AeroMods . o
GenSubs . o : AeroMods . o
16.2 Latex
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# DOCUMENT OPTIONS
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
MASTER=WTbook−B r a n l a r d
OS=WINDOWS
USE_BIBTEX=1
USE_MAKEINDEX=1
USE_MAKEGLOSS=0
USE_PSTRICKS=0
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# PATHS
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
FIGSDIR=f i g s
FIGSDUMPDIR=figsdump
SVGDIR=svg
SVGTEXDIR=s v g t e x
BIBDIR=b i b
SRCDIR=.
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# BINARIES
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
i f e q ( $ (OS) , Windows_NT)
LATEX = C : / Unix / Miktex / miktex / b i n / l a t e x
BIBTEX
= C : / Unix / Miktex / miktex / b i n / b i b t e x
DVIPS = C : / Unix / Miktex / miktex / b i n / d v i p s
PDFLATEX = C : / Unix / Miktex / miktex / b i n / p d f l a t e x
MAKEINDEX= C : / Unix / Miktex / miktex / b i n / makeindex
LATEXHTML= C : / Unix / Miktex / miktex / b i n / l a t e x 2 h t m l
PS4PDF= p s 4 p d f
else
LATEX = l a t e x
BIBTEX
= bibtex
DVIPS =d v i p s
PDFLATEX =p d f l a t e x
MAKEINDEX= makeindex
LATEXHTML= l a t e x 2 h t m l
PS4PDF= p s 4 p d f
endif
test
E. Branlard
:
167
CHAPTER 16. MAKEFILES
@echo Done
@echo $ (LATEX)
CONVERT=c o n v e r t
LN=l n
PDFTOEPS=p d f t o p s − e p s
EPSTOPDF=e p s t o p d f
SVGTOLATEX=s v g 2 l a t e x . py
SVGTOPDF=i n k s c a p e −D −A
SVGTOEPS=i n k s c a p e −D −E
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# FLAGS
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
TEX_FLAGS = −− f i l e − l i n e − e r r o r − s t y l e −− i n t e r a c t i o n=nonstopmode
BIB_FLAGS =
HTML_FLAGS =
PDFLATEX_FLAGS = −− f i l e − l i n e − e r r o r − s t y l e −− i n t e r a c t i o n=nonstopmode
PS2PDF_FLAGS
= −dMaxSubsetPct=100 − d C o m p a t i b i l i t y L e v e l =1.2 −
dSubsetFonts=true −dEmbedAllFonts=true
MAKEINDEX_FLAGS = − s p r e / i n d e x_s t y l e . i s t
MAKEGLOSS_FLAGS = − s p r e / g l o s s a i r e_s t y l e . i s t
DVIPS_FLAGS = −Ppdf −G0
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# SRC FILES
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
FIGS=$ ( n o t d i r $ ( w i l d c a r d $ (FIGSDUMPDIR) /* ) )
FIGSRC=$ ( p a t s u b s t %, $ (FIGSDUMPDIR) / %, $ ( FIGS ) )
TEXSRC = $ ( w i l d c a r d $ (SRCDIR) / p r e /* . t e x ) \
$ ( w i l d c a r d $ (SRCDIR) / t e x / * . t e x )
BIBSRC = $ ( w i l d c a r d $ ( BIBDIR ) /* . b i b )
# Using B i b t e x
i f n e q ( $ ( s t r i p $ (BIBSRC) ) , )
BBLSRC = $ (MASTER) . b b l
endif
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# D i s p l a y Codes ( t h i s i s so we can t r a c k p a s s e s )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
SETCOLOR_BLACK = @echo " \ \ 0 3 3 [ 0 ; 3 0m"
SETCOLOR_RED = @echo " \ \ 0 3 3 [ 0 ; 3 1m"
SETCOLOR_GREEN = @echo " \ \ 0 3 3 [ 0 ; 3 2m"
SETCOLOR_BLUE = @echo " \ \ 0 3 3 [ 0 ; 3 4m"
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# PNG
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
PNGS=$ ( n o t d i r $ ( w i l d c a r d $ (FIGSDUMPDIR) /* . png ) )
PNGS2EPSS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (PNGS : . png=. e p s ) )
PNGS2PDFS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (PNGS : . png=. pdf ) )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
E. Branlard
168
CHAPTER 16. MAKEFILES
# JPG
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
JPGS=$ ( n o t d i r $ ( w i l d c a r d $ (FIGSDUMPDIR) /* . j p g ) )
JPGS2EPSS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (JPGS : . j p g =. e p s ) )
JPGS2PDFS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (JPGS : . j p g =. pdf ) )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# EPS
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
EPSS=$ ( n o t d i r $ ( w i l d c a r d $ (FIGSDUMPDIR) /* . e p s ) )
EPSS2EPSS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (EPSS : . e p s =. e p s ) )
EPSS2PDFS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (EPSS : . e p s =. pdf ) )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# PDF
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
PDFS=$ ( n o t d i r $ ( w i l d c a r d $ (FIGSDUMPDIR) /* . pdf ) )
PDFS2EPSS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (PDFS : . pdf =. e p s ) )
PDFS2PDFS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (PDFS : . pdf =. pdf ) )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# SVGTEX
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
SVGTEXS=$ ( n o t d i r $ ( w i l d c a r d $ (SVGTEXDIR) /* . svg ) )
SVGTEXS2PDFS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (SVGTEXS : . svg =. pdf ) )
SVGTEX2SEPSS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (SVGTEXS : . svg =. e p s ) )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# SVG
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
SVGS=$ ( n o t d i r $ ( w i l d c a r d $ (SVGDIR) /* . svg ) )
SVGS2PDFS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (SVGS : . svg =. pdf ) )
SVGS2SEPSS=$ ( p a t s u b s t %, $ ( FIGSDIR ) / %, $ (SVGS : . svg =. e p s ) )
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# CONVERSION TO EPS
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
$ ( FIGSDIR ) / %. e p s : $ (FIGSDUMPDIR) / %.png
$ (CONVERT) " $<"
EPS3 : " $@"
$ ( FIGSDIR ) / %. e p s
$ (CONVERT)
" $<"
:
$ (FIGSDUMPDIR) / %. j p g
EPS3 : " $@"
$ ( FIGSDIR ) / %. e p s
$ (PDFTOEPS)
: $ (FIGSDUMPDIR) / %. pdf
" $<" " $@"
$ ( FIGSDIR ) / %. e p s
$ (LN)
" $<" " $@"
:
$ (FIGSDUMPDIR) / %. e p s
$ ( FIGSDIR ) / %. e p s
$ (SVGTOLATEX)
: $ (SVGTEXDIR) / %. svg
− f " $<" − l " $ ( FIGSDIR ) /$* . t e x " −e −o
$ ( FIGSDIR ) / %. e p s
$ (SVGTOEPS)
: $ (SVGDIR) / %. svg
" $@" " $<"
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# CONVERSION TO PDF
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
$ ( FIGSDIR ) / %. pdf : $ (FIGSDUMPDIR) / %.png
E. Branlard
169
CHAPTER 16. MAKEFILES
$ (CONVERT)
" $<" " $@"
$ ( FIGSDIR ) / %. pdf
$ (CONVERT)
: $ (FIGSDUMPDIR) / %. j p g
" $<" " $@"
$ ( FIGSDIR ) / %. pdf
: $ (FIGSDUMPDIR) / %. e p s
" $<" −− o u t f i l e=" $@"
$ (EPSTOPDF)
$ ( FIGSDIR ) / %. pdf
$ (LN)
" $<" " $@"
:
$ (FIGSDUMPDIR) / %. pdf
$ ( FIGSDIR ) / %. pdf
$ (SVGTOLATEX)
: $ (SVGTEXDIR) / %. svg
− f " $<" − l " $ ( FIGSDIR ) /$* . t e x " −o
$ ( FIGSDIR ) / %. pdf
$ (SVGTOPDF)
: $ (SVGDIR) / %. svg
" $@" " $<"
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# MAIN COMMANDS
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
all : allpdf
allpdf :
#
figspdf pdfall
$ (MASTER)
. pdf
#$ (MASTER) . p d f
$ (TEXSRC)
$ (FIGSRC)
$ (BIBSRC)
clean :
@rm − f * . aux * . b b l * . b l g * . l o g * . d v i * . i d x * . i l g * . i n d * . t o c * . l o t * . thm
* . cb * . cb2 * . g l s * . mtc0\
* . l o f *~ * . bak * . b l g * . exa * . adx * . bmt * . mtc * . out * . som * . g l o * . g l x * .
t n s * . t p t * . maf * . b r f
cleansvgs :
rm − f $ (SVGTEXS2PDFS)
figssvg :
$ (SVGTEXS2PDFS)
$ (SVGS2PDFS)
$ (SVGS2PDFS)
cleanfigs :
rm − f $ ( FIGSDIR ) / *
f i g s p d f : $ (JPGS2PDFS) $ (PNGS2PDFS)
EPSS2PDFS) $ (PDFS2PDFS)
$ (SVGTEXS2PDFS)
$ (SVGS2PDFS)
$(
f i g s e p s : $ (JPGS2EPSS) $ (PNGS2EPSS)
EPSS2EPSS ) $ (PDFS2EPSS)
$ (SVGTEXS2EPSS)
$ (SVGS2EPSS)
$(
fipspng :
figslower :
E. Branlard
170
CHAPTER 16. MAKEFILES
for
i i n figsdump /* ; do e x t =` echo $$ { i #* . } | t r
mv " $$ i " " $$ { i %. * } . $$ e x t " ; done
' [ : upper : ] '
' [ : lower : ] ' ` ;
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# SEQUENCES
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
pdf :
$ (PDFLATEX) $ (PDFLATEX_FLAGS) $ (MASTER)
pdfall :
i f e q ( $ (USE_PSTRICKS) , 1 )
@echo "======================================= PSTRICKS
================================================"
$ (PS4PDF) $ (MASTER) . t e x
endif
@echo "======================================= PDFLATEX1
================================================"
$ (PDFLATEX) $ (PDFLATEX_FLAGS) $ (MASTER)
i f e q ( $ (USE_BIBTEX) , 1 )
@echo "=======================================
BIBTEX
================================================"
$ (BIBTEX) $ ( BIB_FLAGS) $ (MASTER)
endif
i f e q ( $ (USE_MAKEINDEX) , 1 )
@echo "======================================= MAKEINDEX
================================================"
$ (MAKEINDEX) $ (MAKEINDEX_FLAGS) $ (MASTER)
endif
i f e q ( $ (USE_MAKEGLOSS) , 1 )
@echo "======================================= MAKEGLOSS
================================================"
$ (MAKEINDEX) $ (MAKEGLOSS_FLAGS) −o $ (MASTER) . g l s $ (MASTER) . g l o
endif
@echo "======================================= PDFLATEX2
================================================"
$ (PDFLATEX) $ (PDFLATEX_FLAGS) $ (MASTER)
@echo "======================================= PDFLATEX3
================================================"
$ (PDFLATEX) $ (PDFLATEX_FLAGS) $ (MASTER)
#~
#~
#~
#~
$ (LATEX)
$ (DVIPS)
$ (TEX_FLAGS)
$ (MASTER)
$ (DVIPS_FLAGS)
−o $ (FIGSDIR) /PSTRICKSFIGURES . ps $ (MASTER) .
dvi
$ (PS2PDF) − dAutoRotatePages=/ None
p s t −pdf −example1 −
pics . pdf
$ (PDFLATEX) $ (PDFLATEX_FLAGS) $ (MASTER)
latexquick :
$ (LATEX) $ (MASTER)
latex :
$ (LATEX) $ (TEX_FLAGS) $ (MASTER)
$ (BIBTEX) $ ( BIB_FLAGS) $ (MASTER)
$ (LATEX) $ (TEX_FLAGS) $ (MASTER)
$ (LATEX) $ (TEX_FLAGS) $ (MASTER)
E. Branlard
171
CHAPTER 16. MAKEFILES
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# LATEX
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# To a c c o m p l i s h 2 c o m p i l a t i o n we c h a i n from t e x −>aux−>d v i
# To g e n e r a t e a . aux f i l e from a . t e x f i l e
# To g e n e r a t e a . d v i f i l e from a . t e x f i l e
$ (MASTER) . d v i : $ (MASTER) . aux
$ (LATEX) $ (TEX_FLAGS) $< >/ dev / n u l l
# To g e n e r a t e a . ps f i l e from a . d v i f i l e
$ (MASTER) . ps : $ (MASTER) . d v i
$ (DVIPS) $ (DVIPS_FLAGS) −o $@ $<
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# INDEX
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
i n d e x : $ (MASTER) . aux $ (MASTER) . i d x $ (MASTER) . i l g $ (MASTER) . i n d
# To g e n e r a t e a . i d x f i l e from a . t e x f i l e
%. i l g : %. i d x
$ (MAKEINDEX) $ (MAKEINDEX_FLAGS) $ ( *F)
bibindex : bibtex index
#makeindex − s b i b i d x / manuel . i s t $ (MASTER)
#makeindex − s b i b i d x / g l o s s a i r e . i s t $ (MASTER) . g l o −o
#b i b t e x $ (MASTER)
$ (MASTER)
. glx
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# HTML Output
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
html :
$ (MASTER) . html f i p s p n g
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# PDFLATEX
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
$ (MASTER) . pdf : $ (MASTER) . t e x
$ (PDFLATEX) $ (PDFLATEX_FLAGS) $<
%.aux : %. t e x
$ (PDFLATEX)
$ (PDFLATEX_FLAGS)
$<
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# BIBTEX
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
%. b b l : %. t e x
i f n e q ( $ ( s t r i p $ (BIBSRC) ) , )
echo " Here "
$ (BIBTEX) $ ( BIB_FLAGS) $ ( *F)
E. Branlard
172
CHAPTER 16. MAKEFILES
endif
# Dependencies
#$ (MASTER) . t e x
#$ (MASTER) . aux
#$ (MASTER) . b b l
#$ (MASTER) . p d f
#$ (MASTER) . d v i
E. Branlard
:
:
:
:
:
$ (TEXSRC)
$ (FIGSRC)
$ (BIBSRC)
$ (MASTER)
$ (TEXSRC)
$ (FIGSRC)
$ (BBLSRC)
. aux
$ (MASTER) . aux $ (TEXSRC) $ (FIGSRC)
$ (TEXSRC) $ (FIGSRC)
$ (BBLSRC)
$ (BBLSRC)
$ (BIBSRC)
173
Chapter
17
Kernel compilation
## S o l u t i o n a l a main ( modules_ i n s t a l l e s f o u t l e s modules dans
modules )
# cd / u s r / s r c / l i n u x
# make c l e a n
# make menuconfig
# make && make modules_ i n s t a l l
# make i n s t a l l
#
#
#
#
/lib/
cp arch / i 3 8 6 / b o o t / bzImage / b o o t / k e r n e l − 2.6.26 − x−y
cp . c o n f i g / b o o t / c o n f i g − 2.6.26 − x−y
v i /boot/grub/grub . conf
reboot
## S o l u t i o n d e b i a n s i m p l e
# make−kpkg −− i n i t r d −− r e v i s i o n =1 k e r n e l_image k e r n e l_h e a d e r s
# cd . . /
# dpkg − i l i n u x * . deb
## S o l u t i o n d e b i a n avec c o m p i l a t i o n s modules
make−kpkg −− i n i t r d −−append−to − v e r s i o n =. rastamanu −− r e v i s i o n =2 −−added−
modules=n v i d i a − k e r n e l , broadcom− s t a k e r n e l_image k e r n e l_h e a d e r s modules
_image
make−kpkg −−append−to − v e r s i o n =.batmanu −− r e v i s i o n =1 −−added−modules=n v i d i a
− k e r n e l , broadcom− s t a k e r n e l_image k e r n e l_h e a d e r s modules_image
make−kpkg −−append−to − v e r s i o n =. ironmanu −− r e v i s i o n =1 −−added−modules=
n v i d i a − k e r n e l , broadcom− s t a k e r n e l_image k e r n e l_h e a d e r s modules_image
a f t e r i n s t a l l , t h e modules a r e i n t h e f o l d e r
( default locations
/ u s r / s r c / modules
for
modules s o u r c e s )
174
/ l i b / modules /
CHAPTER 17. KERNEL COMPILATION
(
make−kpkg k e r n e l_source
make−kpkg k e r n e l_doc
)
## S o l u t i o n d e b i a n Target b u i l d p a c k a g e c r e e t o u s l e s deb : k e r n e l_image ,
dbg , headers , doc , e t c . . .
su −c ' make−kpkg −− i n i t r d b u i l d p a c k a g e '
cd . .
su −c ' dpkg − i l i n u x * . deb '
L i v r e u t i l e − Linux K e r n e l i n a N u t s h e l l
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
h t t p : //www. kroah . com/ l k n /
−> P r i n c i p e
Tout c e q u i d o i t ê t r e c h a r g é en permance a c o m p i l e r en dur ( ext3 , a c p i
co . . . ) e t l e r e s t e en module ( c r y p t a g e notement )
E. Branlard
et
175
CHAPTER 17. KERNEL COMPILATION
Dépendances
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−>Paquets b a s i q u e :
sudo a p t i t u d e i n s t a l l b u i l d − e s s e n t i a l k e r n e l −package i n i t r a m f s − t o o l s
f a k e r o o t debconf − u t i l s dpkg−dev d e b h e l p e r b i n 8 6
−>Paquets pour c r é e r l e " . c o n f i g "
" . c o n f i g " , c ' e s t l e f i c h i e r de c o n f i g u r a t i o n c o n t e n a n t l e s i n s t r u c t i o n s de
compilation .
* Pour une i n t e r f a c e g r a p h i q u e ( b l e u e ) en c o n s o l e : i n s t a l l e z l e paquet
l i b n c u r s e s 5 −dev
Pour une i n t e r f a c e en TK : i n s t a l l e z l e paquet tk −dev
* Pour une i n t e r f a c e en GTK+ ( noyau 2 . 6 s e u l e m e n t ) : i n s t a l l e z l e s p a q u e t s
l i b g l i b 2 .0 − dev l i b g t k 2 .0 − dev l i b g l a d e 2 −dev
Pour c r é e r une c o n f i g u r a t i o n en mode c o n s o l e :
make c o n f i g ## D é c o n s e i l l é pour l e s d é b u t a n t s e t même l e s a u t r e s
Pour c r é e r une c o n f i g u r a t i o n en mode semi −g r a p h i q u e ( menu b l e u ) :
make menuconfig
Pour c r é e r une c o n f i g u r a t i o n en GTK :
make g c o n f i g
Pour c r é e r une c o n f i g u r a t i o n en TK ou en QT :
make x c o n f i g
−> D r o i t d ' e c r i t u r e pour l e s s o u r c e s :
$groups
S i vous n ' a p p a r t e n e z pas au groupe " s r c " , a j o u t e z −vous :
$ sudo a d d u s e r $USERNAME s r c ## b e s o i n de s e fermer l a s e s s i o n pour que
c e t t e commande prenne e f f e t .
$ sudo chown $USERNAME / u s r / s r c ## s i l a commande du d e s s u s ne vous donne
pas l ' a c c è s en é c r i t u r e du d o s s i e r / u s r / s r c . . .
I l f a u t maintenant s e r e c o n n e c t e r s o u s v o t r e l o g i n pour que l e s nouveaux
droits soit fonctionnels .
su − $USERNAME ## E n t r e r v o t r e mot de p a s s e
A l l e z dans l e r é p e r t o i r e
cd / u s r / s r c
/usr/ src
:
Téléchargement d e s s o u r c e s
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−> Le k e r n e l
E. Branlard
176
CHAPTER 17. KERNEL COMPILATION
T e l e c h a r g e s l e d e r n i e r k e r n e l s t a b l e h t t p : //www. k e r n e l . o r g / pub / l i n u x /
k e r n e l / . 4 . t a r . bz2 ( wget . . . )
OU
#a p t i t u d e s e a r c h l i n u x −s o u r c e
# a p t i t u d e i n s t a l l l i n u x −source − 2.6.24
( p l a c é dans / u s r / s r c / )
Avec v o t r e u t i l i s a t e u r , p l a c e z vous dans v o t r e r é p e r t o i r e p e r s o n n e l $ {HOME
} p u i s c r é e z un r é p e r t o i r e s r c / , décompactez l ' a r c h i v e c o n t e n a n t l e s
s o u r c e s du noyau :
$ mkdir $ {HOME} / s r c && cd $ {HOME} / s r c /
$ t a r − x v f / u s r / s r c / l i n u x −source − 2 . 6 . 2 4 . t a r . bz2
Vous o b t e n e z un r é p e r t o i r e $ {HOME} / s r c / l i n u x −source − 2 . 6 . 2 4 . Nous a l l o n s
f a i r e un l i e n s y m b o l i q u e p o i n t a n t s u r l e r é p e r t o i r e précédemment c r é é
e t nous p l a c e r e n f i n dans l e r é p e r t o i r e d e s s o u r c e s :
$ l n − s $ {HOME} / s r c / l i n u x −source − 2 . 6 . 2 4 $ {HOME} / s r c / l i n u x
−> l e s modules c o m p l é m e n t a i r e s : a l s a e t n v i d i a
( i n s t a l l e r e t decompacter l e s s o u r c e s )
Pour l a c o m p i l a t i o n r a j o u t e r :
−−added−modules=a l s a − d r i v e r , n v i d i a − k e r n e l −new
La c o n f i g u r a t i o n du . c o n f i g
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
On peut commencer par p r e n d r e l e . c o n f i g a c t u e l :
cp / boot / c o n f i g * / . c o n f i g
$ {HOME} / s r c / l i n u x / . c o n f i g
A f i n de c o n n a î t r e p r é c i s é m e n t v o t r e m a t é r i e l , vous pouvez u t i l i s e r l e s
commandes
$lspci
$ lshw , s a n s o u b l i e r l ' a r b o r e s c e n c e / p r o c /
h t t p : // doc . ubuntu− f r . o r g / t u t o r i e l / k e r n e l_o p t i o n s
Les o p t i o n s s e c t i o n par s e c t i o n
* Code m a t u r i t y l e v e l o p t i o n s : Permet de c a c h e r ou de f a i r e a p p a r a î t r e
l e s o p t i o n s q u i s o n t e n c o r e en développement e t donc c o n s i d é r é e s
comme i n s t a b l e s ( s o u v e n t u t i l e de d i r e ' oui ' i c i s i l ' on veut
E. Branlard
177
CHAPTER 17. KERNEL COMPILATION
p o u v o i r p r o f i t e r d e s d e r n i è r e s a v a n c é e s du noyau ) .
* G e n e r a l s e t u p : Ensemble d ' o p t i o n s g é n é r a l e s s u r v o t r e système ( s a u f
s i vous v o u l e z c o m p i l e r pour d e s a r c h i t e c t u r e s t r è s p a r t i c u l i è r e s ,
vous pouvez l e l a i s s e r t e l q u e l ) .
* Loadable module s u p p o r t : Options c o n c e r n a n t l a g e s t i o n d e s modules (
l e d é f a u t e s t p r e s q u e t o u j o u r s c o r r e c t pour une u t i l i s a t i o n normale
).
* Block l a y e r : Les e n t r é e s / s o r t i e s s u r v o t r e c a r t e −mère ( i n u t i l e d ' y
toucher ) .
* Processor
type
type and f e a t u r e s : Options r e l a t i v e s au ( x ) p r o c e s s e u r ( s ) :
( x86 , Sparc , . . . ) , hyper −thread , dual −c o r e , SMP, e t c .
* Power management o p t i o n s (ACPI , APM) : Options c o n c e r n a n t l ' économie
d ' é n e r g i e , l a mise en v e i l l e
et
l ' ACPI/APM.
* Bus o p t i o n s ( PCI , PCMCIA, EISA , MCA, ISA ) : G e s t i o n de t o u s l e s
e n d r o i t s où vous p o u r r i e z e n f i c h e r d e s c a r t e s ( PCI , PCMCIA, ISA ,
etc ) .
* E x e c u t a b l e f i l e f o r m a t s : La g e s t i o n d e s f i c h i e r s e x é c u t a b l e ( Le
s u p p p o r t ELF d o i t t o u j o u r s ê t r e à 'Y' ) .
* Networking : Options c o n c e r n a n t l e s p r o t o c o l e s r é s e a u g é r é s par v o t r e
noyau ( l e d é f a u t e s t b i e n s o u v e n t s u f f i s a n t , mais j e t e z y un coup
d ' o e i l à tout hasard ) .
* D ev ic e D r i v e r s : Options c o n c e r n a n t t o u s l e s p i l o t e s m a t é r i e l ( c ' e s t
b i e n s o u v e n t i c i que l ' on p a s s e l e p l u s de temps ) .
* F i l e s y s t e m s : Options c o n c e r n a n t l e s s y s t è m e s de f i c h i e r s g é r é s par
v o t r e noyau ( vous a u r e z à y j e t e r un coup d ' o e i l ) .
* I n s t r u m e n t a t i o n Support : Option de p r o f i l a g e du noyau ( i n u t i l e de l '
activer ) .
* K e r n e l h a c k i n g ; Options de déboguage du noyau ( i n u t i l e de l ' a c t i v e r
s a u f s i vous avez d e s e n v i e s p a r t i c u l i è r e s ) .
* S e c u r i t y o p t i o n s : Options c o n c e r n a n t l e modèle de s é c u r i t é de v o t r e
noyau ( l e d é f a u t e s t s u f f i s a n t )
* C r y p t o g r a p h i c o p t i o n s : A l g o r i t h m e s c r y p t o g r a p h i q u e s pouvant ê t r e
i m p l a n t é s dans l e noyau ( l e d é f a u t e s t s u f f i s a n t ) .
* L i b r a r y r o u t i n e s : B i b l i o t h è q u e s communes du noyau ( l e d é f a u t e s t
suffisant )
La c o m p i l a t i o n
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−> Options :
E. Branlard
178
CHAPTER 17. KERNEL COMPILATION
−Les modules c o m p l é m e n t a i r e s :
−−added−modules=a l s a − d r i v e r , n v i d i a − k e r n e l − l e g a c y
− A j o u t e r un nom de v e r s i o n :
−−append−to − v e r s i o n =. ` d a t e +%y%m%d `
−S i f a k e r o o t i n s t a l l é
−−rootcmd f a k e r o o t
−i n i t r d
Cela permet de c r é e r un f i c h i e r i n i t r d . Cela e s t p a r t i c u l i è r e m e n t u t i l e
s i vous s o u h a i t e z u t i l i s e r d e s modules du noyau a f i n qu ' i l s s o i e n t
p r i s en compte d è s
l ' amorçage de l ' image de v o t r e noyau .
Notez que c e t t e o p t i o n n é c e s s i t e l e paquet i n i t r a m f s − t o o l s , que vous
pouvez i n s t a l l e r en t a p a n t :
# a p t i t u d e i n s t a l l i n i t r a m f s −t o o l s
− l e s c i b l e s de make−kpkg : s o n t par exemple c l e a n , b i n a r y ( f a i s . deb doc
e t c e t grub ) , k e r n e l_image ( f a i s . deb e t grub ) , ou b u i l d p a c k a g e ( q u i
f a i t c l e a n et b i n a r y )
−> C o m p i l a t i o n
Sous Ubuntu :
sudo make−kpkg −− i n i t r d b u i l d p a c k a g e
Sous Debian
su −c ' make−kpkg −− i n i t r d b u i l d p a c k a g e '
Retournez dans l e d o s s i e r p r é c é d e n t :
cd . .
su −c ' dpkg − i l i n u x * . deb '
I n s t a l l a t i o n d e s * . deb
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Sous Ubuntu
sudo dpkg − i l i n u x * . deb
Sous Debian
su −c ' dpkg − i l i n u x * . deb '
D e s i n s t a l l a t i o n du k e r n e l
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
a p t i t u d e remove −−purge k e r n e l −image − 2.6.7 − ` d a t e +%y%%m%d `
h t t p : // doc . ubuntu− f r . o r g / t u t o r i e l / comment_c o m p i l e r_un_k e r n e l_de_k e r n e l . o r g
h t t p : //www. a n d e s i . o r g / noyau : c o m p i l a t i o n −d−un−noyau−a−l a −sauce −d e b i a n
h t t p : // g e r s h w i n . e n s . f r / v d a n i e l / Doc−L o c a l e / O u t i l s −Gnu−Linux / Linux_Doc /YAGIL
− 2 . 2 . 1 /HTML/ c4517 . html
E. Branlard
179

Documents pareils

Debianuel-Notes on a linux experience - Emmanuel Branlard

Debianuel-Notes on a linux experience - Emmanuel Branlard Astuce XFCE : transparent background for panel . . . . . . . . . . . . . . . . Astuce XFCE : Handle acpi event for power button, show Xfce logout options Xubuntu xfce saved session . . . . . . . . ...

Plus en détail

Attention certains liens sont peut-être obsolètes. Classification par

Attention certains liens sont peut-être obsolètes. Classification par http://www.vwkweb.nl/( DUTCH METEOROLOGICAL and CLIMATOLOGICAL ASSOCIATION (VWK))

Plus en détail