UNIX / Linux

Index

General

Linux

Embedded Linux 

Kernel

Boot

  • Background image
  • Mini Howto: Lilo with an animated graphics menu
  • Vesafb mini-HOWTO
  • Bootsplash
  • The Linux BootPrompt-HowTo
  • gui boot screen
  • Bootchart 
  • Linux install/boot from:
    from info distribution installation examples


    Mandriva / Mageia Debian
    USB key x x
    Disc dur / HDD
    x
    PXE
    x
  • Boot sequence:



    installation files from


    installer files (vmlinuz; initrd or all.rdz) at
    ISO image
    second-stage boot-loader boot using: remote filesystem CD/DVD USB key existing /boot remote filesystem CD/DVD USB key other HDD partition
    syslinux CD/DVD
    x

    NFS x x x
    USB key

    x


    x x
    GRUB/LILO Existing GRUB/LILO


    x

    x x

    PXE x (tftp?)


    NFS


  • Elements:
    • initrd (RAM disk) (wp):
      • veure el contingut d'un fitxer .img / see the contents of a .img file:
        • mkdir newdir; cd newdir; zcat /boot/initrd-2.6....img | cpio -i
    • vmlinux (wp) (vmlinuz, zImage, bzImage) (Linux kernel)
      • readelf -h vmlinuz
  • Logs
    • 20 Linux Log Files that are Located under /var/log Directory
    • dmesg
    • last
      • last reboot
      • last -x
      • last -x shutdown
    • Log de l'inici (consola) / Initial log (console)
      • more /var/log/prcsys.log
    • rsyslog
      • /etc/rsyslog.conf
    • journald
      • /etc/systemd/journald.conf
        • [Journal]
          Storage=auto
          SystemMaxUse=50M
        • auto => if /var/log/journal exists, it writes to it; if not, writes to volatile /run/log/journal
      • systemctl status systemd-journald.service
      • usage: journalctl
        • journalctl --list-boots
        • journalctl --boot=-1
        • journalctl --disk-usage
    • Preserve logs from previous boots
  • runlevels (wp)
    • configuration of default runlevel
      • systemd
      • old fashioned:
        • /etc/inittab
    • get the current runlevel:
      • ...
  • Login
  • Serveis / Services
    • Exemples / Examples
    • Daemons
    • Info

    • Mageia CentOS Debian Ubuntu
      old SysV init (service / chkconfig)
      SysV init (update-rc) SysV init (update-rc)
      new systemd systemd
      Upstart

    • SysV init systemd Upstart
      chkconfig service update-rc insserv

      used by
      • Mageia (old)
      • Mageia (old)
      • Debian
      • Debian (old)
      • Ubuntu (old)
      • Debian (new)
      • Mageia (new)
      • CentOS
      • Debian (new)
      • Ubuntu (new)

      config dir /etc/[rc.d/]rc?.d/[SK]DDnom_servei->../init.d/nom_servei /etc/insserv.conf /etc/systemd/system/
      • multi-user.target.wants/
      • ...


      script /etc/[rc.d/]init.d/nom_servei (/etc/init.d/skeleton)
      /usr/lib/systemd/system/nom_servei.service /etc/init/nom_servei.conf
      once start
      service nom_servei start /etc/init.d/nom_servei start
      systemctl start nom_servei.service
      systemctl start nom_servei@....service
      sudo [initctl] stop nom_servei
      stop
      service nom_serve stop /etc/init.d/nom_servei stop
      systemctl stop nom_servei.service sudo [initctl] start nom_servei
      status
      service nom_servei status /etc/init.d/nom_servei status
      systemctl status nom_servei.service sudo [initctl] status nom_servei
      restart
      service nom_servei restart /etc/init.d/nom_servei restart
      systemctl restart nom_servei.service sudo [initctl] restart nom_servei
      reload



      systemctl reload nom_servei.service sudo [initctl] reload nom_servei
      list all
      service --status-all

      systemctl status sudo initctl list
      at boot do start chkconfig nom_servei on
      update-rc.d nom_servei enable
      update-rc.d nom_servei defaults
      insserv nom_servei systemctl enable nom_servei.service sudo rm /etc/init/nom_servei.override
      do not start chkconfig nom_servei off
      update-rc.d nom_servei disable
      systemctl disable nom_servei.service sudo sh -c "echo 'manual' > /etc/init/nom_servei.override"
      list chkconfig


      systemctl
      check whether it is enabled




      systemctl is-enabled nom_servei.service


      mask -


      ln -s /dev/null /etc/systemd/system/nom_servei.service
      systemctl daemon-reload

    • SysV init (wp)
    • systemd (wp) (replacement for chkconfig and service)
      • systemd man page
      • Systemd en Mageia 2
      • general view
        • systemctl
        • long lines
          • systemctl -l
      • fitxers / files:
        • /lib/systemd/
        • /etc/systemd/
      • start
        • systemctl start <nom_servei>.service
        • templated service
          • systemctl start <nom_servei>@<param>.service
          • e.g. memcached
      • debugging
        • journalctl -u my_service
        • journalctl -xe
      • reload modified scripts
        • systemctl daemon-reload
      • /var/run
      • Type
        description
        example
        simple
        default type
        [Service]
        Type=simple
        ExecStart=/path/to/script
        forking
        process in ExecStart is expected to call fork()
        [Service]
        Type=forking
        PIDFile=...pid
        ExecStart=/path/to/auto_forked_process
        oneshot
        process do something and ends.
        In order to avoid the service to finish, add RemainAfterExit
        [Service]
        Type=oneshot
        RemainAfterExit=yes
        ExecStart=/path/to/script_that_do_something_and_ends
        dbus

        [Service]
        Type=dbus
        notify

        [Service]
        Type=notify
        ExecStart=/path/to/process_that_launches_sd_notify
        idle

        [Service]
        Type=idle
        ExecStart=/path/to/process

      • dependency on NFS mounted dirs:
      • Glob expansion in ExecStart, ExecStartPre
      • Run script on start-up
      • Run script before shutdown
    • Upstart (replacement for /sbin/init)
      • Upstart intro, cookbook and best practises
      • Stanzas
      • /etc/init/toto.conf
      • Running programs as Linux daemons using Upstart
      • Manual service / (permanent enable/disable)
      • examples
        • nginx
        • toto
          • /usr/local/bin/toto.sh
            • #!/bin/bash
              i=0
              echo "---principi"
              while test $i -le 5
              do
                date
                sleep 2
                let i=$i+1
              done
              echo "---final"
          • /usr/local/bin/launch_toto.sh
            • #!/bin/bash
              /usr/local/bin/toto.sh
          • /etc/init/toto.conf
            • description "toto service"

              start on runlevel [2345]
              stop on runlevel [!2345]

              pre-start script
                # prepare environment
                mkdir -p /var/run/toto
              end script

              post-stop script
                # clean up
                rm -rf /var/run/toto
              end script

              #expect fork
              respawn
              exec /usr/local/bin/launch_toto.sh
        • cvlc
          • /usr/local/bin/launch_cvlc.sh
            • #!/bin/bash
              sudo -u ubuntu /usr/bin/cvlc -I telnet --http-port=8888 &
              exit 0
          • /etc/init/cvlc.conf
            • description "cvlc daemon"
               
              start on (filesystem and net-device-up IFACE=lo)
              stop on runlevel [!2345]
               
              env DAEMON=/usr/local/bin/launch_cvlc.sh
              env PID=/var/run/clvc.pid

              exec $DAEMON
      • usage
        • sudo start cvlc
        • sudo stop cvlc
        • sudo status cvlc
        • sudo initctl list
      • logs
        • /var/log/upstart/cvlc.log

