Archives pour la catégorie Memo

Memorandum: note des choses dont on veut se souvenir, carnet contenant ces notes.

Memo raccourcis du bash

Mémo Précis & concis : les raccourcis du bash

Déplacements :

  • ctrl a : début de ligne
  • ctrl e (end) : fin de ligne
  • alt f (forward) : avance d’un mot (<— pratique)
  • alt b (backward) : recule d’un mot (<— pratique)
  • ctrl x ctrl x (x switch) : alterne le curser avec son ancienne position (<— -* coup de coeur)

Couper coller

  • alt backspace : couper le mot avant
  • alt d : couper le mot après
  • ctrl k : coupe du curser à la fin de la ligne
  • ctrl u : coupe du curser au début de la ligne (<—pratique quand vous voulez annuler la saisie d’un mot de passe par exemple)
  • ctrl y (yank) : coller

Historique

  • flèche haut : remonter d’une ligne dans l’historique (ctrl p (previous))
  • flèche bas : descendre d’une ligne dans l’historique (ctrl n (next)) (vous pouvez vous ballader dans l’historique avec les flèches sans perdre votre saisie en cours…)
  • crtl r (research) : chercher les occurences d’une chaine de caractère dans l’historique (ctrl r pour passer à l’occurence d’après ctrl s pour revenir à l’occurence d’avant). (<— indispensable)
  • ctrl o : valide la ligne en cours et vous replace sur la ligne d’après dans l’historique (utile pour rejouer des pans de votre historique de shell avec ctrl r)

Éditer une ligne de commandes

  • ctrl x ctrl e : édite la ligne courante dans Vi (variable $EDITOR du shell) (<— coup de coeur)
  • alt u : transforme le mot courant en majuscules à partir du curser et avance d’un mot
  • alt l : transforme le mot courant en minuscules à partir du curser et avance d’un mot
  • alt c : met la lettre sous le curser en majuscule et avance d’un mot
  • alt r : annule les changements et remet la ligne telle qu’elle était dans l’historique (<— pratique)
  • tab : complète le mot en cours suivant le contexte (<— indispensable) Pour ceux que ça intéresse, la page de man de bash est évidemment LA référence pour ce genre de choses, si vous voulez atteindre directement la section de ces raccourcis, cherchez la chaine « beginning-of-line »
Honteusement repris de http://geekblog.over-blog.com/article-19405116.html

Ajouter des routes au chargement d’une interface réseau

Je reprend ici un note du mardi 22 avril 2008 par Noplay qui m’a été très utile et que je souhaite garder à disposition (comme souvent).

Plusieurs interface, plusieurs route

Sous Debian ou Ubuntu si vous désirez ajouter automatiquement des routes lorsque une interface réseau devient active vous pouvez utiliser la règle post-up du fichier /etc/network/interfaces. Celle-ci permet éxécuter une commande après qu’une interface soit passée active.

allow-hotplug eth1 iface eth1 inet dhcp post-up route add -net <span style="color: #000000;">42.42</span><span style="color: #000000;">.42</span><span style="color: #000000;">.0</span> netmask <span style="color: #000000;">255.255</span><span style="color: #000000;">.255</span><span style="color: #000000;">.0</span> gw <span style="color: #000000;">192.168</span><span style="color: #000000;">.1</span><span style="color: #000000;">.1</span> down route del -net <span style="color: #000000;">42.42</span><span style="color: #000000;">.42</span><span style="color: #000000;">.0</span> netmask <span style="color: #000000;">255.255</span><span style="color: #000000;">.255</span><span style="color: #000000;">.0</span> gw <span style="color: #000000;">192.168</span><span style="color: #000000;">.1</span><span style="color: #000000;">.1</span>

Pour plus d’informations : man interfaces

Xen : Memo commande xm create

