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 March 2012 Contents I Notes on linux 8 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 1.12 1.13 1.14 1.15 1.16 1.17 1.18 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . Vi Vim or gVim . . . . . . . . . . . . . . . . . . . . . . . . Vim Colorscheme . . . . . . . . . . . . . . . . . . . . . . . . Vim QuickFix window . . . . . . . . . . . . . . . . . . . . . Vim-latex . . . . . . . . . . . . . . . . . . . . . . . . . . . . Vim en color . . . . . . . . . . . . . . . . . . . . . . . . . . Grep - List of my REGEXP . . . . . . . . . . . . . . . . . . FORLOOPS/ FIND / XARGS and SPACECHARACTERS TEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TEST - COMPOUND . . . . . . . . . . . . . . . . . . . . . STANDARD IN, STANDARD OUT . . . . . . . . . . . . . Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command FIND - application to album cover le . . . . . . Remove consecutive blank lines - duplicate empty line . . . AWK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DU and DF . . . . . . . . . . . . . . . . . . . . . . . . . . . Patches - apply patch - create patch -reverse patch . . . . . Git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Latex 2.1 2.2 2.3 2.4 2.5 Install new latex font . . . . . . . . . . . . . Tkz and gnuplot - problem with gnuplot 4.4 svg2latex . . . . . . . . . . . . . . . . . . . Latex et packages . . . . . . . . . . . . . . . Latex et windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Debian wheezy with xfce4 3.1 Important stu to do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Rhythmbox problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Debian squeeze - tweaks - latest updates 4.1 4.2 4.3 4.4 4.5 4.6 Important stu to do . . . . . . . . . . . . . FlashPlayer - plugin for mozilla . . . . . . . Chrome - Get latest java working . . . . . . Compiling evince 2.31 on debian squeeze . . Compiling inkscape 0.48 for debian squeeze Xfce4.8 on debian squeeze . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 9 12 12 12 13 13 14 14 15 15 15 15 16 16 17 17 18 19 19 19 19 20 20 21 21 22 23 23 23 23 24 25 25 CONTENTS 5 APPPLICATIONS 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 5.42 5.43 5.44 5.45 5.46 5.47 xrandr - arandr - Dynamic Multiple screens - xinerama . . . . . . . . . . . . . . . . Download google books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thunderbird with calendar - Debian squeeze . . . . . . . . . . . . . . . . . . . . . . Vmail - gmail in vim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Vimperator - plugin to use vi in refox . . . . . . . . . . . . . . . . . . . . . . . . . Use Vi mode in bash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Playlists - Format - Conversions - Rhythmbox - Solving the problem of moved les Send email with attachment using the shell . . . . . . . . . . . . . . . . . . . . . . Mp3 tag from lenamejwith tagtool . . . . . . . . . . . . . . . . . . . . . . . . . . . Equalize MP3 using mp3 gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xls2csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PDF password - password crack - pdfcrack - bypass - print by keeping CR . . . . . R - Bypass user le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Iceweasel Backspace to go back one page . . . . . . . . . . . . . . . . . . . . . . . . Congure pulseaudio for Debian - 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 . . . . . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logiciels equivalent linux / windows . . . . . . . . . . . . . . . . . . . . . . . . . . Personaliser xterm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RAW photo images nikon .NEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E. Branlard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 26 26 26 27 27 27 27 29 29 29 29 29 30 30 30 33 33 33 37 37 38 38 38 39 39 39 39 39 40 41 41 42 42 43 44 45 45 46 46 46 46 46 46 47 47 47 48 2 CONTENTS 6 Xorg - clavier souris touchpad 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 Starting dierent x servers . . . . . . . . . . . . . . . . . . . . Bien lire le log Xorg . . . . . . . . . . . . . . . . . . . . . . . Xorg ou/et HAL . . . . . . . . . . . . . . . . . . . . . . . . . X11 working x11 without hald/dbus . . . . . . . . . . . . . . Numlockx conicting . . . . . . . . . . . . . . . . . . . . . . . Ctrl alt Backspace to restart X server . . . . . . . . . . . . . QWERTY et accents . . . . . . . . . . . . . . . . . . . . . . . Get keyboard keycodes . . . . . . . . . . . . . . . . . . . . . . Monitor going to sleep after 10 minutes - Power management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Important xfce folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Remember where xfce4-panel layout is stored . . . . . . . . . . . . . . . . . . Disable roll up of windows with mousewheel . . . . . . . . . . . . . . . . . . . Tiling with xfwm4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing les on the desktop without having to go to the desktop . . . . . . Cleaning up Xfce menu - applications wine . . . . . . . . . . . . . . . . . . . . Understanding Mimetypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command for Toggle Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . Notications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thunar - Congure shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . xfce shortcuts are stored in . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thunar - User customed actions . . . . . . . . . . . . . . . . . . . . . . . . . . XFCE Default User directories - Thunar Templates . . . . . . . . . . . . . . . Astuce XFCE : transparent background for panel . . . . . . . . . . . . . . . . Astuce XFCE : Handle acpi event for power button, show Xfce logout options Xubuntu xfce saved session . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sound mixing - xfce4-volumed - amixer - pulseaudio . . . . . . . . . . . . . . Applications pour environnement xfce sans dependances gnome ou kde . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 XFCE - xfce4 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.10 7.11 7.12 7.13 7.14 7.15 7.16 7.17 7.18 8 SYSTEM 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 8.10 8.11 8.12 8.13 8.14 8.15 8.16 8.17 8.18 8.19 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Password protect single user mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Turn o php expose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Heure machine exact - NTP daemon . . . . . . . . . . . . . . . . . . . . . . . . . . . . Increase password strength with PAM cracklib or passwdqc . . . . . . . . . . . . . . . Init Boot sequence messages in color - [ok] . . . . . . . . . . . . . . . . . . . . . . . . . Nettoyage des log automatique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Informations systeme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Addressse MAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Journaux systemes - bootlog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . Use aptitude - Utiliser aptitude - liste de paquets - dpkg - apt-get - Manage Packages package list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bien maitriser ses paquets - application a nvidia . . . . . . . . . . . . . . . . . . . . . . Command to reload fstab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changer le nom de votre machine, change hostname . . . . . . . . . . . . . . . . . . . Rendre clef USB amorcable - install distribution iso from usb bootable . . . . . . . . . Comment savoir si on est 32 ou 64bits . . . . . . . . . . . . . . . . . . . . . . . . . . . E. Branlard 49 49 49 49 50 50 51 51 51 51 53 53 53 53 53 54 55 55 55 56 56 56 56 56 57 57 58 58 59 60 60 60 60 60 60 61 61 61 62 62 62 63 63 63 64 64 64 65 65 3 CONTENTS 8.20 8.21 8.22 8.23 8.24 8.25 8.26 8.27 8.28 8.29 8.30 8.31 8.32 8.33 Exécuter plusieurs versions de Debian avec chroot . . . . . . . . . . . . Probleme d'heure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Make your own init script - launching scripts at boot - init.d . . . . . . . Bip systeme - tab - arret systeme . . . . . . . . . . . . . . . . . . . . . . Congurer son reseau a la main . . . . . . . . . . . . . . . . . . . . . . . Conversion UTF8 ISO-8859-1 . . . . . . . . . . . . . . . . . . . . . . . . Initramfs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Restaurer une installation Debian - Restore Debian install - Package list Accents, caracteres accentues, font terminal amarok . . . . . . . . . . . . Congurer sudoers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Eteindre / redemarrer : droits utilisateur . . . . . . . . . . . . . . . . . Demarrage - gestionnaire de connexion - autologin . . . . . . . . . . . . Demarrage - gestionnaire de connexion - auto-startx - autostartx . . . . Autologin, fenetre de connexion sans gdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 66 66 67 67 67 68 68 68 68 69 69 70 70 9 FILESYSTEMS, UTILISATEURS, GROUPES, DROITS 71 10 Grub, dual-boot, MBR 79 11 WIFI 82 12 SERVERS - PHP SQL APACHE SAMBA FTP SSH 87 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 Policykit - local authority - rights for reboot, mount usb etc.. . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1 Congure Grub 2 - create grub.d congs . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Instal grub in MBR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.3 Installer un dual boot avec Vista, sans utiliser le MBR . . . . . . . . . . . . . . . . . . 11.1 Congurer ma carte wi bcm4312, broadcom . . . . . . . . . . . . . . . . . . . . . . . 11.2 Cracker wi WEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Monitor mode for wi usb key : TL-WN321G chipset Ralink rt73 . . . . . . . . . . . . 12.1 VirtualBox . . . . . . . . . . . . . . . . . . . . . . . . 12.2 SQL editor: sqlitebrowser . . . . . . . . . . . . . . . . 12.3 Free shell servers . . . . . . . . . . . . . . . . . . . . . 12.4 Debian Serveur . . . . . . . . . . . . . . . . . . . . . . 12.5 Video surveillance - Zone minder . . . . . . . . . . . . 12.6 CUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.7 Telnet . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.8 Creer une base de donnees sql pour amarok . . . . . . 12.9 PHP mysql et apache sous ubuntu . . . . . . . . . . . 12.10Apache - example of htaccess le . . . . . . . . . . . . 12.11Apache - probleme de liens symbolic . . . . . . . . . . 12.12Aide server apache - les bases . . . . . . . . . . . . . . 12.13Aide server apache - l'autoindex et le probleme de php 12.14Aide server apache - protection par mot de passe . . . 12.15iptables . . . . . . . . . . . . . . . . . . . . . . . . . . 12.16Server FTP . . . . . . . . . . . . . . . . . . . . . . . . 12.17DynDNS . . . . . . . . . . . . . . . . . . . . . . . . . . E. Branlard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 72 73 74 74 74 75 77 79 79 81 82 85 86 87 87 87 88 89 89 90 90 90 92 93 94 94 95 96 96 97 4 CONTENTS 12.18Voisimage reseau : pyNeighborhood . . . . . . . . . . . . 12.19Samba fusesmb pyNeighborhood . . . . . . . . . . . . . 12.20Communiquer avec les reseaux microsoft . . . . . . . . . 12.21Activation du voisinage réseau Windows dans Thunar . 12.22fusemb . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Multimedia 13.1 13.2 13.3 13.4 13.5 13.6 Lire wmv windows media video ? . . Video capture . . . . . . . . . . . . . Timidity is not yet congured. . . . Timidity GUI . . . . . . . . . . . . . Midi . . . . . . . . . . . . . . . . . . FFMPEG et MP3 lame sous debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Optimizations ? 14.1 Swappiness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.2 Optimisation - Date de modif . . . . . . . . . . . . . . . . . . . . . . . . 14.3 Readahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.4 Optimisation - Preload . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.5 Optimisation - Démarrer les applications plus rapidement avec Prelink 14.6 Optimisation - Suppression services - Init scripts . . . . . . . . . . . . . 14.7 Bootchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.8 Optimisation - Cong reseau demarrage . . . . . . . . . . . . . . . . . . 14.9 Optimisation - chargement polices . . . . . . . . . . . . . . . . . . . . . 14.10Open oce optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 98 99 99 99 100 100 100 100 100 101 101 102 102 102 103 104 104 104 108 108 109 109 15 Misceleanous 110 II 112 15.1 15.2 15.3 15.4 Java Gcj versus Sun - select defaults JVM . . . . . . . . . . . . . . . . . . . . . . . . . Connexion ssh avec mot de passe automatique, methode bourrin mot de passe en clair Nvidia drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Virer le Usplash splash screen demarrage ubuntu . . . . . . . . . . . . . . . . . . . . . Supplementary notes 16 Conguration Files 16.1 16.2 16.3 16.4 16.5 16.6 16.7 /.bashrc . . . . /.bash_prole /.xinitrc . . . . /.xsession . . . /.Xdefaults . . /.vimrc . . . . /.conkyrc . . . 17 Shell scripts 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . exaileplaylist2rhythmox cnx-vjk.expect . . . . . . backupSyst . . . . . . . RisoUnMount . . . . . . showTag . . . . . . . . . syncStorage . . . . . . . audioInfo . . . . . . . . shrinkFig2 . . . . . . . . E. Branlard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 110 110 111 113 113 115 116 117 118 118 126 127 127 128 128 130 131 131 132 133 5 CONTENTS 17.9 ifort-setup . . . . . . . . . 17.10texclean . . . . . . . . . . 17.11sendit . . . . . . . . . . . 17.12topdf . . . . . . . . . . . . 17.13pdfFind . . . . . . . . . . 17.14GETAPTKEY . . . . . . 17.15shrinkFig . . . . . . . . . 17.16svg2latex.py . . . . . . . . 17.17RisoMount . . . . . . . . 17.18xfce4ToggleDesktop . . . . 17.19pdfocr . . . . . . . . . . . 17.20pdfocr-tess . . . . . . . . . 17.21PulseMediaKeys.sh . . . . 17.22alarmaniac . . . . . . . . . 17.23keyboardSetup . . . . . . 17.24pdfAutoRename . . . . . 17.25unix2win . . . . . . . . . . 17.26formatWebVersion . . . . 17.27DoBootchart . . . . . . . 17.28Terminator.sh . . . . . . . 17.29svg2png . . . . . . . . . . 17.30m3u2xspf.py . . . . . . . . 17.31tomp3 . . . . . . . . . . . 17.32ECN-RenameByTitle.sh . 17.33rhythmboxplaylist2exaile . 17.34rhythmboxstart . . . . . . 17.35keywordsSetUp . . . . . . 17.36pm-inhibit.py . . . . . . . 17.37pdfBind . . . . . . . . . . 17.38compilWebVersion . . . . 17.39LaunchSession.sh . . . . . 17.40rhythmboxstartlong . . . . 17.41convertEnc . . . . . . . . 17.42pdfAlternRotation . . . . 17.434terms . . . . . . . . . . . 17.44MoveWindowLeftRight.sh 17.45ScreenConf.sh . . . . . . . 17.46xsetnumlock.c . . . . . . . 17.47ref . . . . . . . . . . . . . 17.48DEFAULT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 133 134 135 135 136 136 137 147 147 147 148 150 151 151 152 154 155 155 155 156 158 160 161 161 162 163 163 163 164 168 168 169 172 173 173 173 173 174 174 18 Debian 176 19 Fluxbox 185 18.1 Install Debian from scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 18.2 Program list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 19.1 Install Debian with Fluxbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 19.2 Notes on Fluxbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 19.3 Tuning Fluxbox Appearence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 E. Branlard 6 CONTENTS 20 Languages and programs 20.1 20.2 20.3 20.4 Unix . . . . . . Awk . . . . . . Vim . . . . . . Language C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 188 189 190 192 21 Makeles 195 22 Kernel compilation 203 21.1 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 21.2 Latex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 23 Old notes on linux 23.1 Google Earth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2 Matlab : Ajouter un repertoire dans la variable PATH . . . . . . . . . . . . . . . . 23.3 Congure skype sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.4 Hacker xterm - source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.5 Congurer Geany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.6 Telecharger les jaquettes des pistes de la liste de lecture d'amarok dans leur dossier 23.7 Cong souris logitech lx8 left handed . . . . . . . . . . . . . . . . . . . . . . . . . . 23.8 Mise en veille et hibernation qui plante avec cartes Nvidia . . . . . . . . . . . . . . 23.9 Equivalent win split revolution with wmctrl - raccourcis clavier xfce . . . . . . . . . 23.10Tip XFCE : How to include all application while switching windows . . . . . . . . 23.11Migrate from Ext3 a Ext4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.12Fluxbox et wi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.13WIFI, et GESTIONNAIRE DE TROUSSEAU . . . . . . . . . . . . . . . . . . . . 23.14Probleme gnome barre verticale - liste de fenetres . . . . . . . . . . . . . . . . . . . 23.15Mot de passe mise en veille . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.16NetworkManager - wi au reveil apres mise en veille ou hibernation . . . . . . . . . 23.17Histoire de memoire vive detectee . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.18Debian - conseil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.19Optimisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E. Branlard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 210 210 210 211 211 211 211 212 212 214 214 215 215 216 217 217 217 217 218 7 Part I Notes on linux 8 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 sed stream e d i t o r , p e r f o r m s s e a r c h and r e p l a c e 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 12G : go t o l i n e 12 M : go t o t h e middle o f t h e s c r e e n %z s t u f f − combine i t with : s e t s c r o l l o f f =3 f o r a smooother s c r e e n offset z t : w i l l s c r o l l s o t h a t t h e c u r r e n t c u r s o r i s a t t h e top z z : w i l l s c r o l l s o t h a t t h e c u r r e n t c u r s o r i s a t t h e middle zb : w i l l s c r o l l s o t h a t t h e c u r r e n t c u r s o r i s a t t h e bottom CTRL−E CTRL−Y : s c r o l l down CTRL−B CTRL−F : page backwards page f o r w a r d CTRL−U CTRL−D : h a l f page up h a l f page down , o r whatever you s e t with s c r o l l ( d e f a u l t s c r o l l =0) CTRL−o CTRL− I : go t o o l d e r / newr p o s i t i o n w b e : next / p r e v i o u s word W B E : same but u s e s s p a c e s a s d e l i m i t e r s 9 CHAPTER 1. UNIX COMMANDS %% % Basic <C−r> : r e d o ! ! ! u U : undo w : save wq : s a v e and q u i t ZZ : s a v e and c l o s e f i l e %% % 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 %% % x xp dd dj dw de D e l e t i o n / Change / Selection : r e v e r s e two l e t t e r s , u s e f u l l Copy − Same b e h a v i o r / for typos l i k e : f r o : d e l e t e c u r r e n t l i n e and below : d e l e t e t h e r e s t o f t h e word and next s p a c e ( good f o r f u l l words ) : d e l e t e r e s t o f t h e word but not t h e s p a c e ( good f o r t h e end o f a word ) %% % di } dt } df } vi } va } yi } ci } Block s t u f f ( don ' t know p r o p e r term ) o r d i { : d e l e t e e v e r y t h i n g between b r a c k e t s : d e l e t e t o l l t h e next b r a k e t but d o e s not d e l e t e t h e } : same but d e l e t e t h e b r a c k e t : 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 { ) : idem but i n c l u d e s b r a c e s : copy c o n t e n t between b r a c e s : etc . . % Upercase −> t i l l t h e end D o r d $ : d e l e t e t i l l end o f l i n e The same apply f o r c and C, v V $ %% % Replacement r cw : change word bde : d e l e t e c u r r e n t word i n t o t a l l i t y bce : change c u r r e n t word i n t o t a l l i t y ~ : switch uppercase lowercase %% % 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 zM : f o l d a l l za : t o g g l e paragraph f o l d i n g , vim− l a t e x o n l y ? < > : 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 == : a u t o i n d e n t s e l e c t i o n ? = : autoindent l i n e I f on a f i r s t b r a k e t { then : =% w i l l i n d e n t e v e r y t h i n t o t h e matchning bracket I f w i t h i n g a code b l o c k then =a { w i l l work a s w e l l %% % set E. Branlard Paragraph r e f o r m a t i n g t e x t w i d t h =80 0 t o c a n c e l 10 CHAPTER 1. UNIX COMMANDS 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 . . %% % Copy p a s t e c u t p : put a f t e r ( u s e s t h e r e g i s t e r " , i . e . e q u i v a l e n t t o " "p ) 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 "+y e t "+gp ou "+gP c o p i e e n t r e documents ? ? ? ? " 0p : p a s t e t h e r e g i s t e r 0 ( i . e . t h e one t h a t has been yanked ) : reg display r e g i s t e r s %% % 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 hlsearch : nohlsearch / % i n s e r t at beginning of l i n e S e l e c t b e g i n n i n g o f l i n e u s i n g CTR−V then SHIFT+I then type t e x t t o i n s e r t , then ESC ( not CTRL+C) % a t end o f l i n e : :<,> s /$/TEXT/ g b l a bla −$ %% % 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 : 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 % : s o u r c e t h e f i l e you a r e e d i t i n g . i f i t ' s . vimrc , then c o n f i g i s reloaded automatically %% % 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 E. Branlard 11 CHAPTER 1. UNIX COMMANDS : tabc : tabn o r gT : next tab : tabN o r g t : p r e v i o u s tab %% % 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 %% % t h e g command on a c u r r e n t word % go t o d e f i n i t i o n gd gD g * : l o o k f o r t h i s word ( i t s t a r t s i m m e d i a t e l y . . s o u s e CTRL−O t o go t o previous position ) %% % 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 %% % Command h i s t o r y i n many s i t u a t i o n s , a b e t t e r s o l u t i o n i s t h e command− l i n e window which you can open i n two ways : Type q : f o r commands , o r q / f o r s e a r c h e s ; o r Type : o r / t o s t a r t e n t e r i n g a command o r s e a r c h , then p r e s s t h e ' c e d i t ' key ( d e f a u l t i s C t r l − f : h e l p ' c e d i t ' ) . The advantage o f t h e command− l i n e window i s t h a t you can u s e a l l Vim ' s e d i t i n g power , i n c l u d i n g s e a r c h i n g with ' / ' i n normal mode , o r u s i n g whole − l i n e c o m p l e t i o n ( : h e l p compl−whole − l i n e ) i n i n s e r t mode . A f t e r e d i t i n g a command , you can : P r e s s Enter t o e x e c u t e t h e c u r r e n t l i n e ( and c l o s e t h e command− l i n e window ) ; o r P r e s s C t r l −c t w i c e t o c l o s e t h e command− l i n e window ( c a n c e l ) . 1.3 Vim Colorscheme for : so t e s t s ( : help hi ) $VIMRUNTIME/ s y n t a x / h i t e s t . vim $ 1.4 Vim QuickFix window : cn : go t o next e r r o r : cp : go t o p r e v i o u s e r r o r : cw : open q u i c k f i x window : cope : c l : c l o s e q u i c k f i x window 1.5 Vim-latex E. Branlard 12 CHAPTER 1. UNIX COMMANDS <−−>: p r e s s CTRL−J t o go t o %% % Vim Latexcommands with s w i t c h \ \ l l : compile \ l v : view \ rf : refresh folds %% % Completion <F9> and g r e p i n s t a l l e d %% % SCH SSE SSS SPG Latex i n i n s e r t mode : chapters : sections : sub : paragraph %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> f o r i t e m s EEQ # where I p u t t h e Imaps and some s h o r t c u t s . On windows , i n MyImpas . vim i n the f o l d e r plugin a f t e r / f t p l u g i n / t e x . vim % maths s t u f f s `/ : frac ` 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.6 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 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 ) 1.7 Grep - List of my REGEXP − I n r s i : my t y p i c a l o p t i o n E. Branlard 13 CHAPTER 1. UNIX COMMANDS −s I r n i 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 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 %. * } 1.8 FORLOOPS/ FIND / XARGS and SPACECHARACTERS #! / b i n / bash " Looking f o r " $ 1 echo 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 echo echo # done ; $1 IFS=$SAVEIFS 1.9 TEST E. Branlard 14 CHAPTER 1. UNIX COMMANDS 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.10 TEST - COMPOUND %% % S t r i n g matching [ [ " abc d e f . d , x−−" == a [ abc ] * \ ?d * ] ] ; echo $ ? 1.11 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.12 Shell 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.13 Command FIND - application to 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 E. Branlard 15 CHAPTER 1. UNIX COMMANDS 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 {} \ ; 1.14 Remove consecutive blank lines - duplicate empty line h t t p : // unstableme . b l o g s p o t . com/ 2008 / 12 / remove− d u p l i c a t e −blank − l i n e s −bash − awk . html %% % Way1 : c a t ( 1 ) g i v e s an o p t i o n named −s , −− s q u e e z e −blank which s a y s : n e v e r more than one s i n g l e blank l i n e $ c a t −s f i l e . t x t %% % Way2 : $ awk ' /^$/ { i f ( ! blank++) p r i n t ; next } { blank =0; p r i n t } ' f i l e . t x t 1.15 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 E. Branlard −F= 'NR<10 { f o r ( i =1; i<=NF; i ++){ p r i n t f $i "=" } ; p r i n t " " } ' d r i f t . i n 16 CHAPTER 1. UNIX COMMANDS #p r i n t f "&NEWRUN\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 } 1.16 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 | ^ / " ' 1.17 Patches - apply patch - create patch -reverse patch %apply a patch patch −p1 < / path / t o / f i l e . patch man patch %r e v e r s e a patch patch −R < / path / t o / f i l e . path % c r e a t e a patch d i f f −crB F o l d e r 1 F o r l d e r 2 > F o l d e r . patch E. Branlard 17 CHAPTER 1. UNIX COMMANDS 1.18 Git % download l a t e s t v e r s i o n g i t c l o n e g i t : // g i t . gnome . o r g / e v i n c e g i t branch : l i s t b r a n c h e s g i t branch −a : a l l % c r e a t e a l o c a l branch c o r r e s p o n d i n g t o t h e remote branch g i t c h e c k o u t −b l o c a l −gnome −2−30 r e m o t e s / o r i g i n / gnome −2−30 % s w i t c h t o a s p e c i f i c branch ( u p d a t e s f i l e s ) ( u s e l e s s a f t e r p r e v i o u s command and t h e s w i t c h −b ) g i t c h e c k o u t l o c a l −gnome −2−30 % Make d i r e c t o r y a c c o r d i n g t o t h i s branch %g i t p u l l E. Branlard 18 Chapter 2 Latex 2.1 Install new latex font Go on t h e CTAN page c o n c e r n i n g urw a r i a l and best option ! as root or s t a f f or g e t n o n f r e e f o n t s −s y s g e t n o n f r e e f o n t s −s y s g e t n o n f r e e f o n t s −s y s g e t n o n f r e e f o n t s −s y s read t h e readme , that ' s t h e u s e r ??? −− h e l p −− l s f o n t s a r i a l −urw −− a l l %% % g e t n o n f r e e f o n t s − s y s a r i a l −urw % l o o k now f o r ua1 . map ( sudo updatedb , l o c a t e ua1 . map) p r o b a b l y i n l o c a l / texmf / echo 'Map ua1 . map ' > / e t c / texmf /updmap . d /25− a r i a l update −updmap vim / var / l i b / texmf / web2c /updmap . c f g udpmap− s y s /usr/ texhash updmap −−enable Map u t o p i a . map 2.2 Tkz and gnuplot - problem with gnuplot 4.4 Ed it / u s r / s h a r e / texmf / t e x / g e n e r i c / p g f / modules / p g f m o d u l e p l o t . code . t e x R ep l ac e \ x d e f \ pgf@gnuplot@head#1{ s e t t e r m i n a l t a b l e ; s e t o u t p u t "#1. t a b l e " ; s e t format "%.5 f "} By \ x d e f \ pgf@gnuplot@head#1{ s e t t a b l e ; s e t o u t p u t "#1. t a b l e " ; s e t format "%.5 f "} 2.3 svg2latex 19 CHAPTER 2. LATEX With i n k s c a p e 0.48 − 1 − 2 , no need t o u s e t h e s c r i p t s v g 2 l a t e x . py : i n k s c a p e −z −D −− f i l e =A. svg −−export−pdf=A. pdf −−export− l a t e x B e t t e r , t h i s can be run when t h e f i l e i s changed d i r e c l t y from l a t e x with : an svg i n l u d e d with t h e a d e f i n e d command " i n c l u d e s v g " \newcommand{\ e x e c u t e i f f i l e n e w e r } [ 3 ] { % \ ifnum \ pdfstrcmp {\ p d f f i l e m o d d a t e {#1}}% {\ p d f f i l e m o d d a t e {#2}}>0% {\ immediate \ w r i t e 1 8 {#3}}\ f i% } \newcommand{\ i n c l u d e s v g } [ 1 ] { % \ e x e c u t e i f f i l e n e w e r {#1 . s v g }{#1. p d f } { i n k s c a p e −z −D −− f i l e =#1 . s v g −− e x p o r t −p d f =#1. p d f −− e x p o r t − l a t e x }% \ i n p u t {#1 . p d f_t e x}% } 2.4 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.5 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 } E. Branlard 20 Chapter 3 Debian wheezy with xfce4 3.1 Important stu to do %− Check out my s c r i p t S e t u p S y s t f o r most m o d i f i c a t i o n s r e q u i r e d %− Check t h e p o l i c i e s ( s e e my n o t e on P o l i c i k i t p o l k i t −1 i n t h i s document ) %− s e t Network automount t o f a l s e : sudo vim / u s r / s h a r e / g v f s / mounts / network . mount DBus e r r o r o r g . f r e e d e s k t o p . DBus . E r r o r . I n v a l i d A r g s : Mountpoint Already registered . f i x e d i n : h t t p : // g i t . x f c e . o r g / x f c e / thunar / commit / ?h=x f c e − 4.8&i d= a14345dafd7cb6333317d5ebddf62fbddc946c27 \ %? not t r y i e d : h t t p s : // b u g z i l l a . x f c e . o r g / show_bug . c g i ? i d =7373 Renaming / u s r / s h a r e / g v f s / remote −volume−m o n i t o r s / gdu . monitor t o gdu . monitor . f o o %− o r r e c o m p i l e source ( what I ' ve v i e w t o p i c . php? i d =112184) cd ~/ C o n f i g / b u i l d s mkdir thunar −nonetwork cd thunar −nonetwork apt −g e t source thunar sudo apt −g e t b u i l d −dep thunar done ) : ( h t t p s : // bbs . a r c h l i n u x . o r g / Modify thunar / thunar − s h o r t c u t s −model . c and thunar − t r e e −model . c , and comment t h e two l i n e s : if ( thunar_g_v f s_i s_u r i_scheme_s u p p o r t e d ( " network " ) ) system_p a t h s = g_ l i s t _append ( system_paths , g_ f i l e _new_f o r_u r i ( " network : // " ) ) ; ./configure make sudo make i n s t a l l %−purge exim4 ( maybe u s e ssmtp i n s t e a d , s e e g m a i l ) update − r c . d − f exim4 remove update − r c . d atd remove update − r c . d − f l p d remove update − r c . d − f t i m i d i t y remove update − r c . d − f r s y n c remove 21 CHAPTER 3. DEBIAN WHEEZY WITH XFCE4 update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f update − r c . d − f a p t i t u d e purge b o o t l o g s remove b o o t l o g d remove avahi −daemon remove p r o c p s remove stop −b o o t l o g d − s i n g l e remove stop −b o o t l o g d remove r m n o l o g i n remove r c . l o c a l remove cups remove n e t w o r k i n g remove hddtemp remove mi n i s s d p d %− Modify i n i t t a b comment t h e C t r l − a l t − d e l command, o r l e a v e i t f o r 123 A f t e r d o i n g t h e a u t o l o g i n , you have t o a l l o w anybody t o run t h e x s e r v e r sudo dpkg− r e c o n f i g u r e x11−common 3.2 Rhythmbox problems − b u i l d p l u g i n remember t h e rhythm and i n s t a l l g i r 1 .2 − peas − 1.0 , and python − a l l wouldn ' t h u r t − For c o v e r a r t : i n s t a l l python −g i − c a i r o E. Branlard 22 Chapter 4 Debian squeeze - tweaks - latest updates 4.1 Important stu to do %% % Gamin i n s t e a d o f fam d o e s not work t h a t w e l l a p t i t u d e i n s t a l l gamin %% % m a k e f i l e c o n c u r r e n c y and readahead : a s r o o t a p t i t u d e i n s t a l l readahead readahead − f e d o r a echo CONCURRENCY=m a k e f i l e >> / e t c / d e f a u l t / r c S aptitude i n s t a l l insserv dpkg− r e c o n f i g u r e i n s s e r v sysv − r c %% % new p a g e r 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 %% % flash a p t i t u d e 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 %% % 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 4.2 FlashPlayer - plugin for mozilla i n s t a l l package f l a s h p l u g i n − n o n f r e e For u p g r a d e s : update − f l a s h p l u g i n − n o n f r e e −− i n s t a l l See which v e r s i o n o f f l a s h p l a y e r you have i n s t a l l e d h t t p : //www. adobe . com/ s o f t w a r e / f l a s h / about / 4.3 Chrome - Get latest java working This HOWTO shows how t o g e t Java Runtime r u n n i n g under Google Chrome 1 . Download Java Runtime from h t t p : //www. j a v a . com 2 . Make and opt / d i r e c t o r y i n home 23 CHAPTER 4. DEBIAN SQUEEZE - TWEAKS - LATEST UPDATES CODE: SELECT ALL mkdir ~/ opt 3 . Move t h e Java . b i n f i l e t o ~/ opt / CODE: SELECT ALL chmod +x j r e −6u18−l i n u x −x64 . b i n . / j r e −6u18−l i n u x −x64 . b i n cd ~/ opt / j r e 1 . 6 . 0 _18 / b i n / ControlPanel S e l e c t t h e Java Tab C l i c k View . . . C l i c k Find . . . C l i c k Next . . . S e l e c t ~/ opt / j r e 1 . 6 . 0_18 / C l i c k Next . . . C l i c k Finsh . . . d e s e l e c t t h e o t h e r s JREs C l i c k OK . . . C l i c k Apply . . . C l i c k OK . . . 4 . As r o o t CODE: SELECT ALL mkdir / opt / g o o g l e / chrome / p l u g i n s cd / opt / g o o g l e / chrome / p l u g i n s l n − s ~/ opt / j r e 1 . 6 . 0_18 / l i b / amd64 / l i b n p j p 2 . s o 5 . Run Google Chrome with p l u g i n s e n a b l e d CODE: SELECT ALL g o o g l e −chrome −−enable− p l u g i n s %U Add o p t i o n : a l l o w −outdated − p l u g i n s have t h e l a t e s t v e r s i o n if chrome i n s i s t s i n s a y i n g you don ' t 4.4 Compiling evince 2.31 on debian squeeze Get source : g i t c l o n e g i t : // g i t . gnome . o r g / e v i n c e Dependencies i n s t a l l gnome−common gtk −doc − t o o l s libgnome −k e y r i n g −dev l i b d b u s −1−dev l i b d b u s − g l i b −1−dev l i b p o p p l e r −dev l i b p o p p l e r − g l i b −dev autogen . sh −− d i s a b l e − n a u t i l u s Platform . . . . . . . . . . . : gnome GConf Support . . . . . . : yes GTK+ Unix P r i n t . . . . : yes Keyring Support . . . . : yes DBUS Support . . . . . . . : yes SM c l i e n t s u p p o r t . . : xsmp Nautilus Plugin . . . . : Thumbnailer . . . . . . . . : E. Branlard no yes 24 CHAPTER 4. DEBIAN SQUEEZE - TWEAKS - LATEST UPDATES Previewer . . . . . . . . . . : Gtk−Doc Support . . . . : Debug mode . . . . . . . . . : GObj . I n t r o s p e c t i o n : Tests . . . . . . . . . . . . . . : yes no no no yes PDF Backend . . . . . . . . : P o s t S c r i p t Backend . : TIFF Backend . . . . . . . : DJVU Backend . . . . . . . : DVI Backend . . . . . . . . : P ix bu f Backend . . . . . : Comics Backend . . . . . : I m p r e s s Backend . . . . : yes no yes yes no no yes no 4.5 Compiling inkscape 0.48 for debian squeeze i n s t a l l f o l l o w i n g p a c k a g e s : i n t l t o o l l i b p n g −dev l i b g c −dev l i b f r e e t y p e 0 6 − dev l i b l c m s −dev libgtkmm −2.4 − dev l i b x s l t −dev l i b g s l 0 −dev l i b b o o s t −dev l i b p o p t −dev libwpg −dev l i b m a g i c k++−dev run . / c o n f i g u r e and l o o k a t what i t s a y s . I might have m i s p e l l e d some packages . . make sudo make i n s t a l l 4.6 Xfce4.8 on debian squeeze h t t p : // ahwhattheheck . w o r d p r e s s . com/ 2011 / 07 / 06 / x f c e 4 −8s q u e e z e / apt −g e t i n s t a l l g c c gcc − m u l t i l i b a u t o c o n f automake1 . 9 \ l i b t o o l f l e x b i s o n gdb gcc −4.4 − m u l t i l i b l i b m u d f l a p 0 −4.4 − dev \ gcc −4.4 − l o c a l e s l i b g c c 1 −dbg libgomp1 −dbg l i b m u d f l a p 0 −dbg \ l i b c l o o g −p p l 0 l i b p p l −c2 l i b p p l 7 automake make gnu−s t a n d a r d s \ b u i l d − e s s e n t i a l i n t l t o o l python −g o b j e c t −dev l i b d b u s −1−dev \ l i b d b u s − g l i b −1−dev xorg −dev l i b x 1 1 −dev l i b g t k 2 .0 − dev l i b g l a d e 2 −dev \ libwnck −dev l i b g u d e v −1.0 − dev l i b n o t i f y −dev l i b g s t r e a m e r 0 .10 − dev \ l i b g h c 6 −g s t r e a m e r −dev l i b k e y b i n d e r −dev E. Branlard 25 Chapter 5 APPPLICATIONS 5.1 xrandr - arandr - Dynamic Multiple screens - xinerama a r a n d r i s a g r a p h i c a l t o o l f o r xrandr make a c o n f i g u r a t i o n and export i t a s a s c r i p t . x=` xrandr −−query | g r e p 1920 | wc − l ` ; 5.2 Download google books Greasemonkey s c r i p t This i s t h e most p o w e r f u l and s t a b l e way t o download Google Book . You can e a s i l y download any book from books . g o o g l e . com u s i n g Greasemonkey s c r i p t . J u s t f o l l o w t h e s i m p l e s t e p s below . This hack o n l y works with f i r e f o x b r o w s e r . Make s u r e you i n s t a l l f i r e f o x browser . Now i n s t a l l Greasemonkey S c r i p t and then i n s t a l l Google book downloader u s e r s c r i p t . I n s t a l l F l a s h g o t t o f i r e f o x b r o w s e r and r e s t a r t your f i r e f o x b r o w s e r . S e a r c h any book on books . g o o g l e . com and you ' l l n o t i c e a download button a t t h e s i d e b a r a s shown i n s c r e e n s h o t . C l i c k t h e download button t o download t h e images o f each . S e l e c t t h e p a g e s you wish t o download and then r i g h t c l i c k and s e l e c t FlashGot S e l e c t i o n t o download t h e s e l e c t e d p a g e s . %% %S c r i p t topdf %! ! ! Might have problem with D i r e c t C l a s s PseudoClass e t c , u s e : c o n v e r t −page A4 − u n i t s P i x e l s P e r I n c h − d e n s i t y 100 f i l e s * . png f i l e . pdf %! ! ! watch out for the f i l e s that are a c t u a l l y jpeg . . 5.3 Thunderbird with calendar - Debian squeeze i c e d o v e i c e o w l −e x t e n s i o n 26 CHAPTER 5. APPPLICATIONS 5.4 Vmail - gmail in vim has r e c e n t d e p e n d e n c i e s 5.5 Vimperator - plugin to use vi in refox B a s i c motions from vim work : h j k l C−u C−d gg G C−b C− f C−e C−y C−p C−n : go from one tab t o t h e o t h e r R : refresh C: c a n c e l C− i : next C−o : p r e v i o u s d : d e l e t e tab f o r F : a c t i v a t e h i n t s ( numbered l i n k s ) F : w i l l open i n new tab / n : search N : go through s e a r c h r e s u l t s / : o g o o g l e s e a r c h i n c u r r e n t window : t g o o g l e s e a r c h i n new tab 5.6 Use Vi mode in bash ###B a s i c s In your . b a s h r c : s e t −o v i When t y p i n g a command, p r e s s ESC o r CTRL− [ t o go t o v i mode ###For o t h e r t e r m i n a l app in the . inputrc f i l e : set set set e d i t i n g −mode v i keymap v i c o n v e r t −meta on ### Tips P r e s s i n g # anywhere w h i l e i n command mode w i l l make t h e command a comment so t h a t you can a c c e s s i t l a t e r More : h t t p : //www. j u k i e . n e t / b a r t / b l o g / 20040326082602 man 3 r e a d l i n e 5.7 Playlists - Format - Conversions - Rhythmbox - Solving the problem of moved les E. Branlard 27 CHAPTER 5. APPPLICATIONS Formats : m3u : j u s t a l i s t o f f i l e l o c a t i o n , Comments a l l o w e d with # x f p f : a s t a n d a r d xml Rhythmbox u s e s i t s own xml format f o r p l a y l i s t s . Backup t h e p l a y l i s t f i l e : ~/ . s h a r e / rhythmbox / p l a y l i s t s . xml Thanks t o python s c r i p t s found h e r e h t t p : // ubuntuforums . o r g / showthread . php ? t =1740610 you can c o n v e r t rhythmbox xml f i l e t o a l i s t s o f m3u f i l e s ### Content o f f i l e r h y t h m b o x p l a y l i s t 2 e x a i l e : #! / u s r / b i n / python import os , s t r i n g marker = 0 marker2 = 0 orderlist = [] a = open ( ' p l a y l i s t s . xml ' , ' r ' ) i f not o s . path . e x i s t s ( " p l a y l i s t s " ) : o s . makedirs ( " p l a y l i s t s " ) os . chdir ( " p l a y l i s t s " ) z = open ( ' o r d e r_ f i l e ' , 'w' ) for l i n e in a . x r e a d l i n e s ( ) : i f marker == 1 : i f l i n e . f i n d ( ' < l o c a t i o n > ') != −1 and l i n e . r f i n d ( ' < / l o c a t i o n > ') − 1: l i n e = l i n e [ l i n e . f i n d ( ' < l o c a t i o n > ') + 1 0 : ] l i n e = l i n e [ : l i n e . f i n d ( ' < / l o c a t i o n > ') ] l i n e = s t r i n g . r e p l a c e ( l i n e , '& ; ' , '& ' ) i f marker2 == 0 : m = open ( name + '. p l a y l i s t ' , 'w' ) z . w r i t e ( name+'\n ' ) marker2 = 1 m. w r i t e ( l i n e +'\n ' ) e l i f l i n e . f i n d ( ' < / p l a y l i s t > ') != − 1: i f marker2 == 0 : != continue m. w r i t e ( 'EOF\n ' ) m. w r i t e ( ' random_e n a b l e d=B : F a l s e \n ' ) m. w r i t e ( ' random_mode=S : t r a c k \n ' ) m. w r i t e ( ' r e p e a t_e n a b l e d=B : F a l s e \n ' ) m. w r i t e ( ' r e p e a t_mode=S : p l a y l i s t \n ' ) m. w r i t e ( ' dynamic_e n a b l e d=B : F a l s e \n ' ) m. w r i t e ( ' c u r r e n t_pos=I : −1\n ' ) m. w r i t e ( ' name=U: '+name+'\n ' ) m. w r i t e ( '_i s_custom=B : True \n ' ) m. w r i t e ( '_n e e d s_s a v e=B : F a l s e \n ' ) m. c l o s e ( ) marker = 0 marker2 = 0 e l i f l i n e . f i n d ( ' < p l a y l i s t name=" ' ) != − 1: i f l i n e . r f i n d ( ' / > ') == − 1: l i n e = l i n e [ l i n e . f i n d ( ' < p l a y l i s t name=" ' ) + 1 6 : ] line = line [ : line . find ( ' " ') ] l i n e = s t r i n g . r e p l a c e ( l i n e , '& ; ' , '& ' ) name = l i n e marker = 1 a . close () E. Branlard 28 CHAPTER 5. APPPLICATIONS z . w r i t e ( 'EOF\n ' ) z . close () 5.8 Send email with attachment using the shell #mail : s i m p l e e m a i l s m a i l − s "SUBJECT" to@serv . com < m a i l . t x t #mutt : e m a i l s w i t h a t t a c h m e n t s echo " t e x t " | mutt −a FILE − s SUBJECT −− to@serv . com #mail+uencode : can send a t t a c h m e n t s smtp o r s e n d m a i l can be used t o send m a i l s . An e a s y way c o n s i s t s i n u s i n g an e x i s t i n g g m a i l a c c o u n t with smtp : h t t p : //www. webupd8 . o r g / 2009 / 11 / use −gmail −to −send −e m a i l s −from − t e r m i n a l . html See my s c r i p t Check for s e n d i n g e x t e r n a l e m a i l s with Thunar . / var / l o g / m a i l . log for errors 5.9 Mp3 tag from lenamejwith tagtool 5.10 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 {} \ ; 5.11 xls2csv command among o t h e r t o o l from package " c a t d o c " 5.12 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 : E. Branlard 29 CHAPTER 5. APPPLICATIONS 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 ` 5.13 R - Bypass user le R −−no− i n i t − f i l e 5.14 Iceweasel Backspace to go back one page about : c o n f i g i n t h e a d r e s s bar f i l t e r for backspace s e t t h e b r o w s e r . b a c k s p a c e_a c t i o n v a l u e t o 0 . type 5.15 Congure pulseaudio for Debian - Iceweasel Soud problem Curent c o n f i g , t h a t seem t o work : For skype pulse pulse pulse %% % Pulse input device I n t e r n a l Audio Analog S t e r e o −> Analog L in e In ( s e t a s f a l l b a c k ? ? ? , don ' t put i t t o s i l e n c e ! ! ! ! ) ( With h e a d s e t Analog Microphone w i l l work ) %% %% %% % %% % / e t c / p u l s e / daemon . high − p r i o r i t y = y e s nice − l e v e l = −11 conf r e a l t i m e −s c h e d u l i n g = y e s r e a l t i m e −p r i o r i t y = 5 %% % Xfce a p p l i c a t i o n a u t o s t a r t I desactivate pulseaudio %% % Daemon s t a r t e d a t boot ( w i l l warn b e c a u s e o f p e r u s e r s e t t i n g s ) / e t c / i n i t . d/ p u l s e a u d i o ( update − r c . d p u l s e a u d i o d e f a u l t s ) % The o t h e r o p t i o n i s not t o s t a r t t h e daemon a t boot , and u s e x f c e autostart . % As i t i s , t h e sound w i l l be such t h a t skype g o e s c u t s rhythmbox . I t was not l i k e t h i s b e f o r e . . I t ' s p r o b a b l y b e c a u s e now they go through / u s r / l i b / i 3 8 6 −l i n u x −gnu / l i b s n d f i l e . s o %% %# 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 . There a r e two o p t i o n s : − Use a mixer between t h e a p p l i c a t i o n and t h e hardware ( p u l s e a u s i o , o r jack ) − Use t h e hardware mixer with an p p l i c a t i o n l i k e dmix p r o v i d e d a l s a 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 . E. Branlard 30 CHAPTER 5. APPPLICATIONS P u l s e a u d i o , s t a r t s by d e f a u l t , if 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 ! / Below I g i v e my s o l u t i o n , but I r e c e n t l y d i s c o v e r e d t h i s o f f i c i a l page t h a t c o u l d h e l p ( though i t made t h i n g s worse f o r me do t o t h e g s t r e a m e r c o n f i g u r a t i o n ) : h t t p : // p u l s e a u d i o . o r g / w i k i / P e r f e c t S e t u p %% % 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 n o t e f o r upgrade : sudo update − f l a s h p l u g i n − n o n f r e e −− i n s t 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 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 { E. Branlard 31 CHAPTER 5. APPPLICATIONS type } pulse pcm . ! d e f a u l t { type p u l s e # I f d e f a u l t s . namehint . s h o w a l l i s s e t t o o f f i n a l s a . conf , t h e n t h i s is # n e c e s s a r y t o make t h i s pcm show up i n t h e l i s t r e t u r n e d by # snd_d e v i c e_name_h i n t or a p l a y −L h i n t . d e s c r i p t i o n " D e f a u l t Audio D ev ic e " } ctl . ! default { type p u l s e } Note , I added t h e f o l l o w i n g s u r e i t was u s e f u l l : #pcm . dmixout { # type pulse #} for skype , but then I commented i t , I 'm not 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 . %% % Wait , now I 'm having a t r o u b l e , rhythmbox d o e s not l a u n c h p u l s e a u d i o by i t s e l f On some w e b s i t e they a d v i s e t o c o n f i g u r e g s t r e a m e r t o s e t i t t o u s e p u l s e s i n k and p u l s e r s r c . But t h i s a c t u a l l y made t h i n g s c r a s h f o r me , rhythmbox o r totem won ' t s t a r t p u l s e a u t o m a t i c a l l y . %What they s u g g e s t s and t h a t make t h i n g s didn ' t work ( maybe I 'm m i s s i n g a package o r something ) : g c o n f t o o l −2 − t s t r i n g −−s e t / system / g s t r e a m e r / 0 . 1 0 / d e f a u l t / a u d i o s i n k pulsesink g c o n f t o o l −2 − t s t r i n g −−s e t / system / g s t r e a m e r / 0 . 1 0 / d e f a u l t / a u d i o s r c pulsesrc g c o n f t o o l −2 − t s t r i n g −−s e t / system / g s t r e a m e r / 0 . 1 0 / d e f a u l t / m u s i c a u d i o s i n k pulsesink %What worked f o r me i s t o s e t e v e r y t h i n g a s auto g c o n f t o o l −2 − t s t r i n g −−s e t / system / g s t r e a m e r / 0 . 1 0 / d e f a u l t / a u d i o s i n k autoaudiosink f c o n f t o o l −2 − t s t r i n g −−s e t / system / g s t r e a m e r / 0 . 1 0 / d e f a u l t / a u d i o s r c autoaudiosrc g c o n f t o o l −2 − t s t r i n g −−s e t / system / g s t r e a m e r / 0 . 1 0 / d e f a u l t / m u s i c a u d i o s i n k autoaudiosink %% % E. Branlard 32 CHAPTER 5. APPPLICATIONS 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 Does i t work ?? %% % advanced s e t u p s pacmd l i s t − s i n k s pacmd s e t −d e f a u l t −s i n k 1 5.16 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 5.17 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 5.18 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) E. Branlard 33 CHAPTER 5. APPPLICATIONS − 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 ) − 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 E. Branlard 34 CHAPTER 5. APPPLICATIONS " 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 " InfoKey : Author " > i n . i n f o " 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 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 " echo echo E. Branlard 35 CHAPTER 5. APPPLICATIONS rm 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 − r f pg_*_ f i l e s %% % 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 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 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 E. Branlard pg_0 0 0 1 . png pg_0 0 0 4 .bmp 36 CHAPTER 5. APPPLICATIONS hocr2pdf hocr2pdf hocr2pdf hocr2pdf −i −i −i −i pg_0 0 0 1 .bmp pg_0 0 0 1 . t i f pg_0 0 0 1 . png pg_0 0 0 1 . png h o c r 2 p d f − i pg_0 0 0 1 . png −n −n −n −n −s −s −s −s −o −o −o −o out_0 0 0 1 . pdf out_0 0 0 2 . pdf out_0 0 0 3 . pdf 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" 5.19 Antivirus for linux- ClamAV - freshclam a p t i t u d e i n s t a l l clamav 5.20 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 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 %% % E. Branlard More ??? 37 CHAPTER 5. APPPLICATIONS . / 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 5.21 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 5.22 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 * 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 * 5.23 Fuseiso - Monter iso facilement- thunar shortcut a d d u s e r manu f u s e ##Mounting command : E. Branlard 38 CHAPTER 5. APPPLICATIONS 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 5.24 Meld : File/Folder comparison- thunar shortcut meld %F 5.25 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 ) 5.26 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 . . . 5.27 Snapshot - Capture d'ecran x f c e 4 −s c r e e n s h o o t e r 5.28 FOR LOOPS/ FIND / XARGS and SPACE CHARACTERS -> Find in PDF E. Branlard 39 CHAPTER 5. APPPLICATIONS 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 "−−−−−−−−−−−−−−−−−−−−−−−−−−−−" "$ 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 5.29 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échargé 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 ' exécuter . #chmod +x j r e −6u1− l i n u x −i 5 8 6 . b i n J ' a i exécuté 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 créé . J ' a i déplacé 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 applications utilisateurs propriétaires . #mv − f j r e 1 . 6 . 0_01 / / o p t / E. Branlard 40 CHAPTER 5. APPPLICATIONS J ' a i a jo 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 s u i v a n t e s : #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 Création 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 / 5.30 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 ) . 5.31 Firefox / iceweasel slow, tweak it %% % about : c o n f i g dans l a b a r r e d ' a d d r e s s e #network . dns . d i s a b l e I p v 6 d e s a c t i v e r l ' Ipv6 #Create new Boolean v a l u e s e t t o t r u e : c o n f i g . t r i m_on_minimize t o r e l e a s e memory when i c o n i f i e d , r i s k y #Create new I n t e g e r v a l u e s e t t o 0 : n g l a y o u t . i n i t i a l p a i n . d e l a y to i n s t a n t a t e o u s l y show page #s e t b r o w s e r . cache . memory . c a p a c i t y t o a f i x e d s i z e ( t h e d e f a u l t v a l u e s are : f o r 256 MB RAM − 14336 , 512 MB RAM − 22528 , 1 GB RAM − 32768) . A good value to t r y i s 16384. #s e t b r o w s e r . s e s s i o n h i s t o r y . max_t o t a l_v i e w e r s t o 0 #change image . animation_mode t o none or once #b r o w s e r . s e s s i o n h i s t o r y . max_e n t r i e s s e t i t t o 5 %% % T o o l s / Options . t h e d i s k c a c h e memory t o a low v a l u e ( l e s s than 50 MB) t u r n o f f Java t r y t o a v o i d t h e s e e x t e n s i o n s : Adblock , F a s t e r f o x , IE Tab , S e s s i o n Saver . Use Adblock Plus i n s t e a d o f Adblock . don ' t u s e more than 5 e x t e n s i o n s set 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 ) 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 ) ; / E. Branlard 41 CHAPTER 5. APPPLICATIONS 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 5.32 PDF Croping - suppression d'espace de marges % Now, I 'm u s i n g b l i s s a j a v a a p p l i c a t i o n #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 . #c o n v e r t − crop 950 x1160 +280+160 +r e p a g e x . png y , png 5.33 Renommage massif unix ca depend de l a v e r s i o n de rename rename " s /mp4/mp3/ g " * . mp4 E. Branlard 42 CHAPTER 5. APPPLICATIONS 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 5.34 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 | 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 E. Branlard 43 CHAPTER 5. APPPLICATIONS 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 5.35 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 ur s if 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 . 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échargement 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éponse 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échargé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échargement l e quota s e r a dépassé , 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é ) E. Branlard 44 CHAPTER 5. APPPLICATIONS −X : e x c l u r e un r à © p e r t o i r e 5.36 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 5.37 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 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 #Animation G i f c o n v e r t − d e l a y 20 − l o o p 0 s p h e r e * . png a n i m a t i o n . g i f animate * . g i f c o n v e r t f i g 1 3 . png − c r o p 1530 x1210+75+95 test . png mkdir mkdir mkdir mkdir 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 m o g r i f y − r e s i z e $ s i z e −path . . /$ s i z e /$ f o l d * . png export s i z e =24x24 E. Branlard 45 CHAPTER 5. APPPLICATIONS mkdir . . /$ s i z e /$ f o l d m o g r i f y − r e s i z e $ s i z e −path . . /$ s i z e /$ f o l d * . png export s i z e =32x32 mkdir . . /$ s i z e /$ f o l d m o g r i f y − r e s i z e $ s i z e −path . . /$ s i z e /$ f o l d * . png export s i z e =48x48 mkdir . . /$ s i z e /$ f o l d m o g r i f y − r e s i z e $ s i z e −path . . /$ s i z e /$ f o l d * . png 5.38 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 5.39 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 5.40 dos2unix : package tofrodos C o n v e r t i t un p o i n t bat 5.41 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 5.42 WICD pour remplacer Gnome Netwok Manager a p t i t u d e i n s t a l l wicd 5.43 Installer un nouveau pager : most b e t t e r than more o r l e s s 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 , grâce à 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 . E. Branlard 46 CHAPTER 5. APPPLICATIONS # 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 . 5.44 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 5.45 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 5.46 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 " alias alias E. Branlard 47 CHAPTER 5. APPPLICATIONS a l a r m a n i a c=" j a v a − j a r alarmaniac . j a r " alias / 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 / 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 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 5.47 RAW photo images nikon .NEF ufraw −−out −type j p g −− c o m p r e s s i o n 90 * .NEF E. Branlard 48 Chapter 6 Xorg - clavier souris touchpad 6.1 Starting dierent x servers by c h a n g i n g x i n i t r c , one can open d i f f e r e n t d e s k t o p manager a t t h e same time s t a r t x −− : 1 ( by d e f a u l t , s t a r t x u s e s s c r e e n 0 ) 6.2 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 6.3 Xorg ou/et HAL Xorg u t i l i s e d e s o r m a i s HAL pour déterminer l a c o n f i g u r a t i o n . Ce q u i a pour conséq uences : * 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érer 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 f o n c t i o n n e r a . %U t i l i s e r xorg . conf , comme avant 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 " 49 CHAPTER 6. XORG - CLAVIER SOURIS TOUCHPAD 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 / 6.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 6.5 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 E. Branlard 50 CHAPTER 6. XORG - CLAVIER SOURIS TOUCHPAD 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 6.6 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 %% %% %%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 6.7 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 6.8 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 ' 6.9 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 . . . E. Branlard 51 CHAPTER 6. XORG - CLAVIER SOURIS TOUCHPAD # 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 # D i s a b l e DPMS x s e t +dpms # Enable DPMS xset s o f f # Disable screen blanking x s e t s 150 # Blank t h e s c r e e n a f t e r 150 s e c o n d s x s e t dpms 300 600 900 # S e t s t a n d b y , suspend , & o f f t i m e s ( i n seconds ) x s e t dpms f o r c e standby # I m m e d i a t e l y go i n t o s t a n d b y mode x s e t dpms f o r c e suspend # I m m e d i a t e l y go i n t o suspend mode x s e t dpms f o r c e o f f # I m m e d i a t e l y t u r n o f f t h e monitor 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 52 Chapter 7 XFCE - xfce4 7.1 Important xfce folders ~/ . c o n f i g /xfce4/panel c o n f i g / x f c e 4 / x f c o n f /−−−−/ x f c e 4 −p a n e l . xml ~/ . 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 ~/ . c o n f i g / Thunar / uca . xml %custom a c t i o n s ~/ . c o n f i g / Thunar / a c c e l s . scm %s h o r t c u t s ~/ . c a c h e / s e s s i o n s ~/ . c o n f i g / u s e r − d i r s . c o n f ~/ . 7.2 Remember where xfce4-panel layout is stored % REMEBMBER: Always do change on t h e f i l e s when X i s not r u n n i n g ( x f c e ) % Things have changed now , x f c e −p a n e l a p p l e t s a r e more and more c o n f i g u r e s through t h e xlm f i l e . In t h e f o l d e r panel , t h e r e i s j u s t s t u f f l i k e q u i c k l a u n c h e r . That ' s way b e t t e r . . % There i s t h e d i r e c t o r y ~/ . c o n f i g / x f c e 4 / p a n e l but t h e r e i s a l s o ~/ . c o n f i g / x f c e 4 / x f c o n f /−−−−/ x f c e 4 − p a n e l . xml The l a t t e r d e f i n i n g t h e l a y o u t ! ! ! ! 7.3 Disable roll up of windows with mousewheel x f c o n f −query −c xfwm4 −p / g e n e r a l / mousewheel_r o l l u p −s false 7.4 Tiling with xfwm4 %% % With Pywo Now t h e b e s t f o r me i s d e f i n i t e l y pywo with xinerama : a c t s l i k e w i n s p l i t revolution For pure t i l i n g , a g e n c i n g a l l windows on s c r e e n a u t o m a t i c a l l y : u s e p y t y l e 53 CHAPTER 7. XFCE - XFCE4 pywo g r i d_width −g R −w H −h F −−xinerama pywo g r i d_width −g TL −w H −h F −−xinerama pywo put −p L ; pywo put −p R; %% % THUNAR TILING ( when you go on an edge ) Download patch on t h i s w e b s i t e ( I s t o r e d i t ) h t t p : // n o t a n o t h e r s h e e p . com/ XFCE4WindowTiling built apt −g e t source xfwm4 apt −g e t b u i l d −dep xfwm4 cp whatever −path / x f w m 4 t i l i n g . patch . / patch −p0 < x f w m 4 t i l i n g . patch cd xfwm4 − 4 . 8 . 3 ./configure make sudo make i n s t a l l cd I f you have s e v e r a l workspace , i t won ' t work w e l l x f c e s e t t i n g s / Windows Manager / Advanced / Don ' t wrap w o r k s p a c e s %% % With wmctrl ( f o r m e r s t u f f ) sudo a p t i t u d e i n s t a l l wmctrl % example 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 Modify d i r e c t l y t h e keyboard s h o r t c u t s . 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 %% % With Compiz ( o l d i n f o s ) 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" . 7.5 Accessing les on the desktop without having to go to the desktop E. Branlard 54 CHAPTER 7. XFCE - XFCE4 My s o l u t i o n : i n s t a l l x f c e 4 − x f a p p l e t and f i l e −browser − a p p l e t 7.6 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> 7.7 Understanding Mimetypes ~/ . l o c a l / s h a r e / ~/ . l o c a l /mime 7.8 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 ; E. Branlard 55 CHAPTER 7. XFCE - XFCE4 fi 7.9 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 7.10 Thunar - Congure shortcuts Go t o Xfce p r e f e r e n c e s / Appearence / S e t t i n g s and enable e d i t a b l e shortcuts Then i n thunar , pop−up one menu from t h e menu bar , when you hover an a c t i o n you can e d i t t h e s h o r t c u t by s i m p l y p r e s s i n g t h e k e y b i n d i n g you want . r e s s i n g b a c k s p a c e e r a s e i t . Some s h o r t c u t s a r e s t o r e d i n : c o n f i g / Thunar / a c c e l s . scm / home /manu/ . 7.11 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 7.12 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 7.13 XFCE Default User directories - Thunar Templates %% % Easiest e d i t ~ . c o n f i g / u s e r −d i r s . c o n f This i s i m p o r t a n t f o r t e m p l a t e s ! ! ! I don ' t l i k e them i n my home , I l i k e them b e t e t r i n my . c o n f i g / Templates Requires relogging E. Branlard 56 CHAPTER 7. XFCE - XFCE4 %O t h e r w i s e D e f a u l t t e m p l a t e d i r e c t o r y i s ~/ Templates %% % System wide See : / e t c / xdg / u s e r − d i r s . c o n f 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 . . . 7.14 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 7.15 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 ` E. Branlard 57 CHAPTER 7. XFCE - XFCE4 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 . DISPLAY=:0 SESSION_MANAGER=" l o c a l /$HOST: /tmp/ . ICE−unix /$SESSION_ID" / u s r / b i n / x f c e 4 − s e s s i o n −logout 7.16 Xubuntu xfce saved session malgré l a c a se décoché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 paramètres 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 s e s s i o n . 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 édité 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 7.17 Sound mixing - xfce4-volumed - amixer - pulseaudio %% % Now My c u r e n t o p t i o n : x f c e −volumed f o r + and − , and a p e r s o n n a l s c r i p t f o r mute / unmute I had t o c o m p i l e my own x f c e 4 −volumed t o d e s a c t i v a t e t h e grab on mute key % x f c e −volumed Mute / unmute not c o m p a t i b l e with p u l s e a u d i o . See o p t i o n c o m p i l e above . %% % Former o p t i o n % with 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 E. Branlard 58 CHAPTER 7. XFCE - XFCE4 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 %% % Way b e f o r e − I used keytouch 7.18 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 E. Branlard 59 Chapter 8 SYSTEM 8.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 8.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 8.3 Heure machine exact - NTP daemon i n s t a l l e r ntp 8.4 Increase password strength with PAM cracklib or passwdqc a p t i t u d e i n s t a l l libpam −passwdqc 8.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} ] " %% % For i n s t a n c e , what I ' ve donee : l o g_b e g i n_msg ( ) { 60 CHAPTER 8. 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 8.6 Nettoyage des log automatique 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 8.7 Informations systeme lspci lsusb 8.8 Addressse MAC E. Branlard 61 CHAPTER 8. SYSTEM sudo i f c o n f i g Regarder a p r e s HWaddress 8.9 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 8.10 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 8.11 ANSI Escape sequences - escape codes for bashrc and login 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 E. Branlard 62 CHAPTER 8. SYSTEM 8.12 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 8.13 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 . #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 8.14 Use aptitude - Utiliser aptitude - liste de paquets - dpkg - apt-get - Manage Packages - package list #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 # I n s t a l l s o u r c e p a c k a g e s ( as u s e r p r e f e r a b l y ) ! ! ! apt −g e t source PACKAGE # I n s t a l l dependencies to b u i l d the sources ! ! ! apt −g e t b u i l d −dep PACKAGE %% % DPKG − % package i n s t a l l e d dpkg − l % Output a l l p a c k g e s i n s t a l l e d , and u s e t h i s l i s t t o r e s t o r e a system install dpkg −−get − s e l e c t i o n s > l i s t e . dpkg dpkg −−s e t − s e l e c t i o n s < l i s t e . dpkg # p a c k a g e l i s t per r e p o s i t o r y / l i s t e de p a q u e t s par r e p o s i t o r y , ( r e q u i r e s t o i n s t a l l apt −show− v e r s i o n s ) apt −show− v e r s i o n s | g r e p u n s t a b l e apt −show− v e r s i o n s | g r e p −v s q u e e z e apt −c a c h e p o l i c y a p t i t u d e s e a r c h " ? i n s t a l l e d ? o r i g i n ( Debian ) " E. Branlard 63 CHAPTER 8. SYSTEM %% % when a package r e a l l y i s i m p o s s i b l e t o c o n f i g u r e − Try t h e f o r c e o p t i o n o f apt −g e t / remove − e d i t / var / l i b / s t a t u s , and remove t h e e n t r y c o r r e s p o n d i n g a t t h e package . CAREFUL ! ! ! ! ! ! ! ! ! ! ! ! ! Do Backups ! dpkg −L package : t o l i s t t h e f i l e s c o n c e r n e d by t h i s package ##A p t i t u d e 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 8.15 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 8.16 Command to reload fstab #t o r e l a o d mount −a / e t c / mtab and /etc/fstab 8.17 Changer le nom de votre machine, change hostname sudo vim E. Branlard / e t c / hostname 64 CHAPTER 8. SYSTEM 8.18 Rendre clef USB amorcable - install distribution iso from usb bootable %% % Simple o p t i o n Simply u s e UNetbootin ( m u l t i p l a t f o r m , e x i s t s a s a l i n u x package ) %% % More advance , format p a r t i t i o n s , and make i t b o o t a b l e 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 % p u t t i n g s y s l i n u x ( f o r 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 8.19 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 E. Branlard test .c @ 1 . 6 0GHz) 3 script C 65 CHAPTER 8. SYSTEM #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 8.20 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 aisément à ª t r e créé 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 . 8.21 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 # 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 8.22 Make your own init script - launching scripts at boot - init.d E. Branlard 66 CHAPTER 8. SYSTEM 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 lancé , 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 lancé à c e s t a d e du démarrage . . . ) 8.23 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 8.24 Congurer son reseau a la main #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 8.25 Conversion UTF8 ISO-8859-1 E. Branlard 67 CHAPTER 8. SYSTEM 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 e t 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 e t 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 . 8.26 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 8.27 Restaurer une installation Debian - Restore Debian install Package list 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) ' / var / c a c h e / apt / 8.28 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 8.29 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 : E. Branlard 68 CHAPTER 8. SYSTEM %sudo ALL=(ALL) ALL s a n s password : %sudo ALL=NOPASSWD: ALL 8.30 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 8.31 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 / s b i n / g e t t y −n 38400 t t y 1 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 E. Branlard 69 CHAPTER 8. SYSTEM 8.32 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 . 8.33 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 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 70 Chapter 9 FILESYSTEMS, UTILISATEURS, GROUPES, DROITS 9.1 Policykit - local authority - rights for reboot, mount usb etc.. C o n s o l e k i t i n wheezy d o e s not behave w e l l with s t a r t x , i t ' s p r o b a b l y a matter o f t h e s e s s i o n b e i n g a c t i v e o r not Ether go back t o t h e s q u e e z e v e r s i o n , o r manage t h e p o l i c y k i t y o u r s e l f by c r e a t i n g . pkla f i l e s in the f o l d e r / e t c / p o l k i t −1/ l o c a l a u t h o r i t y /50− l o c a l . d ( that ' s t h e f o l d e r t h e most a p p r o p r i a t e f o r our u s e ) % Info : man p k l o c a l a u t h o r i t y ls /usr/share/polkit −1/ a c t i o n s / % S l e e p and h i b e r n a t i o n c r e a t e a f i l e , say 10− upower . p k l a with [ upower ] I d e n t i t y=unix − u s e r : * Action=o r g . f r e e d e s k t o p . upower . * ResultAny=y e s % mounting d r i v e s [ udisks ] I d e n t i t y=unix − u s e r : * Action=o r g . f r e e d e s k t o p . u d i s k s . * ResultAny=y e s % shutdown , r e b o o t [ stop ] I d e n t i t y=unix − u s e r : manu Action=o r g . f r e e d e s k t o p . c o n s o l e k i t . system . s t o p ResultAny=y e s [ restart ] I d e n t i t y=unix − u s e r : manu Action=o r g . f r e e d e s k t o p . c o n s o l e k i t . system . r e s t a r t ResultAny=y e s 71 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS 9.2 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 l e t t r e s ( s i l e 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 façon 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 programme exécuté o SGID = 2000 − l e p r o c e s s u s 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 a p p a r t i e n n e n t au groupe a l e s d r o i t s du p r o p r i à © t a i r e du a l e s d r o i t s du groupe du programme 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 du r à © p e r t o i r e 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 lancé 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 E. Branlard 72 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS Pour connaître 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 cré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 exécuté 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 accordé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 ' exécute 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 f i c h i e r s e r a créé . et 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 le / var / s p o o l / c r o n / c r o n t a b s 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 . 9.3 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 E. Branlard 73 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS 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 ! ) 9.4 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 9.5 Disque externe en lecture seule c a t / e t c / 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 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 système ) . # 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 système ). # 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 . 9.6 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 E. Branlard 74 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS 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 9.7 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éralement 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 cré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 . L ' idé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 t e n t e d ' accéder à l a r e s s o u r c e : 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 accède à 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) . E. Branlard 75 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS 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 pr ivé ) . Les d r o i t s du f i c h i e r s o n t généralement 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éfaut peuvent cependant à ª t r e changé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 créé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éfaut e s t donc o−w . Pour une i n f o r m a t i o n p l u s poussé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 ' idée de départ 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 partagé par j o s e t t e e t gaston , mais / vidéos 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 cré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 . 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 : # création 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 / vidéos / p h o t o s −Rc Le mode d ' a c c à ¨ s de ` / vidéos / nos_v a c a n c e s . avi ' a été mo d if 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 / vidéos −Rc chown : a c c e s −p h o t o s / p h o t o s −Rc # a j o u 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 usermod −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 usermod −a −G a c c e s − v i d e o s j o s e t t e E. Branlard 76 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS usermod −a −G a c c e s −p h o t o s r o b e r t r o o 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 crée . La conséquence , à c a u s e de l ' umask par défaut , 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éralement 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 créé 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 créé aura en p l u s l e SGID de positionné . 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épart 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# /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 {} \ ; E n s u i t e , SGID étant 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 créé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 accéder 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 créé , 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 problèmes e t une p e t i t e tâche CRON peut v e n i r f i n i r le travail . 9.8 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 ) E. Branlard for f i l e format −−> 77 CHAPTER 9. FILESYSTEMS, UTILISATEURS, GROUPES, DROITS <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 78 Chapter 10 Grub, dual-boot, MBR 10.1 Congure Grub 2 - create grub.d congs %% % Bad way : e d i t C o n f i g f i l e : . cfg / boot / grub / grub %% % Clean way : make grb . d s c r i p t s 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 / %a s r o o t o f c o u r s e . . nano / e t c / grub . 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 / grub . 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 10.2 Instal grub in MBR %% %% %% %% % # b o o t e r s u r System r e s c u e CD # mounter FS mount / dev / sda3 /mnt/tmp # 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/tmp / 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 79 CHAPTER 10. 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 étant 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 . c o n f ) , s t a g e 2 . 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érique 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 − Chroot e t c 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 80 CHAPTER 10. GRUB, DUAL-BOOT, MBR sudo − s su − 10.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 81 Chapter 11 WIFI 11.1 Congurer ma carte wi bcm4312, broadcom #commandes u t i l e s iwconfig ifconfig i f c o n f i g wlan0 up 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 % wicd wicd s h o u l d be c o n f i g u r e d with t h e r i g h t i n t e r f a c e name d o e s f i n d i t and a c t i v a t e i t o t h e r w i s e . for the w i f i ! ! ! i t #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 chargé dans l ' i n i t r a m f s . Ca s e v e r i f i e en tappant : 82 CHAPTER 11. WIFI 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 #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 83 CHAPTER 11. 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 ! : modprobe wl E. Branlard 84 CHAPTER 11. WIFI 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 ! 11.2 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éseaux e t 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 . % * 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_c r a c k % 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 . % % E. Branlard 85 CHAPTER 11. WIFI 11.3 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 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 E. Branlard 86 Chapter 12 SERVERS - PHP SQL APACHE SAMBA FTP SSH 12.1 VirtualBox %% % SSH from g u e s t t o h o s t i n s t a l l openssh − s e r v e r on h o s t Add a host −o n l y network i n V i r t u a l B o x G e n e r a l p r e f e r e n c e s In t h e v i r t u a l machine o p t i o n , add on top o f t h e nat i n t e r f a c e , a n o t h e r i n t e r f a c e , host −o n l y In t h e g u e s t machine c o n f i g u r e t h e s e c o n d i n t e r f a c e e t h 1 t h e same way than e t h 0 i n / e t c / network / i n t e r f a c e s : auto e t h 1 i f a c e e t h 1 i n e t dhcp By d e f a u l t s t h e h o s t i p w i l l be 1 9 2 . 1 6 8 . 5 6 . 1 and t h e g u e s t i p 192.168.56.101 You can add s h o r t c t u s t o t h e s e IP i n / e t c / h o s t s %% % File sharing D e v i c e s −> I n s t a l l g u e s t s a d d i t i o n s a p t i t u d e i n s t a l l dkms l i n u x −h e a d e r s b u i l d − e s s e n t i a 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 x s e r v e r −xorg − c o r e mount / dev / s r 0 / media / cdrom . / VBoxLinux 12.2 SQL editor: sqlitebrowser 12.3 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 87 t o be runed even a f t e r logout and CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH 12.4 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 ! # 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 E. Branlard 88 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH − 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 accéder au deuxième , c e t t e commande permet de 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 crypté 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 crypté 5901 : p o r t coté 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 établir la connection 12.5 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 12.6 CUPS Debugging commands : p i n g l o c a l h o s t −> i f doesn ' t work , add l o o p b a c k l o i n , i f u p lo , i f c o n f i g l o or r e s t a r t n e t s t a t − n l | g r e p 631 i p t a b l e s −nvL n e t s t a t −tunva E. Branlard network i n t e r f a c e s 89 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH n e t s t a t − t a p l n | g r e p cups vim / var / l o g / cups / e r r o r_l o g c a t / e t c / network / i n t e r f a c e s cat / e t c / h o s t s cat / e t c / h o s t s . allow 12.7 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 12.8 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 ; >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 12.9 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 . ### Apache sudo / e t c / i n i t . d / apache2 r e l o a d E. Branlard 90 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH #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 Have a l o o k a t t h e f i l e / e t c / apache2 / e n v v a r s export APACHE_RUN_USER=manu export APACHE_RUN_GROUP=www−data ### Test / I n s t a l l PhP # 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 ################################################## ### SQL ################################################## 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 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 " ; #To c r e a t e a new mysql u s e r ' g u e s t ' w i t h ' a l l p r i v i l e g e s ' on t h e d a t a b a s e ' demo ' : mysql > c r e a t e d a t a b a s e demo mysql >GRANT ALL PRIVILEGES ON demo . * TO ' g u e s t ' @' l o c a l h o s t ' IDENTIFIED BY ' g u e s t ' WITH GRANT OPTION; mysql> UPDATE u s e r SET Password=PASSWORD( ' g u e s t ' ) WHERE u s e r =' g u e s t ' ; That ' s i t ! MySQL i s ready ! Don ' t f o r g e t t o remember t h e r o o t password a s we might be u s i n g i t with phpmyadmin . E. Branlard 91 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH #################################################### ### Php My Admin #################################################### The phpmyadmin c o n f i g u r a t i o n f i l e i s l o c a t e d a t : / e t c / phpmyadmin f o l d e r . U s u a l l y i t i s a u t o m a t i c a l l y s e t u p with a sim− l i n k i n / e t c / apache2 / c o n f . d / phpmyadmin . c o n f Check i t , i f not p r e s e n t , e i t h e r l i n k i t t o / e t c / phpmyadmin / apache . c o n f o r add t h e f o l l o w i n g l i n e i n / e t c / apache2 / apache2 . c o n f : I n c l u d e / e t c / phpmyadmin / apache . c o n f r e s t a r t apache Goto h t t p : // l o c a l h o s t / phpmyadmin I f you have "You don ' t have p e r m i s s i o n t o a c c e s s / phpmyadmin / on t h i s server . " then e d i t t h e f i l e / e t c / phpmyadmin / apache . c o n f and a l l o w a c c e s s t o t h e folder : <D i r e c t o r y / u s r / s h a r e / phpmyadmin> Options FollowSymLinks D i r e c t o r y I n d e x i n d e x . php Order deny , a l l o w Allow from 1 2 7 . 0 . 0 . 1 # To be a b l e t o import s q l f i l e s i n phpmyadmin e d i t php . i n i : ; h t t p : // php . n e t / post −max− s i z e p o s t_max_s i z e = 20M ; Maximum a l l o w e d s i z e f o r uploaded f i l e s . ; h t t p : // php . n e t / upload −max− f i l e s i z e upload_max_ f i l e s i z e = 200M # Other i n f o 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 h t t p : //www. c y b e r c i t i . b i z / f a q / mysql −command−to −show− l i s t −of −d a t a b a s e s −on− server/ h t t p : //www. h o w t o f o r g e . com/ quick −n−easy −lamp− s e r v e r −c e n t o s − r h e l # Commands s q l show d a t a b a s e s ; 12.10 Apache - example of htaccess le The module RewriteEngine i s r e a l l y nice , but not a l l o w e d on a l l s e r v e r s . One can u s e a workaround with t h e module M u l t i v i e w s , and something l i k e a f i l e t a g . php c o n t a i n i n g : <?php $ u r l = $_SERVER[ 'PATH_INFO ' ] ; $ g e t = e x p l o d e ( "/" , $ u r l ) ; ?> s o t h a t / t a g . php / a / b / c / d o r s c r i p t i n t a g . php . E. Branlard / t a g / a /b/ c /d w i l l be d e a l t t h e same by t h e 92 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH Options I n d e x e s M u l t i v i e w 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 IndexOptions IconsAreLinks IndexOptions SuppressLastModified #HTMLTABLE #XHTML S u p p r e s s R u l e s S u p p r e s s L a s t M o d i f i e d S u p p r e s s S i z e I n d e x O p t i o n s NameWidth=70 HeaderName /_i n c l u d e s / i n d e x h e a d e r . php ReadmeName /_i n c l u d e s / i n d e x f o o t e r . php I n d e x I g n o r e . h t a c c e s s _i n c l u d e s _CONTENT. php AddIcon / images / mimetypes / f o l d e r . png ^^DIRECTORY^^ AddIconByType (SND, / images / mimetypes / audio −x− g e n e r i c . png ) a u d i o /* AddIconByType (IMG, / images / mimetypes / image −png . png ) image /* AddIconByType (TXT, / images / mimetypes / t e x t −x− g e n e r i c . png ) t e x t /* AddIconByType (VID , / images / mimetypes / vid eo −x− g e n e r i c . png ) v i d e o /* AddIconByType (XOF, / images / mimetypes / x− o f f i c e −document . png ) x− o f f i c e /* AddIcon ( ZIP , / images / mimetypes / package −x− g e n e r i c −packed . png ) . t a r . gz . 7 z . z i p . bz2 AddIcon (DOC, / images / mimetypes / x− o f f i c e −document . png ) . r t f . doc . docx . z i p . bz2 AddIcon (PPT, / images / mimetypes / x− o f f i c e − p r e s e n t a t i o n . png ) . ppt . odp AddIcon (XLS , / images / mimetypes / x− o f f i c e − s p r e a d s h e e t . png ) . x l s . x l s x . ods AddIcon (HML, / images / mimetypes / t e x t −html . png ) . html . php . c s s . htm AddIcon (PDF, / images / mimetypes / a p p l i c a t i o n −pdf . png ) . pdf . ps . d v i AddIcon (TEX, / images / mimetypes / t e x t −x−t e x . png ) . t e x . b i b D e f a u l t I c o n / images / mimetypes / t e x t −x− g e n e r i c −t e m p l a t e . png AddIcon / images / mimetypes / go−up . png . . #Options +F o l l o w S y m l i n k s #RewriteEngine on #R e w r i t e R u l e ^ a r t i c l e s / ( [ ^ / ]+) / ( [ ^ / ]+) . z i p h i . php ? s e c t i o n=$ 1& f i l e =$ 2 [NC] 12.11 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 . E. Branlard 93 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH <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 > ~ 12.12 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 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 12.13 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 E. Branlard 94 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH </ 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 AddHandler a p p l i c a t i o n / x−httpd −php . php Options − I n d e x e s 12.14 Aide server apache - protection par mot de passe protéger 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 étapes 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 cr yp té e uniquement . Pour l e créer , 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 mot−de−p a s s e en c l a i r " . Maintenant , l e mot de . 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 . 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 t a p e r " htpasswd / var /www/ . htpasswd bob" e t i l mot de p a s s e . / var /www/ . htpasswd bob p a s s e de bob s e r a crypté S i on ne veut pas que l e de commande , i l f a u t va demander de t a p e r l 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 E. Branlard 95 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH AuthName " Accés réservé " # 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> 12.15 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 i p t a b l e s − t nat −F i p t a b l e s − t nat −X i p t a b l e s − t mangle −F i p t a b l e s − t mangle −X i p t a b l e s −P INPUT ACCEPT i p t a b l e s −P OUTPUT ACCEPT 12.16 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 E. Branlard et actionstop 96 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH 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 #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 12.17 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éralement 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 E. Branlard 97 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH 12.18 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 ! 12.19 Samba fusesmb pyNeighborhood # 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 98 CHAPTER 12. SERVERS - PHP SQL APACHE SAMBA FTP SSH 12.20 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 12.21 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 12.22 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éseau de l a forme « DOMAINES/MACHINES/PARTAGES » . Pour démonter l e p o i n t de montage : fusermount −u Network E. Branlard 99 Chapter 13 Multimedia 13.1 Lire wmv windows media video ? sudo a p t i t u d e i n s t a l l w32codecs 13.2 Video capture % guvcview ( bug with a u d i o c o m p r e s i o n though ) % ffmpeg ffmpeg − f v i d e o 4 l i n u x 2 − i / dev / v i d e o 0 − p i x_fmt yuv420p − s vga − r 8 − f a l s a −ac 1 − a r 16000 − i hw : 1 , 0 − vcodec mpeg4 −b 400 k − a c o d e c libmp3lame −ab 80 k v i d e o . a v i 13.3 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 13.4 Timidity GUI For debian , t h e one p r e s e n t by d e f a u l t : t i m i d i t y − i a f i l e . midi For o t h e r i n t e r f a c e l o o k a t t i m i d i t y −h . GTK: − i g 100 . CHAPTER 13. MULTIMEDIA 13.5 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 . 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 13.6 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 e t L s o n t l e s l a r g e u r e t h a u t e u r . Le b i t r a t e v i d e o par défaut 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. E. Branlard 101 Chapter 14 Optimizations ? 14.1 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éfaut 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 2 Go . De t o u t e façon 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 systématiquement 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 ' i n u t i l i s a t i o n . 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 14.2 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 102 CHAPTER 14. OPTIMIZATIONS ? 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 / ext3 d e f a u l t s , noatime , e r r o r s=remount−r o 0 1 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 également 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 élaboré ( / 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 " . 14.3 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équence 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 remplacé 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 compilé 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éfaut 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équence 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 , e t à © d i t e z l a 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 " , e t à © d i t e z l a d i r e c t e m e n t . * 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âches " 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 : %% % m a k e f i l e c o n c u r r e n c y and readahead # a p t i t u d e i n s t a l l readahead − f e d o r a # echo CONCURRENCY=m a k e f i l e >> / e t c / d e f a u l t / rcS E. Branlard 103 CHAPTER 14. OPTIMIZATIONS ? # 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 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équence 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 problèmes 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 " présenté 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 ) . 14.4 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éral 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 14.5 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 ) . 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 " ;} 14.6 Optimisation - Suppression services - Init scripts Debian s q u e e z e g o e s towards c o n c u r r e n c y boot i e i n CONCURRENCY=m a k e f i l e See " / u s r / s h a r e / doc / i n s s e r v /README. Debian " . / etc / d e f a u l t /rcS h t t p : // w i k i . d e b i a n . o r g / L S B I n i t S c r i p t s / DependencyBasedBoot E. Branlard 104 CHAPTER 14. OPTIMIZATIONS ? dpkg− r e c o n f i g u r e i n s s e r v sysv − r c ####To s e e t h e b o o t and r e b o o t s e q u e n c e dependency graph , use aptitude i n s t a l l i n s s e r v graphviz / u s r / s h a r e / i n s s e r v / check − i n i t d − o r d e r / u s r / s h a r e / i n s s e r v / check − i n i t d − o r d e r d o t t y boot . dot d o t t y r e b o o t . dot −g > boot . dot −g −k > r e b o o t . dot ### h t t p : //www. debian − a d m i n i s t r a t i o n . o r g / a r t i c l e s / 629 h t t p : //www. debian − a d m i n i s t r a t i o n . o r g / a r t i c l e s / 620 ### R u n l e v e l s ( S does not mean s e r v i c e b u t s i n g l e ! ) runlevel directory d e s c r i p t i o n o f r u n l e v e l usage N none system bootup (NONE) l e v e l ( no " / e t c / rcN . d / " d i r e c t o r y ) 0 / e t c / r c 0 . d/ h a l t t h e system S / e t c / r c S . d/ s i n g l e − u s e r mode on boot ( a l i a s : " s " ) 1 / e t c / r c 1 . d/ s i n g l e − u s e r mode s w i t c h e d from multi − u s e r mode 2 / e t c / r c 2 . d/ multi − u s e r mode 3 / e t c / r c 3 . d/ ,, 4 / e t c / r c 4 . d/ ,, 5 / e t c / r c 5 . d/ ,, 6 / e t c / r c 6 . d/ r e b o o t t h e system 7 / e t c / r c 7 . d/ v a l i d multi − u s e r mode but not n o r m a l l y used 8 / e t c / r c 8 . d/ ,, 9 / e t c / r c 9 . d/ ,, ### Go back t o d e f a u l t : # f o r s q u e e z e and l a t e r i n s s e r v anacron # prior to 6.0 ( prior to squeeze ) update − r c . d anacron d e f a u l t s man i n s s e r v man update − r c . d man i n i t ##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 sysv −rc −c o n f −P s w i t c h with sysv −rc −c o n f t o remove o l d empty e n t r i e s . %% % List of services a c p i d ( 2 3 4 5 −> D? ) E. Branlard ??????????? 105 CHAPTER 14. OPTIMIZATIONS ? 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 ( S ) : ???????? anacron ( 2 3 4 5 −> D o r kept , l o g r o t a t e u s e f u l f o r i n s t a n c e . . but w e l l ) : cron anachronic 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 ( 2 3 4 5−>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éseau 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 ( S −>D) un d e s p e r m i e r s s c r i p t s exécuté , l a n c e l e daemon bootlogd b o o t l o g s ( 1 2 3 4 5 −>D) un d e s p e r m i e r s s c r i p t s exécuté , l a n c e l e daemon b o o t l o g d 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âches , 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érifiées ( 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 ( S ) 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 ) c p u f r e q u t i l s ( 2 3 4 5 −> D s e e f o l l o w i n g i n f o ) : f o r cpu f r e q management check t h e output o f c p u f r e q − i n f o and c a t / s y s / d e v i c e s / system / cpu / cpu0 / c p u f r e q / s c a l i n g_g o v e r n o r I f "ondemand" , you ' r e good . For l a p t o p : unplug your power c o r d and check i f i t g i v e s you " powersave " . 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 c u p s y s (D) gestionnaire d ' impression dbus −1 ( 2 3 4 5 ) Important f o r power management , 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 remplacé par gamin fetchmail m a i l ? récupérer 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 ) fuse (S) 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 ( nothing ) pour a r r e t e r l e PC E. Branlard 106 CHAPTER 14. OPTIMIZATIONS ? hddtemp (D) : used by s e n s o r s u t i l s hdparm (S) 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 état 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 −sy st è mes 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 (S) i n i t i a l i s e l ' état d e s i n t e r f a c e s ( a c t i v à © e s ou non ) ifupdown − c l e a n ( S ) ??? 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 kbd ( S ) : ? ? ? ? ? ? ? ? ? keyboard −(S ) : ? ? ? ? ? ? ? ? ? keymap . sh c h a r g e l e mappage c l a v i e r adéquat k i l l p r o c s (S) ????????? 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 à ¨ r e l e s f i c h i e r s p à © r i p h à © r i q u e s n à © c à © s s a i r e s à libdevmapper lm− s e n s o r s (D? ) : loadcpufreq (2 3 4 5) ????????? l p d (D) : printing service l p n r g ( 2 3 4 5−> D) : enhanced l p r / l p d p r i n t e r s p o o l i n g system f o r l o c a l o r remote p r i n t e r s lvm g e s t i o n n a i r e de s t o c k a g e avancé makedev cré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 à © c e s s a i r e s 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 ( sy st èm es de f i c h i e r s " l o c a u x " i e non réseaux d à © f i n i s dans / e t c / f s t a b ) 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 ( S−>D) a c t i v a t i o n d e s i n t e r f a c e s réseaux 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 e t 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 ( 2 3 4 5 S−> 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 E. Branlard 107 CHAPTER 14. OPTIMIZATIONS ? 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éseau 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 s e n d s i g s ( nothing ) 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 restants a l ' extinction single (1) executé 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 (2−5−> 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 (S) daemon q u i cré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 udev−mtab ( S ) umountfs ( n o t h i n g ) démonte l e s swap e t t o u s l e s s ys tè me s de f i c h i e r locaux umountnfs . sh ( n o t h i n g ) 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 la racine urandom (S) 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érateur 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 à © / sauvegardé wicd ( 2 3 4 5 ) 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 x f r e e 8 6 −common 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 les sockets wpa− i f u p d 14.7 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 generé dans / var / l o g . en tappant b o o t c h a r t dasn son home , un png e s t generé . 14.8 Optimisation - Cong reseau demarrage La c o n f i g u r a t i o n réseau 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. E. Branlard 108 CHAPTER 14. OPTIMIZATIONS ? 14.9 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à ! 14.10 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 E. Branlard 109 Chapter 15 Misceleanous 15.1 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 ) 15.2 Connexion ssh avec mot de passe automatique, methode bourrin mot de passe en clair 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 : #! set /usr/bin/ expect −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 ton −l o g i n @ l a −ou−tu −veux e x p e c t " password : $ " send " ton −passwd \n" interact 15.3 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 Screw i t , t e l e c h a r g e r web n v i d i a 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 sur l e s i t e 110 CHAPTER 15. MISCELEANOUS 15.4 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 tapé ç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 également q u i génère l e s p a s h 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 %! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! %! ! ! WATCH OUT − End Of F i l e %! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! E. Branlard 111 Part II Supplementary notes 112 Chapter 16 Conguration Files 16.1 /.bashrc source / home /manu/ C o n f i g / p r o f i l e s / b a s h r c_common #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 \] ' ######################################################### # PROGRAM PATHS and VARIABLES ######################################################### #e x p o r t MATLABPATH=/ home /manu/ C o n f i g / matlab #p a t h f o r l i s t e n music p l a y e r #e x p o r t MOZILLA_FIVE_HOME=/ u s r / l i b / i c e w e a s e l #e x p o r t LD_LIBRARY_PATH=/ u s r / l i b / i c e w e a s e l #/ u s r / l i b / l i s t e n / l i s t e n . py " $@" #i n t e l f o r t r a n #s o u r c e / o p t / i n t e l / Compiler / 1 1 . 1 / 069 / b i n / i f o r t v a r s . sh source / opt / i n t e l − f o r t r a n / b i n / i f o r t v a r s . sh ia32 ia32 LD_LIBRARY_PATH=$LD_LIBRARY_PATH: / opt / cuda / l i b / #gpg −− k e y s e r v e r k e y s e r v e r . ubuntu . com −− r e c v 778978 B00F7992B0 #gpg −− e x p o r t −−armor 778978 B00F7992B0 | sudo apt −key add − # ~/ . 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 113 CHAPTER 16. CONFIGURATION FILES # 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 PC BEEP #x s e t −b #setxkbmap − o p t i o n compose : r a l t ######################################################### # 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 n o c o =' l s −F −− c o l o r=none −−group − d i r e c t o r i e s − f i r s t ' 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 n o c o =' g r e p −− c o l o r=none ' 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 ' a l i a s v i g r u b =' sudo vim / boot / grub / grub . c f g ' a l i a s v i x =' sudo vim / e t c / X11 / xorg . conf ' a l i a s v i i n i t =' sudo vim / e t c / i n i t t a b ' alias alias alias alias alias alias alias alias # 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 ' 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 } # alias ff { grep −I n r s i $1 . /* f= f f # tracker a l i a s a s e a r c h =' t r a c k e r − s e a r c h a l i a s t s e a r c h =' t r a c k e r − s e a r c h a l i a s msearch =' t r a c k e r − s e a r c h a l i a s v s e a r c h =' t r a c k e r − s e a r c h a l i a s i s e a r c h =' t r a c k e r − s e a r c h alias alias ' −t −m −v −i ' ' ' ' 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 " ' #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 a p i =' sudo a p t i t u d e i n s t a l l ' a l i a s aps =' a p t i t u d e s e a r c h ' a l i a s a p s s =' a p t i t u d e show ' E. Branlard 114 CHAPTER 16. CONFIGURATION FILES alias apc =' apt −c a c h e p o l i c y ' ######################################################### # Vim E d i t i n g mode i n Bash ######################################################### s e t −o v i # ^p c h e c k f o r p a r t i a l match i n h i s t o r y bind −m vi − i n s e r t " \C−p" : dynamic −complete−h i s t o r y # ^n c y c l e t h r o u g h t h e l i s t o f p a r t i a l matches bind −m vi − i n s e r t " \C−n" : menu−complete # ^ l clear screen bind −m vi − i n s e r t " \C− l " : c l e a r − s c r e e n ######################################################### # 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 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 #gpg −− k e y s e r v e r k e y s e r v e r . ubuntu . com −− r e c v 778978 B00F7992B0 #gpg −− e x p o r t −−armor 778978 B00F7992B0 | sudo apt −key add − 16.2 /.bash_prole echo " echo " echo " "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−− BASH PROFILE −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− #i f [ ` t t y ` = " / dev / t t y 1 " ] ; t h e n # s t a r t x& #f i E. Branlard 115 CHAPTER 16. CONFIGURATION FILES # 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 / PATH=$PATH: / opt / cuda / b i n / LD_LIBRARY_PATH=$LD_LIBRARY_PATH: / opt / cuda / l i b / #For your . x i n i t you may want t o use ' e x e c ck −launch − s e s s i o n dbus −l a u n c h −−sh − s y n t a x −− e x i t −with − s e s s i o n s t a r t x f c e 4 ' , i t ' s what I have found t o work b e t t e r . # i f [ " $ ( t t y ) " = " / dev / t t y 1 " ] ; t h e n i f [ ` ps − l e | g r e p x i n i t | wc − l ` == 0 ] ; then exec ck −launch − s e s s i o n s t a r t x f c e 4 ; #x i n i t ; echo " " ; echo "Bye Bye" ; echo " " source . b a s h r c # fi fi # && [ $ ( t t y ) == # s t a r t x& #f i 16.3 / dev / t t y 1 ] ; then /.xinitrc echo " echo " echo " "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−− BEGIN XINITRC −−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ############################# # This f i l e i s not used by nodm , s e e . x s e s s i o n ############################# #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 / x s e t n u m l o c k& #xterm c o n f i g xrdb ~/ . X d e f a u l t s #i f which dbus −l a u n c h > / dev / n u l l && t e s t − z " $DBUS_SESSION_BUS_ADDRESS" ; then # e v a l " $ ( dbus −l a u n c h −−sh −s y n t a x −− e x i t −with − s e s s i o n ) " #f i #/ home /manu/ C o n f i g / s c r i p t s / ScreenConf . sh E. Branlard 116 CHAPTER 16. CONFIGURATION FILES #e x e c ck −launch − s e s s i o n s t a r t x f c e 4 #setxkbmap − o p t i o n t e r m i n a t e : c t r l _a l t_b k s p setxkbmap − o p t i o n compose : r a l t #b o o t c h a r t # e x e c x f c e 4 −s e s s i o n exec ck −launch − s e s s i o n x f c e 4 − s e s s i o n ; setxkbmap − o p t i o n compose : r a l t #e x e c s t a r t x f c e 4 #f l u x b o x #b l a c k b o x #icewm #s a w f i s h # echo " echo " echo " 16.4 "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−−−− END XINITRC −−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− /.xsession echo " echo echo "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "−−−−−−−−−−−−−−−−−−−−−−− BEGIN XSESSION −−−−−−−−−−−−−−−−−−−−−−−−−−−" "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− " ############################# # This f i l e i s not used by nodm , s e e . x s e s s i o n ############################# #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 / x s e t n u m l o c k& #xterm c o n f i g #x r d b ~/ . X d e f a u l t s #i f which dbus −l a u n c h > / dev / n u l l && t e s t − z " $DBUS_SESSION_BUS_ADDRESS" ; then # e v a l " $ ( dbus −l a u n c h −−sh −s y n t a x −− e x i t −with − s e s s i o n ) " #f i #e x e c ck −launch − s e s s i o n s t a r t x f c e 4 #e x e c s t a r t x f c e 4 #setxkbmap − o p t i o n compose : r a l t E. Branlard 117 CHAPTER 16. CONFIGURATION FILES 16.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 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− Xcursor * theme : V a n i l l a −DMZ−AA Xcursor . s i z e : 22 ! ! VIM s t u f f s Vim* f o r e g r o u n d : Black Vim . background : w h i t e 16.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 " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " E. Branlard 118 CHAPTER 16. CONFIGURATION FILES " 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 position . " 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 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 s y n t a x on " syntax h i g h l i g h i n g f i l e t y p e on i f has ( " g u i_r u n n i n g " ) s e t g u i f o n t=Monospace \ 10 " use t h i s font s e t background=l i g h t " adapt c o l o r s f o r background 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 s e t g u i o p t i o n s+=b "add h o r i z o n t a l bar c o l o r s c h e m e ManuWhite set nospell else c o l o r s c h e m e ManuGreen " u s e t h i s c o l o r scheme s e t background=dark " adapt c o l o r s f o r background set nospell endif " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " Editor general " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " E. Branlard 119 CHAPTER 16. CONFIGURATION FILES " l i n e numbering s e t number nnoremap \ tn : s e t invnumber number?<CR> " s p e l l check nnoremap \ t s : s e t i n v s p e l l s p e l l ?<CR> " Sessions s e t s s o p=blank , b u f f e r s , c u r d i r , f o l d s , tabpages , w i n s i z e , r e s i z e , winpos " used by CTRL−U and CTRL−D ? w e l l , w e l l w e l l . . . s e t s c r o l l =4 s e t s c r o l l o f f =3 " always i n t h e f i l e d i r e c t o r y " set a u t o c h d i r " autocmd BufEnter * s i l e n t ! l c d %:p : h " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " Keywords " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " s e t i s k=a−z , A−Z,48 − 57 ,_,128 − 167 ,224 − 235 " s e t i s k +=: " f o r l a t e x i n t h e f t p l u g i n d i r " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " Wrapping and h o r i z o n t a l bar " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " function ToggleHorizontalScrollbar () " s e t g u i o p t i o n s+=b i f &go =~# " b " s e t go−=b else s e t go+=b endif endfunc s e t l b r " l i n e break noremap <F10> : s e t nowrap ! <CR> "~ map <F9> : s e t g u i o p t i o n s+=b <CR> noremap <F11> : c a l l T o g g l e H o r i z o n t a l S c r o l l b a r ( )<CR> noremap <F6> : s e t g u i o p t i o n s+=m <CR> " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " 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=l o n g e s t , l i s t , f u l l s e t wildcharm=<C−Z> E. Branlard 120 CHAPTER 16. CONFIGURATION FILES s e t w i l d i g n o r e=* . o , *~ , * . cmo , * . cmi , * . a , * . cmx , * . cmxa , * . aux , * . dvi , * . aut , * . bbl , * . blg , * . dvi , * . f f f , * . ps , * . toc , * . t t t " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " Foldinpeg " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " 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 ) s e t foldmethod=i n d e n t " f o l d i n d e n t e d r e g i o n s s e t f o l d m i n l i n e s =1 s e t f o l d n e s t m a x=2 set nofoldenable s e t f o l d l e v e l =1 " f o l d from t h e b e g i n n i n g " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " 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 e x p l o r e r \ be " 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 " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " Commenting b l o c k s o f code . l e t b : comment_l e a d e r =' // ' autocmd F il eT y p e c , cpp , java , s c a l a , php l e t b : comment_l e a d e r = ' // ' autocmd F il eT y p e sh , ruby , python l e t b : comment_l e a d e r = '# ' autocmd F il eT y p e f o r t r a n l e t b : comment_l e a d e r = ' ! ' autocmd F il eT y p e conf , f s t a b l e t b : comment_l e a d e r = '# ' autocmd F il eT y p e tex , matlab l e t b : comment_l e a d e r = '% ' autocmd F il eT y p e m a i l l e t b : comment_l e a d e r = '> ' autocmd F il eT y p e vim l e t b : comment_l e a d e r = ' " ' " mapping noremap <s i l e n t > , c c :<C−B>s i l e n t <C−E>s /^/<C−R>=e s c a p e ( b : comment_l e a d e r , ' \ / ' )<CR>/<CR>: n o h l s e a r c h <CR> noremap <s i l e n t > , cu :<C−B>s i l e n t <C−E>s / ^\V<C−R>=e s c a p e ( b : comment_l e a d e r , ' \ / ' )<CR>// e<CR>: n o h l s e a r c h <CR> noremap <s i l e n t > , c t : c a l l ToggleComment (&f t )<CR> " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " 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 E. Branlard 121 CHAPTER 16. CONFIGURATION FILES " 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 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 " were c h a r a c t e r w i s e i n s t e a d . " 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 [ exe ' vnoremap <s c r i p t > <C−V>' p a s t e#p a s t e_cmd [ . not p o s s i b l e i n I n s e r t and They a r e p a s t e d a s i f 'i '] '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 " noremap <C−A> ggVG " 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 " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " 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>> E. Branlard 122 CHAPTER 16. CONFIGURATION FILES 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 " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " 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 s e t c l i p b o a r d=unnamed s e t s e s s i o n o p t i o n s+=r e s i z e " i n s e r t o n l y one c h a r a c t e r , e n a b l i n g r e p e t i t i o n s a s ' 5 s ' f u n c t i o n ! RepeatChar ( char , count ) r e t u r n r e p e a t ( a : char , a : count ) endfunction nnoremap s :<C−U>e x e c " normal i " . RepeatChar ( n r 2 c h a r ( g e t c h a r ( ) ) , v : count1 ) <CR> " " " " " C t r l −j /k nnoremap nnoremap nnoremap nnoremap d e l e t e s blank <s i l e n t ><A−J> <s i l e n t ><A−K> <s i l e n t ><A−j > <s i l e n t ><A−k> l i n e below / above , and Alt − j / k i n s e r t s . m` : s i l e n t +g / \m^\ s *$/d<CR> ` ` : noh<CR> m` : s i l e n t −g / \m^\ s *$/d<CR> ` ` : noh<CR> : s e t p a s t e <CR>m` o<Esc > ` ` : s e t nopaste <CR> : s e t p a s t e <CR>m` O<Esc > ` ` : s e t nopaste <CR> " " " " " " " " " " " " E c l i p s e −l i k e p a r e n t h e s i s h a n d l i n g imap ( ( )<L e f t > imap { {}< L e f t > imap ( * ( * * )<L e f t ><L e f t ><L e f t > Same f o r quotes , e x c e p t i n vim f i l e s ( where " i s comment , o b v i o u s l y ) au BufRead i f &f t != ' vim ' | inoremap " " "<L e f t > | e n d i f ' Escapes ' f o r t h e above imap ( ( ( imap ( ) ( ) imap {{ { imap " " " " imap {} {} " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " VIM−LATEX " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " E. Branlard 123 CHAPTER 16. CONFIGURATION FILES " 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 ' " can be c a l l e d c o r r e c t l y . set shellslash set so that l a t e x " 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 " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " " Latex c o m p i l a t i o n " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " 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 " i f s e t t o 1 then a f t e r \ l l then vim w i l l go t o t h e next e r r o r " Inverse search " l e t g : Tex_ViewRule_pdf = ' "C: \ b i n \SumatraPDF\SumatraPDF . exe " − i n v e r s e − s e a r c h " gvim −c \ " : RemoteOpen +\%l \% f \ " " ' " 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 = 11 " 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 =' part , c h a p t e r , 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 = ' ' l e t g : Tex_AutoFolding=1 l e t g : Tex_F o l d i n g=1 E. Branlard 124 CHAPTER 16. CONFIGURATION FILES "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 ( ) "~ " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " " Matlab " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " source $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 " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " " SpellCheck " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " s e t mousemodel=popup_s e t p o s " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " " OmniCpp " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " "" " " " " " " " " " " " " " " " " " " " " " " " " " omnicppcomplete o p t i o n s s e t t a g s+=~/ . vim / t a g s / t a g s_cpp map <F12> : ! c t a g s −R −−c++−k i n d s=+p l −− f i e l d s=+i a S −− e x t r a=+q .<CR><CR> " add c u r r e n t d i r e c t o r y ' s g e n e r a t e d t a g s f i l e t o a v a i l a b l e t a g s s e t t a g s +=./ t a g s " −−− OmniCppComplete −−− " −− r e q u i r e d −− s e t nocp " non v i c o m p a t i b l e mode f i l e t y p e p l u g i n on " enable p l u g i n s " −− c o n f i g s −− l e t OmniCpp_NamespaceSearch = 2 " s e a r c h namespaces i n t h i s and i n c l u d e d files l e t OmniCpp_G l o b a l S c o p e S e a r c h = 1 l e t OmniCpp_ShowAccess = 1 l e t OmniCpp_ShowPrototypeInAbbr = 1 " show f u n c t i o n p r o t o t y p e ( i . e . p a r a m e t e r s ) i n popup window l e t OmniCpp_MayCompleteDot = 1 " a u t o c o m p l e t e with . E. Branlard 125 CHAPTER 16. CONFIGURATION FILES let let let let OmniCpp_MayCompleteArrow = 1 " a u t o c o m p l e t e with −> OmniCpp_MayCompleteScope = 1 " a u t o c o m p l e t e with : : OmniCpp_S e l e c t F i r s t I t e m = 2 " s e l e c t f i r s t item ( but don ' t i n s e r t ) OmniCpp_L o c a l S e a r c h D e c l = 1 " don ' t r e q u i r e s p e c i a l s t y l e o f f u n c t i o n opening braces " a u t o m a t i c a l l y open and c l o s e t h e popup menu / p r e v i e w window " au CursorMovedI , I n s e r t L e a v e * i f p u m v i s i b l e ( ) == 0 | s i l e n t ! p c l o s e | e n d i f " s e t c o m p l e t e o p t=menuone , menu , l o n g e s t , p r e v i e w " auto c l o s e o p t i o n s when e x i t i n g i n s e r t mode o r moving away autocmd CursorMovedI * i f p u m v i s i b l e ( ) == 0 | p c l o s e | e n d i f autocmd I n s e r t L e a v e * i f p u m v i s i b l e ( ) == 0 | p c l o s e | e n d i f s e t c o m p l e t e o p t=menu , menuone " Setup t h e tab key t o do a u t o c o m p l e t i o n f u n c t i o n ! CompleteTab ( ) l e t p r e c = s t r p a r t ( g e t l i n e ( ' . ' ) , 0 , c o l ( ' . ' ) −1 ) i f p r e c =~ '^\ s *$ ' | | p r e c =~ ' \ s $ ' r e t u r n "\<tab>" else r e t u r n "\<c−x>\<c−o>" endif endfunction inoremap <tab> <c−r>=CompleteTab ( )<cr> 16.7 /.conkyrc E. Branlard 126 Chapter 17 Shell scripts 17.1 exaileplaylist2rhythmox #! / u s r / b i n / python import os , s t r i n g h = open ( ' p l a y l i s t s . xml ' , 'w' ) h . w r i t e ( ' <? xml v e r s i o n=" 1 . 0 "?>\n ' ) h . w r i t e ( ' < rhythmdb− p l a y l i s t s >\n ' ) h . w r i t e ( ' < p l a y l i s t name=" Play Queue" type=" queue " />\n ' ) h . w r i t e ( ' < p l a y l i s t name="My Top Rated " type=" a u t o m a t i c " s o r t −key=" Rating " s o r t − d i r e c t i o n=" 1 ">\n ' ) h . write ( ' <c o n j u n c t i o n >\n ' ) h . write ( ' <e q u a l s prop=" type ">song</ e q u a l s >\n ' ) h . write ( ' <subquery >\n ' ) h . write ( ' <c o n j u n c t i o n >\n ' ) h . write ( ' <g r e a t e r prop=" r a t i n g " >4.000000 < / g r e a t e r >\n ' ) h . write ( ' </ c o n j u n c t i o n >\n ' ) h . write ( ' </ subquery >\n ' ) h . write ( ' </ c o n j u n c t i o n >\n ' ) h . w r i t e ( ' </ p l a y l i s t >\n ' ) h . w r i t e ( ' < p l a y l i s t name=" R e c e n t l y Added" type=" a u t o m a t i c " s o r t −key=" A r t i s t " s o r t − d i r e c t i o n=" 0 ">\n ' ) h . write ( ' <c o n j u n c t i o n >\n ' ) h . write ( ' <e q u a l s prop=" type ">song</ e q u a l s >\n ' ) h . write ( ' <subquery >\n ' ) h . write ( ' <c o n j u n c t i o n >\n ' ) h . write ( ' <c u r r e n t −time −w i t h i n prop=" f i r s t −s e e n ">604800< / c u r r e n t − time −w i t h i n >\n ' ) h . write ( ' </ c o n j u n c t i o n >\n ' ) h . write ( ' </ subquery >\n ' ) h . write ( ' </ c o n j u n c t i o n >\n ' ) h . w r i t e ( ' </ p l a y l i s t >\n ' ) h . w r i t e ( ' < p l a y l i s t name=" R e c e n t l y Played " type=" a u t o m a t i c " s o r t −key=" A r t i s t " s o r t − d i r e c t i o n=" 1 ">\n ' ) h . write ( ' <c o n j u n c t i o n >\n ' ) h . write ( ' <e q u a l s prop=" type ">song</ e q u a l s >\n ' ) h . write ( ' <subquery >\n ' ) h . write ( ' <c o n j u n c t i o n >\n ' ) h . write ( ' <c u r r e n t −time −w i t h i n prop=" l a s t −p l a y e d ">604800< / c u r r e n t −time −w i t h i n >\n ' ) 127 CHAPTER 17. SHELL SCRIPTS h . write ( ' h . write ( ' h . write ( ' h . write ( ' </ c o n j u n c t i o n >\n ' ) </ subquery >\n ' ) </ c o n j u n c t i o n >\n ' ) </ p l a y l i s t >\n ' ) not o s . path . e x i s t s ( ' p l a y l i s t s ' ) : o s . makedirs ( ' p l a y l i s t s ' ) os . chdir ( ' p l a y l i s t s ' ) a = open ( ' o r d e r_ f i l e ' , ' r ' ) for b in a . x r e a d l i n e s ( ) : i f b [ − 1 : ] == ' \ n ' : b = b[: −1] i f b [ − 1 : ] == ' \ r ' : b = b[: −1] i f b == 'EOF' : if break c = open ( b + '. p l a y l i s t ' , ' r ' ) b = s t r i n g . r e p l a c e ( b , '& ' , '& ; ' ) h . w r i t e ( ' < p l a y l i s t name=" '+b+'" type=" s t a t i c ">\n ' ) for l i n e in c . x r e a d l i n e s ( ) : i f l i n e [ − 1 : ] == ' \ n ' : l i n e = l i n e [: −1] i f l i n e [ − 1 : ] == ' \ r ' : l i n e = l i n e [: −1] i f l i n e != 'EOF' : i f l i n e . f i n d ( ' \ t ' ) != − 1: l i n e = l i n e [ : l i n e . find ( '\ t ' ) ] l i n e = s t r i n g . r e p l a c e ( l i n e , '& ' , '& ; ' ) h . write ( ' <l o c a t i o n >'+ l i n e +'</ l o c a t i o n >\n ' ) else : break c . close () h . w r i t e ( ' </ p l a y l i s t >\n ' ) a . close () h . w r i t e ( ' < / rhythmdb− p l a y l i s t s >\n ' ) h . close () 17.2 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 17.3 backupSyst #! / b i n / sh #i n i t i a l i z a t i o n HOME=/home/manu E. Branlard 128 CHAPTER 17. SHELL SCRIPTS f o l d e r=backup_data / mydate=$ ( d a t e +%Y−%m−%d−%H%M) f o l d e r=$HOME" / C o n f i g / " $ f o l d e r $ mydate mkdir −p $ f o l d e r cd $ f o l d e r echo $ 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 home/ m o z i l l a / f i r e f o x / 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 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/ C o n f i g / p r o f i l e s / bash * home / cp $HOME/ . vimrc home / vimrc cp − r $HOME/ . vim / home / vim 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 / * . xml home / l o c a l / s h a r e / rhythmbox / #cp −r $HOME/ . m o z i l l a / f i r e f o x home / m o z i l l a / f i r e f o x #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 E. Branlard 129 CHAPTER 17. SHELL SCRIPTS . d a i l y /* e t c / c r o n . d a i l y / . 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 / cp / e t c / c r o n cp / e t c / c r o n #programs cp / e t c / l a t e x 2 h t m l . c o n f e t c / cp / e t c / texmf / texmf . 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 #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 17.4 RisoUnMount #! / b i n / bash ############################################################# E. Branlard 130 CHAPTER 17. SHELL SCRIPTS # Default script : ############################################################# umount /mnt/R−home/ umount /mnt/S−group / umount /mnt/T−apps / umount /mnt/U−garb / 17.5 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 ) 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 ] ) 17.6 syncStorage #! / b i n / sh # S o u l d be run as u s e r E. Branlard 131 CHAPTER 17. SHELL SCRIPTS #v a r i a b l e s OPTS="−av " DEST=/ media / S t o r a g e ############## # DATAWIN ############## SRC=/ media / DataWin #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 / " 17.7 audioInfo #! / 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 } ' ` E. Branlard 132 CHAPTER 17. SHELL SCRIPTS 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" 17.8 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 17.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 17.10 texclean #! rm rm rm rm rm rm / b i n / bash * . aux * . toc * . log * . bbl * . out * . cb E. Branlard 133 CHAPTER 17. SHELL SCRIPTS rm rm rm rm rm rm rm rm rm rm rm rm rm rm rm * . blg *. lot *. lof * . tps * . maf *. ilg * . glo * . mtc * * . ptc* * . bmt * . idx * . ind * . snm * . nav * . cb2 17.11 sendit #! / b i n / sh ############################################################# # Send I t ############################################################# # D e s c r i p t i o n : Send f i l e by e m a i l # Written by : Emmanuel Branlard # Date : October 2011 # Dependencies : mutt # 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 ############################################################# #n o t i f y −send " Email t o : $ a $ 1" mydate=$ ( d a t e +%Y−%m−%d−%H%M−%S ) ; xterm −geometry 30 x2+550+400 +sb −e ' echo " e m a i l a d d r e s s " ; read a ; echo $ a>/ tmp/ s e n d i t $ mydate . tmp ' ; #xterm − geometry 30 x2+550+400 +s b −e ' a=EMAIL@gmail . com ; mydate=$ ( d a t e +%Y −%m−%d−%H%M−%S ) ; echo $ a>/ tmp / s e n d i t $ mydate . tmp ; a ' ; export t o =` c a t /tmp/ s e n d i t $ mydate . tmp ` ; n o t i f y −send " $ t o $@" − i mail −attachment − t 3 0 0 0 ; " Hi I a t t a c h e d $# F i l e ( s ) t o t h i s e m a i l . Best , Emmanuel echo Sent with my geeky s h e l l s c r i p t " | mutt −a " $@" − s " Sent f i l e ( s ) ( $ 1 ) " −− $to ; rm /tmp/ s e n d i t $ mydate . tmp n o t i f y −send " F i l e s e n t ! $@" − t 3000 − i mail −f o r w a r d E. Branlard 134 CHAPTER 17. SHELL SCRIPTS 17.12 topdf #! if / b i n / bash [ $# − eq 0 ] then F i l e s=* . png 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 #c o n v e r t $ F i l e s " $ F i l e O u t " c o n v e r t −page A4 − u n i t s P i x e l s P e r I n c h − n o r m a l i z e − d e n s i t y 100 FileOut " $Files "$ 17.13 pdfFind #! / b i n / bash echo " Looking f o r " $ 1 SAVEIFS=$ IFS IFS=$ ( echo −en " \n\b" ) E. Branlard 135 CHAPTER 17. SHELL SCRIPTS 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 done ; IFS=$SAVEIFS echo echo $1 17.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 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 17.15 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 E. Branlard 136 CHAPTER 17. SHELL SCRIPTS 17.16 svg2latex.py #! / u s r / b i n / python ''' Copyright (C) 2 0 0 8 , 2 0 0 9 , 2 0 1 0 Richard Henwood , rjhenwood@yahoo . co . uk This program i s f r e e s o f t w a r e ; you can r e d i s t r i b u t e i t and / o r modify i t under t h e terms o f t h e GNU G e n e r a l P u b l i c L i c e n s e a s p u b l i s h e d by t h e Free S o f t w a r e Foundation ; e i t h e r v e r s i o n 2 o f t h e L i c e n s e , o r ( a t your o p t i o n ) any l a t e r v e r s i o n . This program i s d i s t r i b u t e d i n t h e hope t h a t i t w i l l be u s e f u l , but WITHOUT ANY WARRANTY; w i t h o u t even t h e i m p l i e d warranty o f MERCHANTABILITY o r FITNESS FOR A PARTICULAR PURPOSE. See t h e GNU G e n e r a l P u b l i c L i c e n s e f o r more d e t a i l s . You s h o u l d have r e c e i v e d a copy o f t h e GNU G e n e r a l P u b l i c L i c e n s e a l o n g with t h i s program ; i f not , w r i t e t o t h e Free S o f t w a r e Foundation , I n c . , 59 Temple Place , S u i t e 3 3 0 , Boston , MA 02111 − 1307 USA −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ''' # We w i l l use i n e x module w i t h p r e d e f i n e d e f f e c t b a s e c l a s s . import s t r i n g from o p t p a r s e import O p t i o n P a r s e r from xml . dom . minidom import p a r s e , p a r s e S t r i n g , Node from s t r i n g import Template import import import import import import import import import pprint re sys o s . path math subprocess tempfile shutil platform class svg2latex () : """ Constructor . D e f i n e s "−−what" o p t i o n o f a s c r i p t . "" " myHorizontalFudgePX = −8 # we have t o knudge t e x t o v e r a b i t t o g e t i t to align h o r i z o n t a l l y . #f l o w_x_ o f f s e t = − 3.47433 #f l o w_y_ o f f s e t = 9.4698369 f l o w_x_ o f f s e t = 0 . 0 f l o w_y_ o f f s e t = 0 . 0 ##################################################################### d e f s v g f i l e _h a n d l e r ( o p t i o n , opt , val ue , p a r s e r ) : p r i n t ( " o p t i o n = %s " % o p t i o n ) p r i n t ( " opt = %s " % opt ) p r i n t ( " v a l u e = %s " % v a l u e ) p r i n t ( " p a r s e r = %s " % p a r s e r ) E. Branlard 137 CHAPTER 17. SHELL SCRIPTS def __ i n i t __( self ) : # Call base c l a s s construtor . u s a g e = " "" Convert svg t o l a t e x p i c t u r e format and u s e I n k s c a p e t o g e n e r a t e a pdf f o r a l l t h e b i t s which a r e not t e x t . − f [−− s v g f i l e ] − l [−− l a t e x o u t f i l e ] −o −e c r e a t e an e p s <f i l e n a m e > s v g f i l e n a m e . <f i l e n a m e > name f o r l a t e x output f i l e . o v e r w r i t e t h e output f i l e s a u t o m a t i c a l l y . f i l e i n s t e a d o f pdf . A pdf f i l e i s a l s o c r e a t e d . This i s g i v e n t h e same name a s t h e l a t e x o u t f i l e with t h e e x t e n s i o n ' pdf ' . This f i l e i s g e n e r a t e d by I n k s c a p e , which must be on t h e path f o r t h i s s c r i p t t o work . """ p ar s e r = OptionParser ( usage ) p a r s e r . add_o p t i o n ( "− f " , "−− s v g f i l e " , d e s t=" s v g f i l e n a m e " , h e l p=" svg i n p u t f i l e " ) p a r s e r . add_o p t i o n ( "− l " , "−− l a t e x o u t f i l e " , d e s t=" l a t e x f i l e n a m e " , h e l p=" l a t e x f i l e t o output t o " ) p a r s e r . add_o p t i o n ( "−o " , "−− o v e r w r i t e " , d e s t=" o v e r w r i t e " , a c t i o n=" s t o r e_t r u e " , h e l p=" a u t o m a t i c a l l y o v e r w r i t e output " ) p a r s e r . add_o p t i o n ( "−e " , "−− e p s o u t p u t " , d e s t=" e p s o u t p u t " , a c t i o n=" s t o r e_t r u e " , h e l p="make e p s i n s t e a d o f pdf " ) ( 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 ( ) if o p t i o n s . l a t e x f i l e n a m e i s None : p r i n t ( "−− l a t e x o u t f i l e not s p e c i f i e d " ) sys . exit ( usage ) s e l f . latexfilename = options . latexfilename l a t e x h e a d , l a t e x t a i l = o s . path . s p l i t ( s e l f . l a t e x f i l e n a m e ) i f ( l a t e x h e a d i s not None and l a t e x h e a d i s not " " ) : l a t e x h e a d += o s . s e p l a t e x r o o t , l a t e x e x t = o s . path . s p l i t e x t ( l a t e x t a i l ) s e l f . e p s f i l e o u t p u t = None o p t i o n s . e p s o u t p u t i s None : s e l f . l a t e x i m a g e f i l e = l a t e x h e a d + l a t e x r o o t + ' . pdf ' else : s e l f . l a t e x i m a g e f i l e = l a t e x h e a d + l a t e x r o o t + ' . eps ' self . epsfileoutput = 1 if s e l f . l a t e x s v g t m p = t e m p f i l e . NamedTemporaryFile ( d e l e t e=F a l s e ) o p t i o n s . s v g f i l e n a m e i s None : p r i n t ( "−− s v g f i l e not s p e c i f i e d " ) sys . exit ( usage ) i f o p t i o n s . o v e r w r i t e i s None : s e l f . autooverwrite = 0 else : s e l f . autooverwrite = options . overwrite if E. Branlard 138 CHAPTER 17. SHELL SCRIPTS s e l f . svgfilename = options . svgfilename p r i n t ( " svg f i l e n a m e = %s " % s e l f . s v g f i l e n a m e ) p r i n t ( " l a t e x image f i l e = " + s e l f . l a t e x i m a g e f i l e ) print ( " latex input f i l e = " + s e l f . la te xf ile nam e ) s e l f . origsvg = parse ( s e l f . svgfilename ) s e l f . notextsvg = parse ( s e l f . svgfilename ) # t h e s e namespaces are u s e f u l . # xmlns : s o d i p o d i =" h t t p : // s o d i p o d i . s o u r c e f o r g e . n e t /DTD/ s o d i p o d i − 0. dtd " # xmlns : i n k s c a p e=" h t t p : //www. i n k s c a p e . org / namespaces / i n k s c a p e " # xmlns=" h t t p : //www. w3 . org / 2000 / s v g " ##################################################################### def tidyup ( s e l f ) : o s . u n l i n k ( s e l f . l a t e x s v g t m p . name ) ##################################################################### d e f makePDF( s e l f ) : # f i r s t , make a copy o f t h e s v g w i t h a l l t h e t e x t removed . f o r e l e m e n t i n s e l f . n o t e x t s v g . getElementsByTagName ( " flowRoot " ) : e l e m e n t . parentNode . removeChild ( e l e m e n t ) for e l e m e n t i n s e l f . n o t e x t s v g . getElementsByTagName ( " t e x t " ) : e l e m e n t . parentNode . removeChild ( e l e m e n t ) # and s a v e i t i n a temp f i l e s e l f . notextsvg . writexml ( s e l f . latexsvgtmp ) s e l f . latexsvgtmp . c l o s e ( ) # # # # # now c a l l i n k s c a p e w i t h t h i s f i l e t o produce a pdf version . TODO: t h i s i s a hard dependency on i n k s c a p e which might be n i c e t o r e p l a c e w i t h c a i r o a t some l a t e r date . . . t e m p p d f f i l e = t e m p f i l e . NamedTemporaryFile ( d e l e t e=F a l s e ) temppdffile . close () exportcmd = "−−export −e p s " i f s e l f . e p s f i l e o u t p u t i s None : exportcmd = " −−export −pdf " inkscapecmd = " i n k s c a p e " i f p l a t f o r m . system ( ) == ' Windows ' : inkscapecmd = "C: \ \ Program F i l e s \\ I n k s c a p e \\ i n k s c a p e . exe " s y s . s t d e r r . w r i t e ( inkscapecmd+exportcmd+t e m p p d f f i l e . name+"−− f i l e "+ s e l f . l a t e x s v g t m p . name+" \n" ) s u b p r o c e s s . c a l l ( [ inkscapecmd , exportcmd , t e m p p d f f i l e . name , " −− f i l e " , s e l f . l a t e x s v g t m p . name ] ) #p r i n t " c o p y i n g f i l e t o : " + s e l f . l a t e x i m a g e f i l e s h u t i l . copy ( t e m p p d f f i l e . name , s e l f . l a t e x i m a g e f i l e ) E. Branlard 139 CHAPTER 17. SHELL SCRIPTS o s . u n l i n k ( t e m p p d f f i l e . name ) ##################################################################### def toLatex ( s e l f ) : filename = s e l f . latexfilename i f o s . path . i s f i l e ( f i l e n a m e ) and not s e l f . a u t o o v e r w r i t e : sys . stderr . write (" File ' " + filename + " ' already e x i s t s . Q u i t t i n g . \ n" ) sys . exit ( ) FILE = open ( f i l e n a m e , "w" ) # we need t o e x t r a c t t h e g l o b a l t r a n s l a t i o n o f t h e whole # page . dom1 = p a r s e ( s e l f . s v g f i l e n a m e ) #p p r i n t . p p r i n t ( dom1 ) e l e_g = dom1 . getElementsByTagName ( " g " ) [ 0 ] e l e_svg = dom1 . getElementsByTagName ( " svg " ) [ 0 ] p g h e i g h t = e l e_svg . a t t r i b u t e s [ " h e i g h t " ] . v a l u e i f p g h e i g h t . e n d s w i t h ( "mm" ) : p g h e i g h t = p g h e i g h t . r s t r i p ( "mm" ) pgheight = f l o a t ( pgheight ) * 3.5433 pgwidth = e l e_svg . a t t r i b u t e s [ " width " ] . v a l u e i f pgwidth . e n d s w i t h ( "mm" ) : pgwidth = pgwidth . r s t r i p ( "mm" ) pgwidth = f l o a t ( pgwidth ) * 3 . 5 4 3 3 l a t e x s t r = s e l f . page_i n f o ( pgwidth , p g h e i g h t ) # TODO, remove t h e g_t r a n s var from g l o b a l s c o p e . f o r node i n dom1 . getElementsByTagName ( " flowRoot " ) : g_t r a n s_x , g_t r a n s_y = s e l f . g e t_g_t r a n s ( node ) l a t e x s t r += " \n" l a t e x s t r += s e l f . p r o c e s s_f l o w ( node , pgwidth , p g h e i g h t , g_t r a n s _x , g_t r a n s_y ) l a t e x s t r += " \n" f o r node i n dom1 . getElementsByTagName ( " t e x t " ) : g_t r a n s_x , g_t r a n s_y = s e l f . g e t_g_t r a n s ( node ) l a t e x s t r += " \n" l a t e x s t r += s e l f . p r o c e s s_t e x t ( node , pgwidth , p g h e i g h t , g_t r a n s _x , g_t r a n s_y ) l a t e x s t r += " \n" l a t e x s t r += " \\ end { p i c t u r e }\n" l a t e x s t r += " \\ endgroup \n" FILE . w r i t e l i n e s ( s t r ( l a t e x s t r . encode ( " u t f −8" ) ) ) FILE . c l o s e ( ) ##################################################################### d e f g e t_g_t r a n s ( s e l f , node ) : #p p r i n t . p p r i n t ( node . t o x m l ( ) ) x_t r a n s , y_t r a n s = ( 0 , 0 ) while not node . nodeType == Node .DOCUMENT_NODE: i f node . h a s A t t r i b u t e ( " t r a n s f o r m " ) == True : #p r i n t " found t r a n s f o r m . . . " E. Branlard 140 CHAPTER 17. SHELL SCRIPTS t r a n s_s t r = node . a t t r i b u t e s [ " t r a n s f o r m " ] . v a l u e ; tmp_x , tmp_y = s e l f . g e t_t r a n s ( t r a n s_s t r ) x_t r a n s += tmp_x y_t r a n s += tmp_y node = node . parentNode return x_t r a n s , y_t r a n s d e f g e t_t r a n s ( s e l f , t r a n s_s t r ) : t r a n s_s t r = t r a n s_s t r . r s t r i p ( " ) " ) x_t r a n s = 1 . 0 y_t r a n s = 1 . 0 i f " t r a n s l a t e " i n t r a n s_s t r : #p r i n t " t r a n s l a t e ! s t r = " , t r a n s_s t r t r a n s_s t r = t r a n s_s t r . l s t r i p ( " t r a n s l a t e ( " ) v a l u e s = t r a n s_s t r . s p l i t ( " , " ) else : #p r i n t " not t r a n s l a t e ! s t r = " , t r a n s_s t r t r a n s_s t r = t r a n s_s t r . l s t r i p ( " matrix ( " ) v a l u e s = t r a n s_s t r . s p l i t ( " , " ) # f i x the x , y i f there i s a s c a l e value included in the matrix #p r i n t " v a l u e s = " , v a l u e s [ 0 ] , v a l u e s [ 3 ] #v a l u e s [ − 2] = f l o a t ( v a l u e s [ 0 ] ) * f l o a t ( v a l u e s [ − 2]) #v a l u e s [ − 1] = f l o a t ( v a l u e s [ 3 ] ) * f l o a t ( v a l u e s [ − 1]) return f l o a t ( values [ −2]) , f l o a t ( values [ −1]) d e f g e t_g l o b a l_t r a n s ( s e l f , t r a n s_s t r ) : tmp_s t r = t r a n s_s t r . l s t r i p ( " t r a n s l a t e ( " ) tmp_s t r = tmp_s t r . r s t r i p ( " ) " ) return map( lambda x : f l o a t ( x ) , tmp_s t r . s p l i t ( " , " ) ) ##################################################################### d e f page_i n f o ( s e l f , pgwidth , p g h e i g h t ) : pagestr pagestr pagestr SVG pagestr pagestr pagestr pagestr pagestr pagestr pagestr pagestr pagestr return = '' += " \\ b e g i n g r o u p \n" += " \ s e t l e n g t h {\ u n i t l e n g t h } { 0 . 8 pt }\n" # t h i s i s s t a n d a r d u n i t s , as PT. += " \\ b e g i n { p i c t u r e } ( " += s t r ( pgwidth ) += " , " += s t r ( p g h e i g h t ) += " ) \n" += " \ put ( 0 , 0 ) {\ i n c l u d e g r a p h i c s " += " { " += r e . sub ( r ' \ \ ' , r ' / ' , s e l f . l a t e x i m a g e f i l e ) += " }}\n" pagestr ##################################################################### d e f p r o c e s s_s t y l e ( s e l f , s t y l e n o d e ) : c o l o r = "{ black }" f o n t S i z e = "" c us t o m Co l o rs = " " colorNum = 1 mboxcode = ' ' fontSizeInt = 1; E. Branlard 141 CHAPTER 17. SHELL SCRIPTS fontSizeFloat = 10; i f s t y l e n o d e i s not None : for styleElement in s t r i n g . s p l i t ( stylenode , '; ') : d i r e c t i v e , value = s t r i n g . s p l i t ( styleElement , ' : ' ) i f d i r e c t i v e == " t e x t − a l i g n " : #p r i n t " d i r e c t i v e found : " , d i r e c t i v e , v a l u e i f v a l u e == ' c e n t e r ' : mboxcode = ' c ' e l i f v a l u e == ' end ' : mboxcode = ' r ' else : mboxcode = ' l ' i f d i r e c t i v e == " f i l l " : i f r e . match ( r ' ^# ' , v a l u e ) i s not None : c o l o r = " { i n k c o l " + ` colorNum ` + " } " red = '0x ' + value [ 1 : 3 ] green = '0x ' + value [ 3 : 5 ] blue = '0x ' + value [ 5 : 7 ] c us t o m Co l o rs += " \\ d e f i n e c o l o r { i n k c o l " + ` colorNum ` + " }{ rgb }{ " c us t o m Co l o rs += ` e v a l ( r e d ) / 2 5 5 . 0 ` + ' , ' c us t o m Co l o rs += ` e v a l ( g r e e n ) / 2 5 5 . 0 ` + ' , ' c us t o m Co l o rs += ` e v a l ( b l u e ) / 2 5 5 . 0 ` + ' } \ n ' colorNum += 1 else : c o l o r = "{" + value + "}" i f d i r e c t i v e == " f o n t − s i z e " : fontSize , f ont Si zeF lo at = s e l f . fontSizeLookup ( value ) #p r i n t " f o n t s i z e : " + f o n t S i z e #p r i n t " f o n t s i z e f l o a t : " + f o n t S i z e F l o a t return c o l o r , f o n t S i z e , customColors , colorNum , mboxcode , fontSizeFloat ##################################################################### d e f p r o c e s s_t s p a n_t r a n s f o r m ( s e l f , t r a n s f o r m , tmpx , tmpy ) : rotate = 0 transX = 0 transY = 0 i f t r a n s f o r m i s not None : transArrTmp = r e . s p l i t ( r " [ , \ ( \ ) ] " , t r a n s f o r m ) transArr = [ ] f o r e l e m e n t i n transArrTmp : i f r e . s e a r c h ( '^[ − +]?\ d +\.?\ d * ' , e l e m e n t ) : t r a n s A r r . append ( e l e m e n t ) transX = tmpx #f l o a t ( t r a n s A r r [ − 2]) transY = tmpy #f l o a t ( t r a n s A r r [ − 1]) i f r e . match ( r ' ^ matrix ' , t r a n s f o r m ) i s not None : r o t a t e = s e l f . g e t_a n g l e ( t r a n s A r r [ 0 ] , t r a n s A r r [ 1 ] , t r a n s A r r [ 2 ] , transArr [ 3 ] ) # p r i n t " d e t e r m i n a n t= " , s e l f . g e t_d e t e r m i n a n t ( t r a n s A r r [ 0 ] , transArr [ 1 ] , transArr [ 2 ] , transArr [ 3 ] ) transX , transY = s e l f . do_t r a n s f o r m ( t r a n s A r r [ 0 ] , t r a n s A r r [ 2 ] , t r a n s A r r [ 1 ] , t r a n s A r r [ 3 ] , tmpx , tmpy ) return r o t a t e , transX , transY ##################################################################### # t h i s p r o c e s s e s <t e x t > dom e l e m e n t s . # i t i s as u g l y as i t l o o k s . # TODO: add code t o d e a l w i t h ' a l i g n −c e n t r e ' s t y l e . E. Branlard 142 CHAPTER 17. SHELL SCRIPTS d e f p r o c e s s_t e x t ( s e l f , flowNode , imgWidth , imgHeight , g_x_t r a n s , g_y_ trans ) : #t m p s t r = ' ' s t y l e = flowNode . a t t r i b u t e s [ " s t y l e " ] c o l o r , f o n t S i z e , customColors , colorNum , mboxcode , f o n t S i z e I n t = s e l f . p r o c e s s_s t y l e ( s t y l e . v a l u e ) put = Template ( ' \ put ( $ x , $ y ) ' ) r o t a t e , transX , transY = ( 0 . 0 , 0 . 0 , 0 . 0 ) tmpx = f l o a t ( flowNode . a t t r i b u t e s [ "x" ] . v a l u e ) tmpy = f l o a t ( flowNode . a t t r i b u t e s [ "y" ] . v a l u e ) if flowNode . h a s A t t r i b u t e ( " t r a n s f o r m " ) : t r a n s f o r m = flowNode . a t t r i b u t e s [ " t r a n s f o r m " ] . v a l u e # t h i s i s a hack f o r t h e c a s e s where i n k s c a p e o p t i m i s e s # a 180 o r o t a t i o n i n t o a s c a l e ( − 1, − 1) i f transform . startswith ( " s c a l e ( " ) : t r a n s f o r m = " matrix ( − 1 ,0 ,0 , − 1) " r o t a t e , transX , transY = s e l f . p r o c e s s_t s p a n_t r a n s f o r m ( transform , 0 . 0 , 0 . 0 ) alltext = ' ' ( x2 , y2 ) = ( None , None ) f o r e l e m e n t i n flowNode . getElementsByTagName ( " t s p a n " ) : #x1 = ( f l o a t ( e l e m e n t . a t t r i b u t e s [ " x " ] . v a l u e ) ) #y1 = ( f l o a t ( e l e m e n t . a t t r i b u t e s [ " y " ] . v a l u e ) ) x1 = tmpx y1 = tmpy x2 = transX + x1 * math . c o s ( r o t a t e ) − y1 * math . s i n ( r o t a t e ) y2 = transY + x1 * math . s i n ( r o t a t e ) + y1 * math . c o s ( r o t a t e ) x2 += g_x_t r a n s y2 += g_y_t r a n s y2 = f l o a t ( imgHeight ) − y2 myWidth = f l o a t ( imgWidth ) if mboxcode == ' c ' : # t h i s b l o c k a d j u s t s x coord f o r # c a s e s where we wish t o c e n t r e t h e t e x t . x2 −= myWidth/ 2 . 0 if element . hasAttribute ( " s t y l e " ) : f o n t S i z e = s e l f . g e t_f o n t s i z e ( e l e m e n t . a t t r i b u t e s [ " s t y l e " ] . val ue , f o n t S i z e ) e l e m e n t . f i r s t C h i l d i s not None : a l l t e x t += " \\ t e x t c o l o r " + c o l o r + " {" + f o n t S i z e + " { " + e l e m e n t . f i r s t C h i l d . data + " }}\\\\\ n" if # v s k i p −1cm #p r i n t " t e x t : " + a l l t e x t + " g_pos " , g_x_t r a n s , g_y_t r a n s #p r i n t "\n" t x t = Template ( ' { \ \ r o t a t e b o x { ' + ` s e l f . toDEG( r o t a t e ) ` + ' } { \ makebox ( 0 , 0 ) [ t l ] { \ s t r u t {}{ $ t e x t }}}}%\n ' ) E. Branlard 143 CHAPTER 17. SHELL SCRIPTS miniPg = ' \ n \\ b e g i n { minipage } [ h ] { ' + s t r ( myWidth * 0 . 8 ) + ' pt }\\ v s p a c e {−2ex }\n ' i f mboxcode == ' c ' : miniPg += ' \ \ b e g i n { c e n t e r }\n ' miniPg += a l l t e x t miniPg += ' \ \ end { c e n t e r }\n ' e l i f mboxcode == ' r ' : miniPg += ' \ \ b e g i n { f l u s h r i g h t }\n ' miniPg += a l l t e x t miniPg += ' \ \ end { f l u s h r i g h t }\n ' else : miniPg += a l l t e x t miniPg += ' \ end { minipage } ' c u st o m Co l o rs + put . s u b s t i t u t e ( x=x2 , y=y2 ) + t x t . s u b s t i t u t e ( t e x t=miniPg ) return ##################################################################### d e f p r o c e s s_f l o w ( s e l f , flowNode , imgWidth , imgHeight , g_x_t r a n s , g_y_ trans ) : tmpstr = ' ' s t y l e = flowNode . a t t r i b u t e s [ " s t y l e " ] c o l o r , f o n t S i z e , customColors , colorNum , mboxcode , f o n t S i z e I n t = s e l f . p r o c e s s_s t y l e ( s t y l e . v a l u e ) put = Template ( ' \ put ( $ x , $ y ) ' ) #p r i n t " f l o w p r o c e s s i n g " r o t a t e , transX , transY = ( 0 . 0 , 0 . 0 , 0 . 0 ) i f flowNode . h a s A t t r i b u t e ( " t r a n s f o r m " ) : t r a n s f o r m = flowNode . a t t r i b u t e s [ " t r a n s f o r m " ] r o t a t e , transX , transY = s e l f . p r o c e s s_t s p a n_t r a n s f o r m ( t r a n s f o r m . va lue , 0 . 0 , 0 . 0 ) for e l e m e n t i n flowNode . getElementsByTagName ( " r e c t " ) : x1 = ( f l o a t ( e l e m e n t . a t t r i b u t e s [ "x" ] . v a l u e ) )# + g_x_t r a n s + s e l f . f l o w_x_ o f f s e t y1 = ( f l o a t ( e l e m e n t . a t t r i b u t e s [ "y" ] . v a l u e ) )# + g_y_t r a n s + s e l f . f l o w_y_ o f f s e t x2 = transX + x1 * math . c o s ( r o t a t e ) − y1 * math . s i n ( r o t a t e ) y2 = transY + x1 * math . s i n ( r o t a t e ) + y1 * math . c o s ( r o t a t e ) x2 = x2 + g_x_t r a n s y2 = y2 + g_y_t r a n s #p r i n t " x2 : " , ( f l o a t ( e l e m e n t . a t t r i b u t e s [ " x " ] . v a l u e ) ) , g_x_ t r a n s , transX , x1 , x2 #p r i n t " y2 : " , ( f l o a t ( e l e m e n t . a t t r i b u t e s [ " y " ] . v a l u e ) ) , g_y_ t r a n s , transY , y1 , y2 y2 = f l o a t ( imgHeight ) − y2 tmpstr += put . s u b s t i t u t e ( x=x2 , y=y2 ) myWidth = f l o a t ( e l e m e n t . a t t r i b u t e s [ " width " ] . v a l u e ) alltext = ' ' e l e m e n t i n flowNode . getElementsByTagName ( " f l o w P a r a " ) : i f element . hasAttribute ( " s t y l e " ) : f o n t S i z e = s e l f . g e t_f o n t s i z e ( e l e m e n t . a t t r i b u t e s [ " s t y l e " ] . val ue , f o n t S i z e ) i f e l e m e n t . f i r s t C h i l d i s not None : for E. Branlard 144 CHAPTER 17. SHELL SCRIPTS a l l t e x t += " \\ t e x t c o l o r " + c o l o r + " {" + f o n t S i z e + " { " + e l e m e n t . f i r s t C h i l d . data + " }}\\\\\ n" #p r i n t a l l t e x t t x t = Template ( ' { \ \ r o t a t e b o x { ' + ` s e l f . toDEG( r o t a t e ) ` + ' } { \ makebox ( 0 , 0 ) [ t l ] { \ s t r u t {}{ $ t e x t }}}}%\n ' ) miniPg = ' \ n \\ b e g i n { minipage } [ h ] { ' + s t r ( myWidth * 0 . 8 ) + ' pt }\n ' i f mboxcode == ' c ' : miniPg += ' \ \ b e g i n { c e n t e r }\n ' miniPg += a l l t e x t miniPg += ' \ \ end { c e n t e r }\n ' e l i f mboxcode == ' r ' : miniPg += ' \ \ b e g i n { f l u s h r i g h t }\n ' miniPg += a l l t e x t miniPg += ' \ \ end { f l u s h r i g h t }\n ' else : miniPg += a l l t e x t miniPg += ' \ end { minipage } ' tmpstr += t x t . s u b s t i t u t e ( t e x t=miniPg ) return c u st o m Co l o rs + tmpstr ##################################################################### d e f g e t_f o n t s i z e ( s e l f , a t t , f o n t S i z e ) : s i z e = a t t . p a r t i t i o n ( " f o n t −s i z e : " ) [ 2 ] size = size . partition (" ; ") [0] i f s i z e i s None : return f o n t S i z e return s e l f . f o n t S i z e L o o k u p ( s i z e ) [ 0 ] def do_t r a n s f o r m ( self , a ,b , c ,d , x , y) : x2 = f l o a t ( a ) * f l o a t ( x ) + f l o a t ( b ) * f l o a t ( y ) y2 = f l o a t ( c ) * f l o a t ( x ) − f l o a t ( d ) * f l o a t ( y ) return ( x2 , y2 ) d e f undo_t r a n s f o r m ( s e l f , a , b , c , d , x , y ) : x2 = f l o a t ( a ) * f l o a t ( x ) + f l o a t ( b ) * f l o a t ( y ) y2 = − f l o a t ( c ) * f l o a t ( x ) + f l o a t ( d ) * f l o a t ( y ) return ( x2 , y2 ) d e f g e t_d e t e r m i n a n t ( s e l f , a , b , c , d ) : return f l o a t ( a ) * f l o a t ( d ) − f l o a t ( b ) * f l o a t ( c ) d e f g e t_a n g l e ( s e l f , x1 , x2 , y1 , y2 ) : #s y s . s t d e r r . w r i t e (" a n g l e '" + x1 + " ' . " + x2 + " ' . " + y1 + " ' . " + y2 + " ' . " ) acosA = math . a c o s ( f l o a t ( x1 ) ) i f ( math . a s i n ( f l o a t ( x2 ) ) >= 0 ) : return f l o a t ( acosA ) else : return 2 * math . p i − f l o a t ( acosA ) d e f toDEG( s e l f , rad ) : return 360 − 180.0 * rad / math . p i def fontSizeLookup ( s e l f , pxSize ) : E. Branlard 145 CHAPTER 17. SHELL SCRIPTS s i z e S t r = " \\ n o r m a l s i z e " i f not r e . s e a r c h ( ' px $ ' , p x S i z e ) : try : f l o a t ( pxSize ) except ValueError : s y s . s t d e r r . w r i t e ( " found u n u s u a l f o n t s i z e : " + p x S i z e + " assuming ' \ \ n o r m a l s i z e ' m i s s i n g . \ n" ) return " \\ n o r m a l s i z e " , 10 s y s . s t d e r r . w r i t e ( " found u n u s u a l f o n t s i z e : " + p x S i z e + " assuming ' px ' m i s s i n g . \ n" ) p x S i z e += "px" #p r i n t " P x s i z e = " + p x S i z e s i z e = r e . s p l i t ( r "px $ " , p x S i z e ) #p r i n t " s i z e = " + s i z e size [0] = float ( size [0]) if size [ 0 ] < 7: return " \\ t i n y " , s i z e [ 0 ] if size [ 0 ] < 8: return " \\ s c r i p t s i z e " , s i z e [ 0 ] if size [ 0 ] < 9: return " \\ f o o t n o t e s i z e " , s i z e [ 0 ] i f size [ 0 ] < 10: return " \\ s m a l l " , s i z e [ 0 ] i f size [ 0 ] < 12: return " \\ n o r m a l s i z e " , s i z e [ 0 ] i f size [ 0 ] < 14: return " \\ l a r g e " , s i z e [ 0 ] i f size [ 0 ] < 18: return " \\ Large " , s i z e [ 0 ] i f size [ 0 ] < 20: return " \\LARGE" , s i z e [ 0 ] i f size [ 0 ] < 24: return " \\ huge " , s i z e [ 0 ] i f s i z e [ 0 ] >= 2 4 : return " \\Huge" , s i z e [ 0 ] s y s . s t d e r r . w r i t e ( " found u n u s u a l f o n t s i z e : " + p x S i z e + " assuming normalsize . ") return " \\ n o r m a l s i z e " , 10 #\ t i n y 5 5 #\ s c r i p t s i z e 7 7 #\ f o o t n o t e s i z e 8 8 #\ s m a l l 9 9 #\ n o r m a l s i z e 10 10 #\ l a r g e 12 12 #\ Large 14 1 4 . 4 0 #\LARGE 18 1 7 . 2 8 #\ huge 20 2 0 . 7 4 #\Huge 24 2 4 . 8 8 #e l s e : # s y s . s t d e r r . w r i t e (" found u n u s u a l f o n t s i z e : " + p x S i z e + " assuming n o r m a l s i z e . " ) # r e t u r n "\\ n o r m a l s i z e " , 10 E. Branlard 146 CHAPTER 17. SHELL SCRIPTS s v g f i l e = svg2latex () s v g f i l e . toLatex ( ) s v g f i l e . makePDF ( ) s v g f i l e . tidyup ( ) p r i n t ( " completed " ) 17.17 RisoMount #! / b i n / bash ############################################################# # Default script : ############################################################# mount /mnt/R−home/ mount /mnt/S−group / mount /mnt/T−apps / mount /mnt/U−garb / 17.18 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 17.19 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 echo E. Branlard "− Pre− p r o c e s s i n g $f ... "; 147 CHAPTER 17. SHELL SCRIPTS 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" ; 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 . . . " 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 ] ; echo 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_* 17.20 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 . E. Branlard 148 CHAPTER 17. SHELL SCRIPTS # 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 " 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 echo E. Branlard " " 149 CHAPTER 17. SHELL SCRIPTS "− Binding with p d f t k . . . " p d f t k pg_* . png . pdf output " . . /$1−OCR. pdf " 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_* 17.21 PulseMediaKeys.sh #! / b i n / bash #### Create ~/ . p u l s e / mute i f not e x i s t s l s ~/ . p u l s e / mute &> / dev / n u l l i f [ [ $ ? != 0 ] ] then "false" > echo ~/ . p u l s e / mute fi ####Create ~/ . p u l s e / volume i f not e x i s t s l s ~/ . p u l s e / volume &> / dev / n u l l i f [ [ $ ? != 0 ] ] then " 65536 " > echo ~/ . p u l s e / volume fi CURVOL=` c a t ~/ . p u l s e / volume ` MUTE=` c a t ~/ . p u l s e / mute ` if [[ $1 #Reads i n t h e c u r r e n t volume #Reads mute s t a t e == " i n c r e a s e " ] ] then CURVOL=$ ( ( $CURVOL + 1 3 1 1 ) ) #3277 i s 5% o f t h e t o t a l volume , you can change t h i s t o s u i t your needs . i f [ [ $CURVOL − ge 95536 ] ] then CURVOL=95536 fi elif [[ $1 == " d e c r e a s e " ] ] then CURVOL=$ ( ( $CURVOL − 1 3 1 1 ) ) i f [ [ $CURVOL − l e 0 ] ] then CURVOL=0 fi elif [[ $1 == "mute" ] ] then if [[ $MUTE == " f a l s e " ] ] then E. Branlard 150 CHAPTER 17. SHELL SCRIPTS pactl s e t −s i n k −mute 1 1 " t r u e " > ~/ . p u l s e / mute i c o n=" audio −volume−muted" n o t i f y −send − t 500 − i $ i c o n "Mute : on" echo exit else pactl s e t −s i n k −mute 1 0 " f a l s e " > ~/ . p u l s e / mute i c o n="audio −volume −low " i f [ [ $CURVOL − ge 50000 ] ] then i c o n="audio −volume − h i g h " e l i f [ [ $CURVOL − ge 30000 ] ] then i c o n="audio −volume −medium" fi a=00 p=` e x p r $CURVOL$ a / 65536 ` i c o n=" audio −volume−medium" n o t i f y −send − t 1000 − i $ i c o n "Mute : o f f " echo # # # # # # # # # # exit fi fi # a=00 # p=` e x p r $CURVOL$ a / 65536 ` # i c o n="audio −volume −low " # i f [ [ $CURVOL − ge 50000 ] ] # then # i c o n="audio −volume − h i g h " # e l i f [ [ $CURVOL − ge 30000 ] ] # then # i c o n="audio −volume −medium" # fi #echo $CURVOL pactl s e t −s i n k −volume 1 $CURVOL > ~/ . p u l s e / volume # Write t h e new volume t o d i s k t o be read t h e n e x t time t h e s c r i p t i s run . # n o t i f y −send − t 500 − i $ i c o n " $ p%" echo $CURVOL 17.22 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 17.23 keyboardSetup #! / b i n / bash "−−−−−−−−−−−−−−−−−−−−−−− BEGIN KEYBOARD SETUP −−−−−−−−−−−−−−−−−−−−−−−−−−−" setxkbmap − o p t i o n compose : r a l t echo E. Branlard 151 CHAPTER 17. SHELL SCRIPTS "−−−−−−−−−−−−−−−−−−−−−−− END KEYBOARD SETUP −−−−−−−−−−−−−−−−−−−−−−−−−−−" echo 17.24 pdfAutoRename #! / b i n / sh i i n * . pdf ; do "" echo " −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− "; f i l e b a s e=$ { i %. * } ; for echo 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 ` echo E. Branlard $ 152 CHAPTER 17. SHELL SCRIPTS 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" 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 "RISO INSIDE" [ ` expr l e n g t h " $ t i t l e R i s 1 " ` − g t 12 ] echo if 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 E. Branlard 153 CHAPTER 17. SHELL SCRIPTS echo 7 − $titleupper 8 − $ titleECN "" 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 " ] echo echo then " Using c h o i c e $ c h o i c e " in 0 ) d e s t=" $ f i l e b a s e " ; ; 1 ) d e s t=" $ t i t l e " ; ; 2 ) d e s t=" $ t i t l e R i s 1 " ; ; 3 ) d e s t=" $ t i t l e R i s 2 " ; ; 4 ) d e s t=" $ t i t l e s a n d i a " ; ; 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 echo c a se $ c h o i c e 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 17.25 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 i f [ [ "$ f i l e " $ f i l e | sed −e ' s / [ ^ a−Z_0 − 9\. "$ n e w f i l e " ] ] / − ] // g ' ;` != 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 E. Branlard 154 CHAPTER 17. SHELL SCRIPTS 17.26 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 #~ #~ #~ 17.27 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 17.28 Terminator.sh #! / b i n / bash # echo "−−−−−−−−−−−−−−−−−−−−−−− BEGIN TERMINATOR −−−−−−−−−−−−−−−−−−−−−−−−−−−" # #x=` xrandr −− q u e r y | g r e p 2720 | wc − l ` ; #home # # sleep 5 E. Branlard 155 CHAPTER 17. SHELL SCRIPTS # echo "−−−−−−−−−−−−−−−−−−−−−−− BEGIN TERMINATOR −−−−−−−−−−−−−−−−−−−−−−−−−−−" # x=` xrandr −− q u e r y | g r e p 3360 | wc − l ` ; #r i s o # i f [ [ $x > 0 ] ] # then # t e r m i n a t o r −−geometry +2000 −m − l 4 terms / home /manu/ C o n f i g / b u i l d s / t e r m i n a t o r / t e r m i n a t o r − 0.95 / t e r m i n a t o r −− geometry +2000 −m − l 4 terms # else # t e r m i n a t o r −m − l 4 terms # fi # Screen 0 : minimum 2720 x 1024 , c u r r e n t 2720 x 1024 , maximum 2720 x 1024 # d e f a u l t c o n n e c t e d 2720 x1024+0+0 0mm x 0mm # 2720 x1024 50.0* 17.29 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 " " E. Branlard !" 156 CHAPTER 17. SHELL SCRIPTS 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 " canvas=" Page " e x p o r t o f=" Image à c o n v e r t i r : " ; ; esac ################################################# # 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 E. Branlard 157 CHAPTER 17. SHELL SCRIPTS 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 17.30 m3u2xspf.py #! / u s r / b i n / env python # # Convert an M3U p l a y l i s t t o XSPF. # # Usage : m3u2xspf < i n p u t . m3u > o u t p u t . x s p f # # C o p y r i g h t ( c ) 2006 , M a t t h i a s F r i e d r i c h <matt@mafr . de> # # This program i s f r e e s o f t w a r e ; you can r e d i s t r i b u t e i t and / or modify # i t under t h e terms o f t h e GNU General P u b l i c L i c e n s e as p u b l i s h e d by # t h e Free S o f t w a r e Foundation ; e i t h e r v e r s i o n 2 , or ( a t your o p t i o n ) # any l a t e r v e r s i o n . # # This program i s d i s t r i b u t e d i n t h e hope t h a t i t w i l l be u s e f u l , # b u t WITHOUT ANY WARRANTY; w i t h o u t even t h e i m p l i e d warranty o f # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See t h e # GNU General P u b l i c L i c e n s e f o r more d e t a i l s . # __r e v i s i o n__ = ' $ Id : m3u2xspf , v 1 . 4 2007 / 03 / 30 1 6 : 3 1 : 0 3 m a t t h i a s Exp matthias $ ' __v e r s i o n__ = ' 0 . 2 ' import import import import import import sys urllib urlparse o s . path optparse xml . sax . s a x u t i l s a s s a x u t i l s c l a s s XmlWriter ( o b j e c t ) : d e f __ i n i t __( s e l f , outStream , indentAmount =' s e l f ._out = outStream s e l f ._indentAmount = indentAmount s e l f ._s t a c k = [ ] ') : d e f p r o l o g ( s e l f , e n c o d i n g ='UTF− 8 ' , v e r s i o n = ' 1 . 0 ' ) : p i = '<?xml v e r s i o n="%s " e n c o d i n g="%s "?>' % ( v e r s i o n , e n c o d i n g ) s e l f ._out . w r i t e ( p i + ' \ n ' ) d e f s t a r t ( s e l f , name , a t t r s ={ } ) : i n d e n t = s e l f ._g e t I n d e n t i o n ( ) s e l f ._s t a c k . append ( name ) s e l f ._out . w r i t e ( i n d e n t + s e l f ._makeTag ( name , a t t r s ) + ' \ n ' ) d e f end ( s e l f ) : name = s e l f ._s t a c k . pop ( ) i n d e n t = s e l f ._g e t I n d e n t i o n ( ) E. Branlard 158 CHAPTER 17. SHELL SCRIPTS s e l f ._out . w r i t e ( '% s</%s >\n ' % ( i n d e n t , name ) ) d e f elem ( s e l f , name , value , a t t r s ={ } ) : # d e l e t e a t t r i b u t e s w i t h an u n s e t v a l u e for ( k , v ) in a t t r s . items ( ) : i f v i s None o r v == ' ' : del attrs [ k ] v a l u e i s None o r v a l u e == ' ' : l e n ( a t t r s ) == 0 : if if return s e l f ._out . w r i t e ( s e l f ._g e t I n d e n t i o n ( ) ) s e l f ._out . w r i t e ( s e l f ._makeTag ( name , a t t r s , True ) + ' \ n ' ) else : escValue = s a x u t i l s . escape ( value or ' ' ) s e l f ._out . w r i t e ( s e l f ._g e t I n d e n t i o n ( ) ) s e l f ._out . w r i t e ( s e l f ._makeTag ( name , a t t r s ) ) s e l f ._out . w r i t e ( e s c V a l u e ) s e l f ._out . w r i t e ( ' < /%s >\n ' % name ) def _g e t I n d e n t i o n return ( self ) : s e l f ._indentAmount * l e n ( s e l f ._s t a c k ) d e f _makeTag ( s e l f , name , a t t r s ={ } , c l o s e=F a l s e ) : r e t = ' < ' + name for if (k , v) in attrs . iteritems () : v i s not None : v = saxutils . quoteattr ( str (v) ) r e t += ' %s=%s ' % ( k , v ) close : if return else : return r e t + ' / >' ret + '>' def createAnnotation ( url ) : " " "Get f i l e name part , s p l i t o f f e x t e n s i o n , r e w r i t e u n d e r s c o r e s . " " " path = u r l l i b . unquote ( u r l p a r s e . u r l s p l i t ( u r l ) [ 2 ] ) f i l e n a m e = o s . path . s p l i t e x t ( o s . path . basename ( path ) ) [ 0 ] return f i l e n a m e . r e p l a c e ( '_ ' , ' ' ) # # MAIN # optParser = optparse . OptionParser ( u s a g e='%prog [ − ah ] [ f i l e ] ' , v e r s i o n ='%prog ' + __v e r s i o n__ ) o p t P a r s e r . add_o p t i o n ( ' − a ' , '−− a n n o t a t i o n ' , a c t i o n =' s t o r e_true ' , d e s t ='add_a n n o t a t i o n ' , d e f a u l t=F a l s e , h e l p =' c r e a t e a n n o t a t i o n e l e m e n t s based on t h e f i l e name ' ) ( o p t i o n s , a r g s ) = o p t P a r s e r . p a r s e_a r g s ( ) E. Branlard 159 CHAPTER 17. SHELL SCRIPTS # # Write t h e p l a y l i s t i n XSPF format . # xml = XmlWriter ( s y s . s t d o u t , indentAmount =' xml . p r o l o g ( ) xml . s t a r t ( ' p l a y l i s t ' , { ' xmlns ' : }) xml . s t a r t ( ' t r a c k L i s t ' ) ') ' h t t p : // x s p f . o r g / ns / 0 / ' , ' v e r s i o n ' : '1 ' l i n e in sys . stdin : l i n e = l i n e . r s t r i p ( '\n ' ) for l i n e . s t a r t s w i t h ( '# ' ) or l e n ( l i n e . s t r i p ( ) ) == 0 : if continue l i n e . s t a r t s w i t h ( ' h t t p : // ' ) : url = line else : u r l = ' f i l e : // ' + u r l l i b . pathname2url ( l i n e ) if xml . s t a r t ( ' t r a c k ' ) xml . elem ( ' l o c a t i o n ' , u r l ) if o p t i o n s . add_a n n o t a t i o n : xml . elem ( ' a n n o t a t i o n ' , c r e a t e A n n o t a t i o n ( u r l ) ) xml . end ( ) # t r a c k xml . end ( ) # t r a c k L i s t xml . end ( ) # p l a y l i s t # EOF 17.31 tomp3 #! / b i n / bash ############################################################# # 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 echo " F i l e $ j " if [ − f "$ j " ] then echo " File exists $j −> s k i p p i n g " else E. Branlard 160 CHAPTER 17. SHELL SCRIPTS " F i l e d o e s not e x i s t s " [ [ " $ i " == * . au ] ] echo if 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 elif f a a d −o − " $ i " | lame −h −b 192 − " $ j " [ [ " $ i " == * . wav ] ] then elif then elif then elif then lame " $ i " " $ j " [ [ " $ i " == * .wma ] ] #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 * ] ] # echo To be done [ [ " $ i " == * . mp3 ] ] #mp3 > mp3 lame " $ i " " audiodump . mp3" mv " audiodump . mp3" " $ j " else "Format unknown" ; ffmpeg − i " $ i " −vn −ab 128 k −ac 2 − a r 44100 −y " $ j ">/ dev / n u l l ; echo fi fi done 17.32 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 17.33 rhythmboxplaylist2exaile #! / u s r / b i n / python import os , s t r i n g E. Branlard 161 CHAPTER 17. SHELL SCRIPTS marker = 0 marker2 = 0 orderlist = [] a = open ( ' p l a y l i s t s . xml ' , ' r ' ) i f not o s . path . e x i s t s ( " p l a y l i s t s " ) : o s . makedirs ( " p l a y l i s t s " ) os . chdir ( " p l a y l i s t s " ) z = open ( ' o r d e r_ f i l e ' , 'w' ) for l i n e in a . x r e a d l i n e s ( ) : i f marker == 1 : i f l i n e . f i n d ( ' < l o c a t i o n > ') != −1 and l i n e . r f i n d ( ' < / l o c a t i o n > ') − 1: l i n e = l i n e [ l i n e . f i n d ( ' < l o c a t i o n > ') + 1 0 : ] l i n e = l i n e [ : l i n e . f i n d ( ' < / l o c a t i o n > ') ] l i n e = s t r i n g . r e p l a c e ( l i n e , '& ; ' , '& ' ) i f marker2 == 0 : m = open ( name + '. p l a y l i s t ' , 'w' ) z . w r i t e ( name+'\n ' ) marker2 = 1 m. w r i t e ( l i n e +'\n ' ) e l i f l i n e . f i n d ( ' < / p l a y l i s t > ') != − 1: i f marker2 == 0 : != continue m. w r i t e ( 'EOF\n ' ) m. w r i t e ( ' random_e n a b l e d=B : F a l s e \n ' ) m. w r i t e ( ' random_mode=S : t r a c k \n ' ) m. w r i t e ( ' r e p e a t_e n a b l e d=B : F a l s e \n ' ) m. w r i t e ( ' r e p e a t_mode=S : p l a y l i s t \n ' ) m. w r i t e ( ' dynamic_e n a b l e d=B : F a l s e \n ' ) m. w r i t e ( ' c u r r e n t_pos=I : −1\n ' ) m. w r i t e ( ' name=U: '+name+'\n ' ) m. w r i t e ( '_i s_custom=B : True \n ' ) m. w r i t e ( '_n e e d s_s a v e=B : F a l s e \n ' ) m. c l o s e ( ) marker = 0 marker2 = 0 e l i f l i n e . f i n d ( ' < p l a y l i s t name=" ' ) != − 1: i f l i n e . r f i n d ( ' / > ') == − 1: l i n e = l i n e [ l i n e . f i n d ( ' < p l a y l i s t name=" ' ) + 1 6 : ] line = line [ : line . find ( ' " ') ] l i n e = s t r i n g . r e p l a c e ( l i n e , '& ; ' , '& ' ) name = l i n e marker = 1 a . close () z . w r i t e ( 'EOF\n ' ) z . close () 17.34 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& E. Branlard 162 CHAPTER 17. SHELL SCRIPTS 17.35 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 rm " $ i . tmp" done ; IFS=$SAVEIFS echo echo ~ NAME=" 17.36 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 ) 17.37 pdfBind #! / b i n / bash E. Branlard 163 CHAPTER 17. SHELL SCRIPTS if [ $# − 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 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 " 17.38 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 ] E. Branlard 164 CHAPTER 17. SHELL SCRIPTS then echo exit ; " I n s t a l l gawk !" ; 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" E. Branlard 165 CHAPTER 17. SHELL SCRIPTS echo rm "##################################################################" * . pdf 2>/ dev / n u l l . . / pdf2pngCleanUp ######################################################################## # 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 echo echo echo E. Branlard "##################################################################" " Running b i b t e x on $ f " "##################################################################" 166 CHAPTER 17. SHELL SCRIPTS f f =* . aux bibtex $ f f "##################################################################" " 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 | E. Branlard 167 CHAPTER 17. SHELL SCRIPTS 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 | 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 17.39 LaunchSession.sh #! / b i n / bash if [ $ 1 = " v o r t e x " ] ; then DIR=" / work / p u b l i c a t i o n s / n o t e s / " thunar " $DIR" ; gvim −S " $DIR" " S e s s i o n V o r t e x . vim" [ $ 1 = " v o r t e x c o d e " ] ; then DIR=" / work / VortexCode / VortexElements / " thunar " $DIR" ; gvim −S " $DIR" " S e s s i o n . vim" [ $ 1 = "momentum" ] ; then DIR=" / work / p u b l i c a t i o n s / n o t e s / " thunar " $DIR" ; gvim −S " $DIR" " SessionMomentum . vim" [ $ 1 = " book " ] ; then DIR=" / work / p u b l i c a t i o n s / book / " thunar " $DIR" ; gvim −S " $DIR" " S e s s i o n . vim" fi if fi if fi if fi 17.40 rhythmboxstartlong E. Branlard 168 CHAPTER 17. SHELL SCRIPTS #! / 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& 17.41 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 ( ) { 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 ( ) { E. Branlard 169 CHAPTER 17. SHELL SCRIPTS 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 "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 " 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 E. Branlard 170 CHAPTER 17. SHELL SCRIPTS if [ −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 echo −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 ### 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 . E. Branlard 171 CHAPTER 17. SHELL SCRIPTS # on l e c o n v e r t i : nom=$ ( echo " $ 1 " | i c o n v − f c o n v e r t_c o n t e n t " $nom" echo $FROM −t $TO) " 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 17.42 pdfAlternRotation #! / 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 E. Branlard bind . pdf "Done . F i l e ' bind . pdf ' c r e a t e d " 172 CHAPTER 17. SHELL SCRIPTS 17.43 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 & 17.44 MoveWindowLeftRight.sh #! / b i n / bash pywo put −p $ 1 pywo put −p M −−xinerama 17.45 ScreenConf.sh #! / b i n / bash "−−−−−−−−−−−−−−−−−−−−−−− BEGIN SCREENCONF −−−−−−−−−−−−−−−−−−−−−−−−−−− " sleep 3 echo "−−−−−−−−−−−−−−−−−−−−−−− BEGIN SCREENCONF −−−−−−−−−−−−−−−−−−−−−−−−−−− " echo #x=` xrandr −− q u e r y | g r e p 2720 | wc − l ` ; #home x=` xrandr −−query | g r e p 1920 | wc − l ` ; echo if [[ #r i s o "x : " $ x $x > 0 ]] then #/ home /manu/ C o n f i g / p r o f i l e s / s c r e e n l a y o u t / RisoScreenPersoLaptop . sh xrandr −−output LVDS−1 −−mode 1440 x900 −−pos 1920 x0 −− r o t a t e normal −− output VGA−1 −−mode 1920 x1080 −−pos 0 x0 −− r o t a t e normal fi 17.46 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 ) E. Branlard 173 CHAPTER 17. SHELL SCRIPTS { 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; 17.47 ref #! / b i n / sh ############################################################# # Ref ############################################################# # Description : uses l o c a t e to search through references # Written by : Emmanuel Branlard # Date : Dec 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 # Use : r e f Word1 Word2 e t c . ############################################################# a=" " ; for i do a=$ a " " $ i ; b=$ b" | " $ i ; done # l o c a t e −iA $ a | g r e p −− c o l o u r=n e v e r _Refs | c u t −b 13 − | g r e p −− c o l o u r=auto − i −E " $ b " l o c a t e −iA $ a | g r e p −− c o l o u r=n e v e r _R e f s | g r e p −− c o l o u r=auto − i −E " $ b" 17.48 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 174 CHAPTER 17. 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 E. Branlard 175 Chapter 18 Debian 18.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 176 / e t c / network / CHAPTER 18. 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 177 CHAPTER 18. 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 ) a p t i t u d e i n s t a l l n t f s −3g # !!! Use a p t i t u d e t o i n s t a l l d ep e n de n c es ! ! ! ! #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 # t o be a b l e t o i n s t a l l x i n i t w i t h o u t t o o much s t u f f . . . #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 −nouveau a p t i t u d e i n s t a l l x s e r v e r −xorg # t o be a b l e t o i n s t a l l xterm w i t h o u t t o o much s t u f f E. Branlard 178 CHAPTER 18. DEBIAN # use a p t i t u d e t o manage d e p e n d e n c i e s ! ! ! a p t i t u d e i n s t a l l f o n t −c o n f i g − c o n f i g l i b f o n t c o n f i g 1 l i b u t e m p t e r 0 l i b x f t 2 l i b x r e n d e r 1 t t f −dejavu − c o r e xbitmaps xterm #Now we are ready f o r x i n i t aptiude i n s t a l l x i n i t #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 # 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 # a p t i t u d e i n s t a l l cpp a p t i t u d e i n s t a l l xfwm4 a p t i t u d e i n s t a l l x f c e 4 −p a n e l #i n s t a l l t h u n a r w i t h a p t i t u d e g u i #i e needs d e s k t o p − f i l e − u t i l s l i b g u d e v −1−0−0 l i b n o t i f y 4 l i b t h u n a r x −2−0 a p t i t u d e i n s t a l l x f c e 4 −s e s s i o n E. Branlard 179 CHAPTER 18. DEBIAN #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 #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 . E. Branlard 180 CHAPTER 18. DEBIAN 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 − 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 . E. Branlard 181 CHAPTER 18. DEBIAN 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 18.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 \ ############################# ### 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 E. Branlard 182 CHAPTER 18. DEBIAN #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 \ vim gvim geany e v i n c e \ mirage gimp g p i c v i e w i n k s c a p e \ unzip zip bzip2 tar \ numlockx sysv −rc −c o n f t e r m i n a t o r \ o p e n o f f i c e . org − w r i t e r o p e n o f f i c e . org − c a l c o p e n o f f i c e . org −i m p r e s s \ v l c a u d a c i t y rhythmbox t i m i d i t y \ wicd i c e w e a s e l amule t r a n s m i s s i o n f i l e z i l l a \ i c e d o v e i c e o w l −e x t e n s i o n \ meld f i l e l i g h t texmaker \ jumpnbump f r o z e n −bubble \ aptitude i n s t a l l \ x c l i p l i b n o t i f y −b i n \ readahead readahead − f e d o r a \ f l a s h p l u g i n − n o n f r e e sun−java6 − j r e sun−java6 − p l u g i n \ gamin \ n t f s −3g wmctrl xclip smbfs arandr l i b c u r l 3 #f o r chrome E. Branlard 183 CHAPTER 18. DEBIAN l s b − c o r e #f o r g o o g l e − e a r t h E. Branlard 184 Chapter 19 Fluxbox 19.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 19.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 & 185 CHAPTER 19. FLUXBOX 19.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 186 CHAPTER 19. 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 187 Chapter 20 Languages and programs 20.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 : 188 CHAPTER 20. 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/ 20.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 189 CHAPTER 20. 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 } 20.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 190 CHAPTER 20. 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 . 191 CHAPTER 20. 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 20.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 192 CHAPTER 20. 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 193 CHAPTER 20. 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 ) ; 194 Chapter 21 Makeles 21.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) 195 CHAPTER 21. 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 21.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 : 196 CHAPTER 21. 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 197 CHAPTER 21. 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 198 CHAPTER 21. 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 199 CHAPTER 21. 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 200 CHAPTER 21. 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 201 CHAPTER 21. 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) 202 Chapter 22 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 # man make−dpkg # p u t modules s o u r c e s i n / u s r / s r c / modules ( d e f a u l t l o c a t i o n ) 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 ) 203 / l i b / modules / CHAPTER 22. 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 204 CHAPTER 22. 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 E. Branlard 205 CHAPTER 22. KERNEL COMPILATION −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− −> Le k e r n e l 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 E. Branlard 206 CHAPTER 22. KERNEL COMPILATION * 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 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 E. Branlard 207 CHAPTER 22. KERNEL COMPILATION −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− −> Options : −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 E. Branlard 208 CHAPTER 22. KERNEL COMPILATION 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 209 Chapter 23 Old notes on linux 23.1 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 23.2 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 23.3 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 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 210 CHAPTER 23. OLD NOTES ON LINUX 23.4 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 23.5 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+& 23.6 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 ( ( 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 ` " ; \ cp " $ ( 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 ; for do echo 23.7 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 E. Branlard 211 CHAPTER 23. OLD NOTES ON LINUX # 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 a l i a s lhm='xmodmap −e " p o i n t e r = 3 2 1 4 5 7 6 8 9 " ' a l i a s 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 / 23.8 Mise en veille et hibernation qui plante 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 Option "NvAGP" " 1 " Option "NoLogo" " t r u e " / e t c / X11 / xorg 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 23.9 Equivalent win split revolution with wmctrl - raccourcis clavier xfce SEE MY SECTION ON TILING ! ! ! ! ! ! USE PYWO 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 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 E. Branlard 212 CHAPTER 23. OLD NOTES ON LINUX 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 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 " ; g r e e n" ; −bg " ; b l a c k" ; " /> <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 ; E. Branlard 213 CHAPTER 23. OLD NOTES ON LINUX 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 " /> <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 > 23.10 Tip 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 . 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 23.11 Migrate from Ext3 a Ext4 % 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 E. Branlard 214 CHAPTER 23. OLD NOTES ON LINUX 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 plupart des f i c h i e r s systemes . ) % Step 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 . % Step 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 . 23.12 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 ) 23.13 WIFI, et GESTIONNAIRE DE TROUSSEAU E. Branlard 215 CHAPTER 23. OLD NOTES ON LINUX 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 23.14 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 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 E. Branlard 216 CHAPTER 23. OLD NOTES ON LINUX 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 23.15 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 connecté au w i f i ) . 23.16 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_ 23.17 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 . 23.18 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 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 217 CHAPTER 23. OLD NOTES ON LINUX 23.19 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 218