GNU

Distribucions / Distributions

Gestió de paquets / Package management


pkgs.org rpmfind.net
Mageia

CentOS / RHEL



dpkg-based
rpm-based
Python
Node.js
Ruby


dpkg apt-get aptitude rpm urpmi yum pip
npm
gem
usage








repo config config repo files



/etc/urpmi/ /etc/yum.repos.d/


add main repository



urpmi.addmedia --distrib --mirrorlist yum-config-manager --add-repo repository_url


add repository
add-apt-repository ...

urpmi.addmedia ...



remove repository



urpmi.removemedia



list repositories



urpmq --list-media yum [-v] repolist


enable repository




yum-config-manager --enable repository…


disable repository




yum-config-manager --disable repository


update repository
apt-get update


urpmi.update ...



upgrade
upgrade all installed packages (-u: only list availability)

apt-get [-u] upgrade







upgrade distribution

apt-get dist-upgrade







install install a package dpkg -i package_name.deb apt-get install package_name

urpmi package_name yum install package_namepip install package_name
npm install [-g] package_name
gem install package_name
install a package (alpha version)






pip install -pre package_name

install a group / metapackage / task




urpmi task-c++-devel
yum groupinstall "Development Tools"


info list of all installed packages dpkg -l

rpm -qa

pip freeze
npm list
gem list
information about a package dpkg -l package_name


urpmq -i package_name yum info package_name pip show package_name


list of files provided by an installed package dpkg-query -L package_name
dpkg -L package_name


rpm -ql package_name urpmq -l package_name



list of files provided by an uninstalled package dpkg --contents package_name.deb



yum install -y yum-utils;
repoquery -l package_name




search for a package name



urpmq -a -y part_of_name



list dependencies

apt-cache depends package_name






whether a package is installed
dpkg -s package-name | grep Status







search search an expression
apt-cache search expression

urpmf expression yum search expression

gem search expression
which package provides a file (full path name) dpkg -S /absolute/path/to/file


urpmf /absolute/path/to/file yum provides /absolute/path/to/file



which package provides a file (part of path name)



urpmf expression
yum provides "*expression"


search on package name



urpmf --name expression yum list [installed|available] "expression*" (installed and not installed)



search on description



urpmf --description expression



remove remove a package
apt-get [--purge] remove package_name


urpme package_name



remove all no longer needed packages

apt-get [--purge] autoremove package_name








Gestió de parcs d'ordinadors / Cluster management

Linux en portàtils / on notebooks

  • Linux on laptops
  • Linux Laptop Volunteer Support Database
  • Dell Inspiron
  • Getting X up on an I7K
  • Inspiron Linux Mailing List Archive
  • PCMCIA support
  • Mountain Studio MX
    • HM77, i7-3630QM (Intel HD Graphics 4000) 2.4 GHz
    • lspci
      • 00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
        00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09)
        00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
        00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
        00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
        00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
        00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
        00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)
        00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4)
        00:1c.3 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 (rev c4)
        00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
        00:1f.0 ISA bridge: Intel Corporation HM77 Express Chipset LPC Controller (rev 04)
        00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)
        00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
        01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GTX 660M] (rev a1)
        03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8723AE PCIe Wireless Network Adapter
        04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5289 (rev 01)
        04:00.2 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0a)
    • Elantech touchpad
    • Targetes gràfiques
      • L'ordinador té dues targetes gràfiques. Normalment fa servir la integrada (Intel HD Graphics 4000, led «pila amb fulletes»), però es pot demanar que faci servir la Nvidia Geforce GTX 660M 2GB (led «agulla de velocímetre»). Per a fer-ho, cal instal·lar Bumblebee (implementació per a Nvidia Optimus) i cridar l'aplicació precedida de «optirun»
      • Nvidia
      • Intel CPU i7-3630QM (Intel HD Graphics 4000)
        • Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
          • Invalid ROM contents
          • Problems
            • No glx with Intel (when physical led is indicating Intel integrade graphics: "battery with leaves"):
              • /var/log/Xorg.o.log:
                • [  1296.578] (II) LoadModule: "glx"
                  [  1296.579] (II) Loading /usr/lib64/xorg/modules/extensions/libglx.so
                  [  1296.588] (II) Module glx: vendor="NVIDIA Corporation"
                  [  1296.588]     compiled for 4.0.2, module version = 1.0.0
                  [  1296.588]     Module class: X.Org Server Extension
                  [  1296.588] (II) NVIDIA GLX Module  331.38  Wed Jan  8 19:10:17 PST 2014
                  [  1296.588] Loading extension GLX
                  [  1296.588] (II) LoadModule: "intel"
                  [  1296.588] (II) Loading /usr/lib64/xorg/modules/drivers/intel_drv.so
                  [  1296.649] (II) Module intel: vendor="X.Org Foundation"
                  ...
                  [  1297.404] (EE) Failed to initialize GLX extension (Compatible NVIDIA X driver not found)
              • Solution: check that /usr/lib64/xorg/modules/extensions/libglx.so is not pointing to a Nvidia file (e.g. libglx.so -> libglx.so.331.38) (where did it come from?)
                If so, reinstall the xorg drivers and restart the X server:
                • urpmi --replacepkgs x11-server-common
                • CTRL + ALT + Backspace
                • glxgears
    • SSD
    • Botons / Buttons
      • dmesg | grep input
        • [    0.513775] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0
          [    1.623916] input: ETPS/2 Elantech Touchpad as /devices/platform/i8042/serio2/input/input1
          [    3.079265] input: Power Button as /devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input2
          [    3.079307] input: Sleep Button as /devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input3
          [    3.079339] input: Lid Switch as /devices/LNXSYSTM:00/device:00/PNP0C0D:00/input/input4
          [    3.099365] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input5
          [    4.123937] input: Video Bus as /devices/LNXSYSTM:00/device:00/PNP0A08:00/device:1b/LNXVIDEO:00/input/input6
          [    4.632086] input: Video Bus as /devices/LNXSYSTM:00/device:00/PNP0A08:00/LNXVIDEO:01/input/input7
          [    7.664368] input: HID 413c:3010 as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input8
          [    7.664421] generic-usb 0003:413C:3010.0001: input,hidraw0: USB HID v1.10 Mouse [HID 413c:3010] on usb-0000:00:1a.0-1.2/input0
          [   20.227723]    inputs: Mic=0x18 Internal Mic=0x19
          [   20.235887] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
          [   20.235967] input: HDA Intel PCH Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
          [   20.236020] input: HDA Intel PCH Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
          [ 3376.531530] input: BisonCam, NB Pro as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/input/input12
      • cat /proc/bus/input/devices