Memo des paramètres de la commande xm create , simple copier coller de la sortie de l’option help.

 xm create —help_config Values: vncviewer=no|yes Spawn a vncviewer listening for a vnc server in the domain. The address of the vncviewer is passed to the domain on the kernel command line using 'VNC_SERVER=&lt;host&gt;:&lt;port&gt;'. The port used by vnc is 5500 + DISPLAY. A display value with a free port is chosen if possible. Only valid when vnc=1. vncconsole=no|yes Spawn a vncviewer process for the domain's graphical console. Only valid when vnc=1. name=NAME Domain name. Must be unique. bootloader=FILE Path to bootloader. bootargs=NAME Arguments to pass to boot loader bootentry=NAME DEPRECATED. Entry to boot via boot loader. Use bootargs. kernel=FILE Path to kernel image. ramdisk=FILE Path to ramdisk. features=FEATURES Features to enable in guest kernel builder=FUNCTION Function to use to build the domain. memory=MEMORY Domain memory in MB. maxmem=MEMORY Maximum domain memory in MB. shadow_memory=MEMORY Domain shadow memory in MB. cpu=CPU CPU to run the VCPU0 on. cpus=CPUS CPUS to run the domain on. pae=PAE Disable or enable PAE of HVM domain. acpi=ACPI Disable or enable ACPI of HVM domain. apic=APIC Disable or enable APIC of HVM domain. vcpus=VCPUS # of Virtual CPUS in domain. cpu_weight=WEIGHT Set the new domain's cpu weight. WEIGHT is a float that controls the domain's share of the cpu. restart=onreboot|always|never Deprecated. Use on_poweroff, on_reboot, and on_crash instead. Whether the domain should be restarted on exit. - onreboot: restart on exit with shutdown code reboot - always: always restart on exit, ignore exit code - never: never restart on exit, ignore exit code on_poweroff=destroy|restart|preserve|rename-restart Behaviour when a domain exits with reason 'poweroff'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. on_reboot=destroy|restart|preserve|rename-restart Behaviour when a domain exits with reason 'reboot'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. on_crash=destroy|restart|preserve|rename-restart Behaviour when a domain exits with reason 'crash'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. blkif=no|yes Make the domain a block device backend. netif=no|yes Make the domain a network interface backend. tpmif=no|yes Make the domain a TPM interface backend. disk=phy:DEV,VDEV,MODE[,DOM] Add a disk device to a domain. The physical device is DEV, which is exported to the domain as VDEV. The disk is read-only if MODE is 'r', read-write if MODE is 'w'. If DOM is specified it defines the backend driver domain to use for the disk. The option may be repeated to add more than one disk. pci=BUS:DEV.FUNC Add a PCI device to a domain, using given params (in hex). For example 'pci=c0:02.1a'. The option may be repeated to add more than one pci device. ioports=FROM[-TO] Add a legacy I/O range to a domain, using given params (in hex). For example 'ioports=02f8-02ff'. The option may be repeated to add more than one i/o range. irq=IRQ Add an IRQ (interrupt line) to a domain. For example 'irq=7'. This option may be repeated to add more than one IRQ. usbport=PATH Add a physical USB port to a domain, as specified by the path to that port. This option may be repeated to add more than one port. vif=type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,script=SCRIPT,backend=DOM,vifname=NAME Add a network interface with the given MAC address and bridge. The vif is configured by calling the given configuration script. If type is not specified, default is netfront not ioemu device. If mac is not specified a random MAC address is used. If not specified then the network backend chooses it's own MAC address. If bridge is not specified the first bridge found is used. If script is not specified the default script is used. If backend is not specified the default backend driver domain is used. If vifname is not specified the backend virtual interface will have name vifD.N where D is the domain id and N is the interface id. This option may be repeated to add more than one vif. Specifying vifs will increase the number of interfaces as needed. vtpm=instance=INSTANCE,backend=DOM Add a TPM interface. On the backend side use the given instance as virtual TPM instance. The given number is merely the preferred instance number. The hotplug script will determine which instance number will actually be assigned to the domain. The associtation between virtual machine and the TPM instance number can be found in /etc/xen/vtpm.db. Use the backend in the given domain. access_control=policy=POLICY,label=LABEL Add a security label and the security policy reference that defines it. The local ssid reference is calculated when starting/resuming the domain. At this time, the policy is checked against the active policy as well. This way, migrating through save/restore is covered and local labels are automatically created correctly on the system where a domain is started / resumed. nics=NUM DEPRECATED. Use empty vif entries instead. Set the number of network interfaces. Use the vif option to define interface parameters, otherwise defaults are used. Specifying vifs will increase the number of interfaces as needed. root=DEVICE Set the root= parameter on the kernel command line. Use a device, e.g. /dev/sda1, or /dev/nfs for NFS root. extra=ARGS Set extra arguments to append to the kernel command line. ip=IPADDR Set the kernel IP interface address. gateway=IPADDR Set the kernel IP gateway. netmask=MASK Set the kernel IP netmask. hostname=NAME Set the kernel IP hostname. interface=INTF Set the kernel IP interface name. dhcp=off|dhcp Set the kernel dhcp option. nfs_server=IPADDR Set the address of the NFS server for NFS root. nfs_root=PATH Set the path of the root NFS directory. device_model=FILE Path to device model program. fda=FILE Path to fda fdb=FILE Path to fdb serial=FILE Path to serial or pty or vc localtime=no|yes Is RTC set to localtime? usb=no|yes Emulate USB devices? usbdevice=NAME Name of USB device to add? stdvga=no|yes Use std vga or cirrhus logic graphics isa=no|yes Simulate an ISA only system? boot=a|b|c|d Default boot device nographic=no|yes Should device models use graphics? soundhw=audiodev Should device models enable audio device? vnc Should the device model use VNC? vncdisplay VNC display to use vnclisten Address for VNC server to listen on. vncunused Try to find an unused port for the VNC server. Only valid when vnc=1. sdl Should the device model use SDL? display=DISPLAY X11 display to use xauthority=XAUTHORITY X11 Authority to use uuid xenstore UUID (universally unique identifier) to use. One will be randomly generated if this option is not set, just like MAC addresses for virtual network interfaces. This must be a unique value across the entire cluster. 

Memo Renommer une carte réseau

J’installe régulièrement des lame sur Blade Center HP ProLiant BL460c G1 (pour être exacte) et j’ai régulièrement la mauvaise surprise de voir les cartes réseaux reconnues dans un ordre aléatoire. Sur l’une j’ai le réseau de prod sur eth1 et sur l’autre lame sur eth3, sans que cela soit définissable par une configuration particulière dans les switch du châssis. Autant dire que cela me gonfle car toute automatisation devient difficile chaque serveur étant différent.

Je veux renommer eth3 en eth0

Et bien pour changer le nom de la carte ethernet il suffit d’éditer le fichier suivant.


/etc/udev/rules.d/z25_persistent-net.rules

Fichier très explicite dans le quel vous faite votre cuisine à volonté.


# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.

# PCI device 0x14e4:0x16ac (bnx2)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:1e:0b:8d:eb:e2", NAME="eth0"

# PCI device 0x14e4:0x16ac (bnx2)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:1e:0b:8d:eb:ec", NAME="eth1"

# PCI device 0x14e4:0x1679 (tg3)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:16:35:c6:4b:69", NAME="eth2"

# PCI device 0x14e4:0x1679 (tg3)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:16:35:c6:4b:6a", NAME="eth3"

Vous sauvegardez, vous rebooter, servir chaud.