Bluetooth

Còpies de seguretat / Back up

Cygwin (UNIX on MSWindows)

Dispositius / Devices

Documentació / Documentation

Impressió / Printing

IrDA

Maquinari / Hardware

So / Sound

  • Devices
    • /dev/snd/...
  • Kernel drivers
    • OSS
    • Alsa
      • info
      • config
        • ‎/etc/sound/profiles/pulse/alsa-default.conf
        • ‎/usr/share/alsa/pcm/pulseaudio.conf
      • command line
        • amixer
        • aplay -l (list of playback hardware devices)
        • aplay -L (list all PCMs)
        • aplay -D<pcm>:<card>,<device> toto.wav
          • aplay -vv [-Ddefault] /usr/share/sounds/KDE-Im-Phone-Ring.wav
          • aplay -vv -Dpulse /usr/share/sounds/KDE-Im-Phone-Ring.wav
          • aplay -vv -Dfront:CARD=Intel,DEV=0 /usr/share/sounds/KDE-Im-Phone-Ring.wav
          • aplay -vv -Dplughw:0,7 /usr/share/sounds/KDE-Im-Phone-Ring.wav
        • arecord -l
  • Servidor de so / Sound server
    • aRts (used by KDE 2, 3) (wp)
    • Jack Audio Connection Kit (wp)
    • PulseAudio (wp: diagrama)
      • commands
        • pavucontrol
        • pactl stat
        • pactl list
        • pactl move-sink-input ID SINK
        • pacmd list
      • config files
        • /usr/share/pulseaudio/alsa-mixer/
        • /etc/pulse/default.pa
      • modules
        • urpmi pulseaudio-module-bluetooth
      • info
      • limitation:
        • Pulse does not see hw:0,7 only the first (2) devices of each card are enumerated (*)
      • Problemes / Problems
        • Volum massa alt / Volume too loud
        • HDMI audio out
          • Intel HDA HDMI interfaces are not detected (PulseAudio ticket #909)
            • /etc/pulse/default.pa
              • load-module module-alsa-sink device=hw:0,7 sink_name=DP set-default-sink DP update-sink-proplist DP device.description="DisplayPort?"
              • load-module module-alsa-sink device=hw:0,7
                set-default-sink alsa_output.hw_0_7
              • load-module module-alsa-sink device=hw:1,7 sink_name=HDMI
                set-default-sink HDMI 
              • load-module module-alsa-sink device=hw:0,1 sink_name=TOTO
                set-default-sink TOTO 
  • Multimedia API
    • Phonon (used by KDE 4) (wp)
  • Inspiron 9400 + Logitech webcam
    • aplay -l / arecord -l pavucontrol (Pulse Audio) KDE Multimedia Phonon
      card device type dispositius / configuració

      0
      Intel [HDA Intel] 0 STAC92xx Analog [STAC92xx Analog] playback dispositius de sortida Audio intern sortida d'àudio Audio intern Estèreo analògic
      capture dispositius d'entrada captura d'àudio
      1 STAC92xx Digital [STAC92xx Digital] playback dispositius de sortida sortida d'àudio Audio intern Estèreo digital (IEC958)
      1 default [Camera         ]
      USB Audio [USB Audio] capture dispositius d'entrada QuickCam for Notebooks captura d'àudio QuickCam for Notebooks analògic
    • aplay -l
      • **** List of PLAYBACK Hardware Devices ****
        card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
        card 0: Intel [HDA Intel], device 1: STAC92xx Digital [STAC92xx Digital]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
    • aplay -L (list all PCMs)
      • null
            Discard all samples (playback) or generate zero samples (capture)
        pulse
            PulseAudio Sound Server
        default
            Default ALSA Output (currently PulseAudio Sound Server)
        front:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Analog
            Front speakers
        surround40:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Analog
            4.0 Surround output to Front and Rear speakers
        surround41:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Analog
            4.1 Surround output to Front, Rear and Subwoofer speakers
        surround50:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Analog
            5.0 Surround output to Front, Center and Rear speakers
        surround51:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Analog
            5.1 Surround output to Front, Center, Rear and Subwoofer speakers
        surround71:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Analog
            7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
        iec958:CARD=Intel,DEV=0
            HDA Intel, STAC92xx Digital
            IEC958 (S/PDIF) Digital Audio Output
    • arecord -l
      • **** List of CAPTURE Hardware Devices ****
        card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
        card 1: default [Camera         ], device 0: USB Audio [USB Audio]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
  • Intel ICH7 (i3 2100T) + Haupauge PCI
    • aplay -l / arecord -l pavucontrol (Pulse Audio) KDE Multimedia Phonon
      card device type dispositius / configuració

      0
      CX8801 [Conexant CX8801] 0 CX88 Digital [CX88 Digital] capture



      1
      PCH [HDA Intel PCH] 0 ALC892 Analog [ALC892 Analog] playback



      capture



      1 ALC892 Digital [ALC892 Digital] playback



      3 HDMI 0 [HDMI 0] playback



      7 HDMI 1 [HDMI 1] playback



    • aplay -l
      • card 1: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
        card 1: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
        card 1: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
        card 1: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
          Subdevices: 0/1
          Subdevice #0: subdevice #0
    • aplay -L
      • null
            Discard all samples (playback) or generate zero samples (capture)
        pulse
            PulseAudio Sound Server
        default
            Default ALSA Output (currently PulseAudio Sound Server)
        front:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Analog
            Front speakers
        surround40:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Analog
            4.0 Surround output to Front and Rear speakers
        surround41:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Analog
            4.1 Surround output to Front, Rear and Subwoofer speakers
        surround50:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Analog
            5.0 Surround output to Front, Center and Rear speakers
        surround51:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Analog
            5.1 Surround output to Front, Center, Rear and Subwoofer speakers
        surround71:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Analog
            7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
        iec958:CARD=PCH,DEV=0
            HDA Intel PCH, ALC892 Digital
            IEC958 (S/PDIF) Digital Audio Output
        hdmi:CARD=PCH,DEV=0
            HDA Intel PCH, HDMI 0
            HDMI Audio Output
        hdmi:CARD=PCH,DEV=1
            HDA Intel PCH, HDMI 1
            HDMI Audio Output
    • arecord -l
      • **** List of CAPTURE Hardware Devices ****
        card 0: CX8801 [Conexant CX8801], device 0: CX88 Digital [CX88 Digital]
          Subdevices: 1/1
          Subdevice #0: subdevice #0
        card 1: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
          Subdevices: 1/1
          Subdevice #0: subdevice #0

PAM (Pluggable Authentication Modules)

Programari / Software

Desenvolupament / Development

Ncurses

X Window System


ServerLayout (:0, CTRL+ALT+F7)
  • Identifier "layout_crt"
Screen
  • Identifier "screen_crt"
Device
  • Identifier "card_crt"
  • Driver "nvidia"
  • BusID "PCI:1:0:0"
Monitor
  • Identifier "crt"
  • HorizSync
  • VertRefresh
  • ModeLine "1280x1024" ...
  • ModeLine "1024x768" ...
  • ...
  • Subsection "Display"
    • Viewport 0 0
    • Depth 24
    • Modes "1280x1024" "1024x768" (CTRL-ALT-+/-)
  • Subsection "Display"
    • Viewport 0 0
    • Depth 16
    • Modes "1280x1024" "1024x768"
  • ...
InputDevice
  • Identifier  "keyboard0"
InputDevice
  • Identifier "mouse0"
  • InputDevice "mouse0" "CorePointer" 
  • InputDevice "keyboard0" "CoreKeyboard"
ServerLayout (:1, CTRL+ALT+F8)
  • Identifier "layout_tv"
Screen
  • Identifier "screen_tv"
Device
  • Identifier "card_tv"
  • Driver "nvidia"
  • BusID "PCI:1:0:0"
  • Option "TVOutFormat" "SVIDEO"
  • Option "TVStandard" "PAL-B"
  • Option "ConnectedMonitor" "tele"
Monitor
  • Identifier "tele"
  • HorizSync 30-50
  • VertRefresh 60
  • Subsection "Display"
    • ...
    • Modes "1920x1080_60" "1280x720_60" "720x480_60"
  • ...
InputDevice
  • Identifier "keyboard0"
InputDevice
  • Identifier "mouse0"
  • InputDevice "mouse0" "CorePointer" 
  • InputDevice "keyboard0" "CoreKeyboard"
  • DISPLAY=:1 xterm
  • /usr/local/bin/mplayer.tv
    • #!/bin/sh
    • exec /usr/X11R6/bin/xinit /usr/bin/xterm -ut -e /usr/bin/mplayer -stop-xscreensaver -fs -vo sdl "$@" -- /usr/X11R6/bin/X :1 -layout layout_tv
ServerLayout (:0, CTRL+ALT+F7)
  • Identifier "layout0"
Screen
  • Identifier "screen_crt"
Device
  • Identifier "card_crt"
  • Driver "nvidia"
  • BusID "PCI:1:0:0"
  • Screen 0 (:0.0)
Monitor
  • Identifier "crt"
  • HorizSync
  • VertRefresh
Screen
  • Identifier "screen_tv"
Device
  • Identifier "card_tv"
  • Driver "nvidia"
  • BusID "PCI:1:0:0"
  • Screen 1 (:0.1)
  • Option "TVOutFormat" "SVIDEO"
  • Option "TVStandard" "PAL-B"
  • Option "ConnectedMonitor" "tele"
Monitor
  • Identifier "tele"
  • HorizSync 30-50
  • VertRefresh 60
InputDevice
  • Identifier  "keyboard0"
InputDevice
  • Identifier "mouse0"

  • Screen 0 "screen_crt"
  • Screen 1 "screen_tv" rightof "screen_crt"
  • InputDevice "mouse0" "CorePointer" 
  • InputDevice "keyboard0" "CoreKeyboard"

Output connectors ("ConnectedMonitor"):
  • DVI: "DFP", "CRT-0"
  • VGA: "CRT", "CRT-1"

Captures de pantalla / Screencast

  • gtk-recordMyDesktop
  • ffmpeg x11grab

DirectFB

  • Utilitats / Tips
  • Linux Framebuffer HOWTO
  • DirectFB X11
    /etc/directfbrc (*) /etc/X11/xorg.conf
    Device
    Driver="fbdev"

    vesa intelfb viafb (*) linux-viafb
    (DirectFB) (*)
    compilation


    modprobe
    intelfb mode=1024x768-76 viafb mode=1024x768 bpp=32 refresh=60 active_dev=CRT (readme.txt)
    /boot/grub/menu.lst vga=xxx [video=vesa...] video=intelfb (*) video=viafb:mode=1024x768,bpp=32,active_dev=CRT (*)
    bootsplash (text console): /etc/bootsplash/themes/current/config
  • VESA Framebuffer modes:
    bits 640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
    4
    - 770
    0x302




    8 768
    0x300
    769
    0x301
    771
    0x303
    773
    0x305
    0x161 775
    0x307
    796
    0x31c
    15
    0x310
    0x313
    0x316 0x162 0x319 797
    0x31d
    16
    785
    0x311
    788
    0x314
    791
    0x317
    0x163 794
    0x31a
    798
    0x31e
    24
    786?
    0x312
    789?
    0x315
    792?
    0x318

    795?
    0x31b
    799?
    0x31f
    32
    786?
    0x312
    789?
    0x315
    792?
    0x318
    0x164 795?
    0x31b
    799?
    0x31f

  • Use a VESA fb mode with 24/32bpp (792: 1024x768 24/32bpp):
    • grub
      • /boot/grub/menu.lst
        • kernel ... vga=792 append="video=vesa:ywrap,mtrr"
    • lilo
  • Check with:
    • dfbterm (urpmi dfbterm)
    • dfbshow (urpmi dfb++-examples)
    • mplayer -vo directfb toto.mp4
  • fbset (/etc/fb.modes)
    • urpmi fbset
    • fbset -i
  • Aplicacions / Applications

Publicacions / Publications

Seguretat / Security

  • SELinux
    • status
      • sestatus
    • enforce
      • setenforce 0
      • setenforce 1
      • getenforce
    • booleans (not kept among rebbots; build a .pp file instead)
      • getsebool -a
      • setsebool -P <boolean>=1
    • modules
      • dependencies
        • Mageia
          • urpmi checkpolicy
          • urpmi policycoreutils
        • CentOS
          • checkmodule
            • sudo yum install checkpolicy
          • semodule_package
            • sudo yum install policycoreutils-python
      • option 1: step by step
        • generate my_unit.te (my_unit is the systemd unit: nginx, httpd, ...)
          • grep my_unit /var/log/audit/audit.log | audit2allow -m my_unit >my_unit.te
        • generate my_unit.mod
          • checkmodule -M -m -o my_unit.mod my_unit.te
        • compile it to my_unit.pp
          • semodule_package -o my_unit.pp -m my_unit.mod
      • option 2: all in one step
        • grep my_unit /var/log/audit/audit.log | audit2allow -M my_unit
      • install it
        • semodule -i my_unit.pp
      • analyse my_unit.pp
        • sedismod my_unit.pp
          • 1)
          • a)
    • labels
    • CentOS SELinux
    • mount
      • # mount --verbose /mnt/vol1
        mount: /mnt/vol1 does not contain SELinux labels.
               You just mounted an file system that supports labels which does not
               contain labels, onto an SELinux box. It is likely that confined
               applications will generate AVC messages and not be allowed access to
               this file system.  For more details see restorecon(8) and mount(8).
      • 5.6. SELinux Contexts – Labeling Files
        • ls -Z toto.txt
      • Solution
        • ...
    • NFS
  • Lynis
  • BackTrack
  • BackBox Linux
  • msec (Mandriva/Mageia)
    • /etc/security/msec/
    • /etc/cron.daily/msec -> /usr/share/msec/security.sh

Shell

Sistema de fitxers / File systems

SGI Linux

Usuaris i grups / Users and groups

Variables d'entorn / Environment variables

  • LANGUAGE
    • /etc/sysconfig/i18n
    • ~/.i18n
  • PATH
    • /etc/profile
  • Altres configuracions
    • /etc/skel/ (estructura de directoris per a nous usuaris)

Llengua / Language (i18n, l10n)

  • /etc/sysconfig/i18n:
    • LANGUAGE=ca:en
    • LANG=ca_ES.UTF-8:en
  • gimp in English
    • export LANGUAGE=en; gimp
  • variable
    example value
    default value specified at
    non-default specified at
    files
    installed by package
    used by
    LANG
    • ca_ES.UTF-8
    • Mageia: /etc/sysconfig/i18n
    • CentOS: /etc/locale.conf

    /usr/share/locale/<LANG>/
    • LC_PAPER
    • LC_NAME
    • LC_MEASUREMENT
    • LC_TELEPHONE
    • LC_NUMERIC
    • LC_MONETARY
    • LC_TIME
    • LC_IDENTIFICATION
    • LC_COLLATE
    • LC_ADDRESS
    • LC_TYPE
    • LC_MESSAGES
      • SYS_LC_MESSAGES
    locales-ca
    shell commands:
    • ls
    • date
      • LANG=en_GB date
        Mon 20 Feb 11:45:03 CET 2017
      • LANG=en_US date
        Mon Feb 20 11:45:08 CET 2017

    • ...
    LANGUAGE
    • ca
    /etc/sysconfig/i18n ~/.i18n
    /usr/share/locale/<LANGUAGE>/LC_MESSAGES/*.mo (each software package)
    software

Data / Date

  • Set system local time to UTC
    • ln -s /usr/share/zoneinfo/UTC /etc/localtime

Xarxes / Networks

  • Linux Home Netwoking
  • Linux Network Administrators Guide
  • Consistent Network Device Naming coming to Fedora 15 (biosdevname)
    • embeded (on-board):
      • em0, em1...
    • PCI
      • pci1#0 ...
  • Eines / Tools
  • Network interfaces
  • Flux de paquets de xarxa en Linux / Network packet flow in Linux
  • Drivers


  • configuration
    binary
    Linux distribution
    general config
    per-device config
    low level config
    main
    internally calls
    example
    config file
    config options
    config file
    config options (man ifcfg)
    file
    options








    manual IP address
    DHCP


    ifup, ifdown
    ifup-eth
    • ip
    • (ifconfig)
    • ifup eth0
    • ifup enp0s3
    Mageia
    Mandriva
    RedHat
    CentOS
    Fedora
    /etc/sysconfig/network HOSTNAME=pctoto
    NETWORKING=yes
    CRDA_DOMAIN=ES
    GATEWAYDEV=eth1

    /etc/sysconfig/network-scripts/ifcfg-eth0[:1]
    DEVICE=eth0
    IPADDR=192.168.0.15
    GATEWAY=192.168.0.1
    NETMASK=255.255.255.0
    MTU=1200
    IPV6_MTU="1280"
    ...


    /etc/sysctl.conf
    (speedguide)
    Mageia 5
    RedHat Enterprise
    CentOS 7
    • hostnamectl set-hostname my_hostname

    • /etc/sysconfig/network-scripts/ifcfg-enp0s3
    • /etc/sysconfig/network-scripts/ifcfg-eth0
    TYPE=Ethernet
    NAME=eth0
    ONBOOT=yes
    BOOTPROTO=none
    IPADDR0=10.0.0.31
    PREFIX0=24
    GATEWAY0=10.0.0.1
    DNS1=10.0.0.1

    USERCTL=no
    TYPE=Ethernet
    NAME=eth1
    ONBOOT=yes
    BOOTPROTO=dhcp
    USERCTL=no


    Mageia 3
    /etc/hostname
    pctoto





    Ubuntu Debian

    /etc/network/interfaces (*)
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.0.15
    network 192.168.0.0
    gateway 192.168.0.1
    netmask 255.255.255.0
    mtu 1492

    auto eth1
    iface eth1 inet dhcp

    auto eth2
    iface eth2 inet6 static
    pre-up modprobe ipv6
    address 2607:f0d0:2001:000a:0000:0000:0000:0002
    netmask 64
    gateway 2607:f0d0:2001:000a:0000:0000:0000:0001

    auto br0
    iface br0 inet static
        address 192.168.0.10
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off




    ifconfig (classical)











    ip (new) (iproute2)












  • Service
    type
    OS
    command
    info

    • old Mageia
    • old CentOS
    • service network start
    • service network stop
    • service network restart
    • service network status


    • Mageia
    • CentOS
    • systemctl start network
    • systemctl stop network
    • systemctl restart network
    • systemctl status network
    same result as reboot: only interfaces marked as ONBOOT=true will be active

    • Debian
    • Ubuntu
    • ...


  • Options
    • ip-sysctl
    • dir
      • /proc/sys/
    • configuration
      • /etc/sysctl.conf
    • control
      • list
        • sysctl -a
      • write
        • sysctl -w net.ipv4.ip_forward=1
    • General
      • /proc/sys/net/ipv4/ip_forward
    • Per NIC
      • Mageia
        • /proc/sys/net/ipv4/conf/enp4s0f2/
      • Ubuntu
        • /proc/sys/net/ipv4/conf/eth0/
      • ...
  • Zeroconf
  • Eines de gestió / Management tools
    • NetworkManager (gui)
      • /etc/NetworkManager/
      • disable
        • Ubuntu
          • sudo stop network-manager
          • permanently (Upstart)
            • echo "manual" > /etc/init/network-manager.override
        • CentOS
          • sudo systemctl stop NetworkManager
          • permanently
            • sudo systemctl disable NetworkManager
    • Ubuntu
    • Change the hostname:
    • ifconfig
      • DEPRECATED. Use iproute2 tools: ip
      • List interfaces
        • only active (Ubuntu)
          • ifconfig
        • active and non active
          • ifconfig -a
      • Assign a static IP address and bring up a device (automatically adds a specific route; but default route is not added nor modified):
        • ifconfig eth0 192.168.0.23 netmask 255.255.255.0 up
        • optionally (this is automatically added when using ipup):
          • add a default route to the router, to have access to Internet
            • route add default gw 192.168.0.1 dev eth0
          • add a dns server
            • echo "nameserver 192.168.0.1" >> /etc/resolv.conf
      • Assign a static IP address:
        • ifconfig eth0 192.168.0.100 netmask 255.255.255.0
      • Bring the device up:
        • ifconfig eth0 up
      • Bring the device down:
        • ifconfig eth0 down
      • Assign a dynamic IP address:
        • ...
      • Add a second IP address to the same NIC:
        • temporary (*) (it adds the corresponding route):
          • ip ...
          • ifconfig eth0:1 inet <second_ip_address> [broadcast 172.16.11.255 netmask 255.255.255.0]
        • permanently:
          • Mageia / Mandriva / Fedora / RedHat / CentOS:
            • cd /etc/sysconfig/network-scripts
            • cp ifcfg-eth0 ifcfg-eth0:1
            • edit ifcfg-eth0:1:
              • DEVICE=eth0:1
              • IPADDR=<second_ip_address>
            • service network restart
          • Debian / Ubuntu
            • ...
      • Promiscuous mode
        • enable
          • ifconfig eth0 promisc
        • disable
          • ifconfig eth0 -promisc
    • iwconfig (for wireless interfaces)
      • iwgetid
        • iwgetid -r wlp2s0
      • iwlist
    • ip
      • list all
        • ip a
    • ipcalc
    • route
      • DEPRECATED: Use iproute2 tools: ip
      • Introduction to Linux IP Routing Fundamentals (Part 1)
      • List routes:
        • route
        • routel
        • netstat -r
        • numerical IP addresses:
          • route -n
          • netstat -rn

      • add
        (automatically added when interface is activated: ifup wlp2s0)
        remove
        (automatically removed when interface is deactivated: ifdown wlp2s0)
        list



        Destination
        Gateway
        Genmask
        Flags
        Iface



        -net
        gw
        netmask

        dev
        to a local network
        route add -net 192.168.0.0 netmask 255.255.255.0 dev enp1s0f1
        192.168.0.0 0.0.0.0
        *
        255.255.255.0 U
        enp1s0f1
        route add -net 192.168.43.0 netmask 255.255.255.0 dev wlp2s0

        192.168.43.0 0.0.0.0
        *
        255.255.255.0 U
        wlp2s0
        to a gateway
        (destination is outside listed networks)
        route add default gw 192.168.0.1 enp1s0f1 route del default enp1s0f1




        route add default gw 192.168.43.1 wlp2s0
        default
        0.0.0.0
        192.168.43.1 0.0.0.0
        UG
        wlp2s0

      • Add a new route (*):
        • temporarily:
          • route add 192.168.0.1 eth0
          • route add -net 192.168.0.0 netmask 255.255.255.0 dev eth2
          • route add -net 172.16.0.0 netmask 255.255.0.0 dev eth2
          • route add -net 224.0.0.0/4 eth0
          • default gateway
            • route add default gw 10.0.0.1 eth0
        • permanently (*):
          • /etc/sysconfig/network-scripts/route-eth0
            • ADDRESS0=224.0.0.0 NETMASK0=240.0.0.0
      • Delete a route:
        • route del default eth1
        • route del -net 192.168.0.0/24 dev eth0
      • Change the default route to eth1:
      • Example:
        • Network topology
          • internal WiFi interface (wlp2s0) connected to Sony Xperia Z5 (tethering)
          • usb WiFi dongle (wlp0s20f0u1) connected to non-internet TP-Link router
          • internal ethernet (enp1s0f1) connected to non-internet TP-Link router
        • Steps
          • Start network (will make all interfaces available, and will be visible with ifconfig) (config in /etc/sysconfig/network)
            • systemctl start network.service
          • Configure interfaces (files can also be created from mcc: «Estableix una nova interfície de xarxa», and deleted with «Elimina una connexió»)
            • /etc/sysconfig/network-scripts/ifcfg-wlp2s0 (from BOOTPROTO: copied from /etc/sysconfig/network-scripts/wireless.d/Xperia Z5_7225) (WIRELESS_ESSID is not used, but result from iwgetid -r wlp2s0)
              • DEVICE=wlp2s0
                BOOTPROTO=dhcp
                ONBOOT=yes
                METRIC=3
                MII_NOT_SUPPORTED=no
                USERCTL=no
                RESOLV_MODS=no
                WIRELESS_MODE=Managed
                WIRELESS_ESSID="Xperia Z5_7225"
                WIRELESS_ENC_KEY=s:xxxxxxxx
                WIRELESS_WPA_DRIVER=wext
                WIRELESS_WPA_REASSOCIATE=no
                IPV6INIT=no
                IPV6TO4INIT=no
                ACCOUNTING=no
                DHCP_CLIENT=dhclient
                NEEDHOSTNAME=no
                PEERDNS=yes
                PEERYP=yes
                PEERNTPD=no

            • /etc/sysconfig/network-scripts/ifcfg-wlp0s20f0u1 (from BOOTPROTO: copied from /etc/sysconfig/network-scripts/wireless.d/TP-LINK_F3B398)
              • DEVICE=wlp0s20f0u1
                BOOTPROTO=dhcp
                ONBOOT=yes
                METRIC=35
                MII_NOT_SUPPORTED=no
                USERCTL=no
                RESOLV_MODS=no
                WIRELESS_MODE=Managed
                WIRELESS_ESSID=TP-LINK_F3B398
                WIRELESS_ENC_KEY=s:xxxxxxxx
                WIRELESS_WPA_DRIVER=wext
                WIRELESS_WPA_REASSOCIATE=no
                IPV6INIT=no
                IPV6TO4INIT=no
                ACCOUNTING=no
                DHCP_CLIENT=dhclient
                NEEDHOSTNAME=no
                PEERDNS=yes
                PEERYP=yes
                PEERNTPD=no

            • /etc/sysconfig/network-scripts/ifcfg-enp1s0f1
              • DEVICE=enp1s0f1
                BOOTPROTO=dhcp
                NETMASK=255.255.255.0
                ONBOOT=yes
                METRIC=10
                MII_NOT_SUPPORTED=no
                USERCTL=no
                RESOLV_MODS=no
                LINK_DETECTION_DELAY=6
                IPV6INIT=no
                IPV6TO4INIT=no
                ACCOUNTING=no
                DHCP_CLIENT=dhclient
                NEEDHOSTNAME=no
                PEERDNS=yes
                PEERYP=yes
                PEERNTPD=no
          • Bring up interfaces (can also be done from mcc: «Connecta»)
            • ifup enp1s0f1
              • if you experience problems:
                • check GATEWAYDEV in /etc/sysconfig/network
                • try switching off tethering on mobile phone (!?)
            • ifup wlp2s0
            • ifup wlp0s20f0u1
          • Remove default gateways without connection to internet (default gateway in wlp2s0 will have precedence because its metric (3) is lower than metric in enp1s0f1 (5) )
            • route del default wlp0s20f0u1
            • route del default enp1s0f1
    • Ponts / Bridges
    • Tallafocs / Firewalls
  • Afinament / Tuning
    • Info
    • Kernel parameters
      • How To: Network / TCP / UDP Tuning
      • Sysctl tuning for optimized system performance
      • TCP Tunnig Guide
      • sysctl [-w]


        • units
          default
          description
          usage
          network general



          net.core.rmem_default
          212992
          This sets the default OS receive buffer size for all types of connections.
          gstreamer receiving rtp
          net.core.rmem_max
          212992
          This sets the max OS receive buffer size for all types of connections.
          ffmpeg buffer when receiving rtp (maximum)
          net.core.wmem_default
          212992
          This sets the default OS send buffer size for all types of connections.

          net.core.wmem_max
          212992
          This sets the max OS send buffer size for all types of connections.

          IPV4 UDP


          net.ipv4.udp_mem pages (4096 bytes)
          auto-tuned by kernel:
          43620        58162   87240


          net.ipv4.udp_rmem_min
          4096


          net.ipv4.udp_wmem_min
          4096


          IPV4 TCP


          net.ipv4.tcp_mem
          pages (4096 bytes) auto-tuned by kernel:
          42519        56694   85038
          The tcp_mem variable defines how the TCP stack should behave when it comes to memory usage.
          • The first value specified in the tcp_mem variable tells the kernel the low threshold. Below this point, the TCP stack will not bother to put any pressure on the memory usage by different TCP sockets.
          • The second value tells the kernel at which point to start pressuring memory usage down.
          • The final value tells the kernel how many memory pages it may use (maximum). If this value is reached, TCP streams and packets start getting dropped until it reaches a lower memory usage again. This value includes all TCP sockets currently in use.

          net.ipv4.tcp_rmem

          4096        87380   6291456


          net.ipv4.tcp_wmem

          4096        16384   4194304


      • permanent changes accross reboots:
        • /etc/sysctl.d/60-rtp.conf
          • # values needed by gst-launch when receiving big rtp packets
            net.core.wmem_default = 851968
            net.core.rmem_max = 851968

        • sudo sysctl -p
  • Monitoratge / Monitoring
  • Emulació / Emulation
  • Simulació / Simulation
    • ns-2
    • OMNeT++
    • Simulació de pèrdua de paquets / Packet loss simulation
      • Info
      • Eines / Tools
        • tc (Traffic Control) (part of iproute2 package) (wp)
          • man tc
          • Advanced traffic control (Archlinux wiki)
            • CoDel
          • How to Use the Linux Traffic Control
          • QoS in Linux with TC and Filters
          • TrafficControl (Debian wiki)
            • gràfic jerarquia
          • Traffic Control HOWTO (old)
          • Linux Advanced Routing & Traffic Control HOWTO
          • Monitor
            • ...
            • Visualizing Linux Traffic Control Setup
              • Installation
                • Dependencies
                  • CentOS
                • git clone https://github.com/ze-phyr-us/tcviz.git
              • Utilització / Usage
                • cd tcviz
                • ./tcviz.py eth0 >eth0.dot
                • dot -Tsvg eth0.dot >eth0.svg
              • Legend
                • ...
          • syntax
            • tc <type> <action> <device> <position> <id> <qdisc> <parameters>
              • tc qdisc [ add | change | replace | link ] dev DEV [ parent qdisc-id | root ] [ handle x:[0] ] qdisc [ qdisc_specific_parameters ] 
              • tc qdisc remove ...
              • tc class [ add | change | replace ] dev DEV parent qdisc-id [ classid parent_x:y ] classful_qdisc [ qdisc_specific_parameters ]
              • tc filter [ add | change | replace ] dev DEV [ parent qdisc_x:0 | root ] protocol protocol prio priority filtertype [ filtertype_specific_parameters ] flowid flow-id
              • tc [ FORMAT ] qdisc show [ dev DEV ]
              • tc [ FORMAT ] class show dev DEV
              • tc filter show dev DEV
            • FORMAT := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -i[ec] }
          • queuing disciplines (qdisc)
            • type
              family
              qdisc
              qdisc specific parameters
              usage (advice)
              ingress
              Ingress qdisc ingress
              • To 'shape' incoming traffic which you are not forwarding. Incoming shaping is called 'policing', by the way, not 'shaping'.
              • Consider also IFB
              egress
              classless
              • A qdisc with no configurable internal subdivisions.
              • do not allow to add more qdiscs to it.
              • less flexible
              • less customizing
              • In the absence of classful qdiscs, classless qdiscs can only be attached at the root of a device.

              CoDel (Controlled Delay) (man) /
              Fair Queueing CoDel (man)
              fq_codel

              • default (systemd > 217)
              Fifo fast
              pfifo_fast

              • default (systemd <= 217)
              • Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band queue which honors Type of Service flags, as well as the priority that may be assigned to a packet.
              • FIFO
              • 3 queues
              • classify based on TOS/Priority field
              bfifo/pfifo bfifo
              pfifo
              • limit
              • Simplest usable qdisc, pure First In, First Out behaviour. Limited in packets or in bytes.
              • If you don't want to shape, but only want to see if your interface is so loaded that it has to queue
              Token Bucket Filter tbf
              • rate 1mbit
              • burst 32kbit
              • latency 400ms
              • The Token Bucket Filter is suited for slowing traffic down to a precisely configured rate. Scales well to large bandwidths.
              • To purely slow down outgoing traffic
              • If you *are* forwarding incoming traffic, use a TBF on the interface you are forwarding the data to
              Stochastic Fairness Queueing sfq
              • perturb 10 (seconds)
              • quantum 1514b (bytes)
              • limit 127p (packets)
              • Stochastic Fairness Queueing reorders queued traffic so each 'session' gets to send a packet in turn.
              • round-robin
              • If your link is truly full and you want to make sure that no single session can dominate your outgoing bandwidth
              Random Early Detection (RED) red

              • Random Early Detection simulates physical congestion by randomly dropping packets when nearing configured bandwidth allocation. Well suited to very large bandwidth applications.
              • If you have a big backbone and know what you are doing
              Netem
              netem
              • delay
                • 200ms
                • 100ms 10ms
                • 100ms 10ms 10%
                • 100ms 10ms distribution normal
              • loss
                • 10%
              • corrupt
                • 5%
              • duplicate
                • 1%

              classful
              • A classful qdisc contains multiple classes. Each of these classes contains a further qdisc, which may again be classful, but need not be.
              • configurable classes
              • traffic is sent to any of the classes within, based on response when calling filters
              • each class contains a leaf qdisc which by default has pfifo behaviour though another qdisc can be attached in place. This qdisc may again contain classes, but each class can have only one leaf qdisc.
              PRIO prio
              • bands
              • priomap
              • The PRIO qdisc is a non-shaping container for a configurable number of classes which are dequeued in order. This allows for easy prioritization of traffic, where lower classes are only able to send if higher ones have no packets available. To facilitate configuration, Type Of Service bits are honored by default.
              • created with a static number of children
              Class Based Queuing cbq Shaping:
              • avpkt 1000
              • bandwidth 10Mbit (physical bandwidth of the device)
              • cell
              • maxburst
              • minburst
              • minidle
              • mpu
              • rate 512kbit (desired rate)
              Classful (like PRIO) (weighted round robin):
              • allot 1500
              • prio 3
              • weight ...
              Link sharing and borrowing:
              • bounded/borrow
              • isolated/sharing
              • Class Based Queueing implements a rich linksharing hierarchy of classes. It contains shaping elements as well as prioritizing capabilities. Shaping is performed using link idle time calculations based on average packet size and underlying link bandwidth. The latter may be ill-defined for some interfaces.
              • allow for runtime addition of classes
              Hierarchical Token Bucket (user guide)
              htb
              • rate
                • ...
              • default
                • 30
              • The Hierarchy Token Bucket implements a rich linksharing hierarchy of classes with an emphasis on conforming to existing practices. HTB facilitates guaranteeing bandwidth to classes, while also allowing specification of upper limits to inter-class sharing. It contains shaping elements, based on TBF and can prioritize classes.
              • well suited for setups where you have a fixed amount of bandwidth which you want to divide for different purposes, giving each purpose a guaranteed bandwidth, with the possibility of specifying how much bandwidth can be borrowed
              • all filters must be attached to the htb root qdisc
              • allow for runtime addition of classes
              advanced CSZ



              DMARK



              Generic Random Early Detection



              VC/ATM emulation



              Weighted Round Robin (WRR)




          • filter
            • A filter is used by a classful qdisc to determine in which class a packet will be enqueued.
            • filter is attached to a qdisc (not a class)
            • syntax
              • tc filter [ add | change | replace ] dev DEV [ parent qdisc-id | root ] protocol protocol prio priority filtertype [ filtertype_specific_parameters ] flowid flow-id
                • show
                  • each filter created with a single add has a unique handle, and can contain several match (AND)
                  • several filters can point to the same class (OR)
                  • match <value_in_hex>/<mask> at <at_code>
                    • at_code:
                      • 12: ip src
                      • 16: ip dst
                      • 20: ip dport, ip sport
              • tc filter del dev DEV parent parent_qdisc_id: handle handle_id protocol protocol prio priority filtertype
                • Example:
                  • delete one specific filter:
                    • tc filter del dev eth0 parent 1: handle 800::800 prio 1 protocol ip u32
                  • delete all filters in a qdisc:
                    • tc filter del dev eth0 parent 1:
            • man
              • tc-basic
              • tc-ematch
            • Usage
              • tc only
                • tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip src 4.3.2.1/32 match ip sport 80 0xffff flowid 1:11
              • tc + iptables
                • tc filter add dev eth0 protocol ip parent 1: prio 1 handle 6 fw flowid 1:30
                • iptables -A PREROUTING -t mangle -i eth0 -j MARK --set-mark 6
            • protocol
              prio
              [handle] filtertype
              filtertype parameters
              flowid
              • ip
              • ...

              <n>

              u32
              • match
                • ip protocol 6 0xff (/etc/protocols)
                • ip src 4.3.2.1/32
                • ip dst 4.3.2.1/32
                • ip sport 80 <port_mask>
                • ip dport 22 0xffff
                • ip tos 0x10 0xff
              <destination_class_id>

              <handle_id> fw


              bpf


              route


              rsvp


              ...

          • Exemples / Examples
            • Ingress
              • using IFB
                • How can I use netem on incoming traffic? (netem)
                • Passos / Steps
                  1. modprobe ifb
                  2. ip link set dev ifb0 up
                  3. tc qdisc add dev eth0 ingress
                  4. tc filter add dev eth0 parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0
                  5. tc qdisc add dev ifb0 root netem delay 750ms
            • 9.5.4.4 CBQ sample configuration: 5Mbps for webserver, 3Mbps for SMTP
            • list
              • tc -s qdisc ls dev eth0
              • tc -s -d qdisc ls
            • Filters
            • Packet loss
              • tc qdisc change dev eth0 root netem loss 0.1%
              • bursts:
                • tc qdisc change dev eth0 root netem loss 0.3% 25%
            • Delaying only some traffic
              • Netem - how to delay packets sent to/received from some host
              • interface=eth0
                # reset
                tc qdisc del dev
                ${interface} root
                # create 4 bands
                tc qdisc add dev
                ${interface} root handle 1: prio bands 4
                # add filter to band e.g. 3: send packets with destination port 50000 to band 3
                band=3
                handle=$(( band * 10 ))
                dport=50000
                tc filter add dev
                ${interface} parent 1:0 protocol ip u32 match ip dport ${dport} 0xffff flowid 1:${band}
                # delay band 3 by 2000ms
                delay=2000ms
                tc qdisc add dev
                ${interface} parent 1:${band} handle ${handle}: netem delay ${delay}
            • loss only packets to a destination address:
              • interface=eth0
                dst_address="234.1.2.3"
                dst_port=5004
                loss="10%"
                tc qdisc del dev ${interface} root
                tc qdisc add dev $interface root handle 1: prio
                #tc filter add dev $interface parent 1:0 protocol ip prio 2 u32 match ip dport ${dst_port} 0xffff flowid 1:2
                tc filter add dev $interface parent 1:0 protocol ip prio 2 u32 match ip dst ${dst_address}/32 flowid 1:2
                tc qdisc add dev $interface parent 1:2 handle 2: netem loss ${loss}

        • tcng
        • iptables
  • Serveis / Services
    • netcat / nc / ncat
      • Instal·lació / Installation
        • Mageia
          • urpmi netcat-traditional
            • /usr/share/doc/netcat-traditional/scripts
        • CentOS
          • sudo yum install nc
          • sudo yum install nmap-ncat
      • Usage
      • Options:
        option
        description
        notes
        -c, --sh-exec <commands>
        execute (/bin/sh -c) commands after connection (only once)

        -e, --exec <command>
        execute command after connection

        -k, --keep-open
        keep connection open

        -l, --listen
        listen

        -n, --nodns
        no DNS lookup

        -p, --source-port <port>
        source port

        -u, --udp
        UDP

        -v, --verbose
        verbose

        -w, --wait <sec>
        connection timeout after <sec> seconds of inactivity

        -z
        zero mode, used for scanning (do not receive from server)
        not available on CentOS
      • Exemples / Examples

        • description
          code
          server (-l)
          one-shot web server on port (-p) 8080 { echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <index.html)\r\n\r\n"; cat index.html; } | nc -l -p 8080
          simple bidirectional udp (u) server on port (-p) 7000
          nc -ul -p 7000
          • (will show received text)
          • (type text to be transmitted)
          proxy
          • mkfifo backpipe
            nc -l 12345 0<backpipe | nc www.google.com 80 1>backpipe
          • one-shot:
            ncat -l 12345 -c 'nc www.google.com 80'

          making any process a server
          • nc -l -k -p 1234 -e <script_name>
          client
          connect to server at port 25
          nc mail.server.net 25
          check whether udp ports are open
          nc -vzu <server> 80-90
          simple bidirectional udp client
          nc -u <server> 7000
          • (type text to be transmitted)
          • (will show received text)
          port scanning
          nc -v -n -z -w 1 192.168.1.2 1-1000
        • connect to remote host:
          • nc ip_adress port
        • fake http server:
          • nc -l 80
        • UDP server (two servers can be started at the same port, but data from client will only go to one of them)
          • nc -ul 5004
            • <text from client will appear here>
        • UDP client:
          • nc -u <server> 5004
            • <type your text here>
        • snowmix
      • ...
  • Compartició de connexió Internet / Internet connection sharing 
  • WiFi 

http://www.francescpinyol.cat/linux.html
Darrera modificació: 29 de novembre de 2018 / Last update: 29th November 2018

KDE now linux softcatalà

Valid HTML 4.01!

Cap a casa / Back home.