Outils pour utilisateurs

Outils du site


blog

Yum force pb erreur le fichier de l'installation entre en conflit avec le fichier du paquet

Comment faire un yum --force en trichant un peu

Pb

le fichier /var/www de l'installation de httpd-2.4.6-40.el7.centos.1.x86_64 entre en conflit avec le fichier du paquet plop-1.8.8-2.noarch
Solution

Solution possible : Refaire proprement le package plop

ou forcer ! Nous allons utiliser yumdownloader (packet yum-utils)

yum install yum-utils
yumdownloader httpd
rpm -Uvh --force httpd-2.4.6-40.el7.centos.1.x86_64.rpm

Pour que ça marche, il faut faire la même chose avec toutes les dépendances

# yumdownloader --resolve httpd-tools
yumdownloader httpd-tools
rpm -Uvh --force httpd-2.4.6-40.el7.centos.1.x86_64.rpm httpd-tools-2.4.6-40.el7.centos.1.x86_64.rpm
2025/03/24 15:06

Xorg.conf généré par nvidia-xconfig

Voir :

nvidia-xconfig
nvidia-xconfig -a

/etc/X11/xorg.conf

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 440.64

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "nvidia"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Faire fonctionner la carte intégrée pour l'écran

Voir LinuxFr - Utiliser la carte graphique NVIDIA et la carte INTEL intégrée

PS : Xorg est obligé de créer un “Screen” par carte graphique, et qu'un Screen n'est pas un écran physique

/etc/X11/xorg.conf

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen1"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    #Option         "ConstrainCursor" "off"
    Option         "UseDisplayDevice" "none"
    Option         "ProbeAllGpus" "false"
    Option         "AllowEmptyInitialConfiguration"
    #Option         "IgnoreDisplayDevices" "CRT"
EndSection

Section "Device"
    Identifier     "Intel"
    BusID          "PCI:0:2:0"
    Driver         "modesetting"
    VendorName     "Intel Corporation"
    #BoardName      "Display controller"
    #ModelName      "Device 3e98"
    #Option         "AccelMethod" "SNA"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Intel"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "nvidia"
EndSection
$ lspci | grep 'Display controller: Intel Corporation Device' | awk -F'[:. ]' '{print $1, $2, $3}' | sed -r 's|0([0-9]) |\1:|g'
0:2:0

https://github.com/Bumblebee-Project/Bumblebee/blob/master/conf/xorg.conf.nvidia

xorg.conf

Section "ServerLayout"
    Identifier  "Layout0"
    Option      "AutoAddDevices" "false"
    Option      "AutoAddGPU" "false"
EndSection

Section "Device"
    Identifier  "DiscreteNvidia"
    Driver      "nvidia"
    VendorName  "NVIDIA Corporation"

#   If the X server does not automatically detect your VGA device,
#   you can manually set it here.
#   To get the BusID prop, run `lspci | egrep 'VGA|3D'` and input the data
#   as you see in the commented example.
#   This Setting may be needed in some platforms with more than one
#   nvidia card, which may confuse the proprietary driver (e.g.,
#   trying to take ownership of the wrong device). Also needed on Ubuntu 13.04.
#   BusID "PCI:01:00:0"

#   Setting ProbeAllGpus to false prevents the new proprietary driver
#   instance spawned to try to control the integrated graphics card,
#   which is already being managed outside bumblebee.
#   This option doesn't hurt and it is required on platforms running
#   more than one nvidia graphics card with the proprietary driver.
#   (E.g. Macbook Pro pre-2010 with nVidia 9400M + 9600M GT).
#   If this option is not set, the new Xorg may blacken the screen and
#   render it unusable (unless you have some way to run killall Xorg).
    Option "ProbeAllGpus" "false"

    Option "NoLogo" "true"
    Option "UseEDID" "false"
    Option "UseDisplayDevice" "none"
EndSection

https://gist.githubusercontent.com/mokkabonna/7ebf99590e42fcee9dfe/raw/6963a2e2ff6255a2ee251435953eba27cc9f5275/gistfile1.txt

xorg.conf

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    #Inactive "intel" # Not supported ?
EndSection

Section "Device"
    Identifier "intel"
    Driver "intel"
    BusID "PCI:0@0:2:0"
    Option "AccelMethod" "SNA"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:2@0:0:0"
    Option "ConstrainCursor" "off"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
    Option "IgnoreDisplayDevices" "CRT"
EndSection

https://gist.githubusercontent.com/dvejmz/879eebb607b9069b536b/raw/df2ec920573326cd05f95452d5af87a4d055e6e4/sample-xorg.conf

xorg.conf

Section "ServerLayout"
	Identifier "layout"
	Screen 0 "nvidia"
	#Inactive "intel" # Not supported ?
EndSection

Section "Device"
	Identifier "nvidia"
	Driver "nvidia"
	BusID "PCI:1:0:0"
EndSection

Section "Screen"
	Identifier "nvidia"
	Device "nvidia"
	Option "AllowEmptyInitialConfiguration" "Yes"
EndSection

Section "Device"
	Identifier "intel"
	Driver "modesetting"
	Option "AccelMethod" "none"
EndSection

Section "Screen"
	Identifier "intel"
	Device "intel"
EndSection
2025/03/24 15:06

XML xpath parse

Il existe deux langages de requêtes XML : XPath et XQuery.

Voir aussi :

Lint

xmllint --noout fic.xml

xpath

virsh dumpxml VM1 |xpath -q -e "/domain/devices/disk[@type='file']/source/@file[1]"

Ansible

Exemple

/etc/ImageMagick-6/policy.xml

<policymap>
  <policy domain="resource" name="memory" value="256MiB"/>
  <policy domain="resource" name="map" value="512MiB"/>
  <policy domain="resource" name="width" value="16KP"/>
  <policy domain="resource" name="height" value="16KP"/>
  <policy domain="resource" name="area" value="128MB"/>
  <policy domain="resource" name="disk" value="1GiB"/>
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <policy domain="delegate" rights="none" pattern="URL" />
  <policy domain="delegate" rights="none" pattern="HTTPS" />
  <policy domain="delegate" rights="none" pattern="HTTP" />
  <policy domain="path" rights="none" pattern="@*"/>
</policymap>

Nous voulons ajouter

`/etc/ImageMagick-6/policy.xml

<policymap>
  <policy domain="resource" name="time" value="5"/>
</policymap>

Conf Ansible

- name: install deps for ansible xml module
  apt: name='{{ packages }}'
  vars:
    packages:
      - python-lxml  # For Ansible xml
      - python3-lxml # For Ansible xml

- name: /etc/ImageMagick-6/policy.xml - change timeout
  xml:
    path: /tmp/policy.xml
    xpath: /policymap/policy[@domain='resource' and @name='time']
    attribute: value
    value: "5"
2025/03/24 15:06

Notes X11

Quel est mon gestionnaire de fenêtres - what is my window manager running

sudo apt-get install wmctrl
wmctrl -m

Ou plus simplement

printf 'Desktop: %s\nSession: %s\n' "$XDG_CURRENT_DESKTOP" "$GDMSESSION"

Lister toutes les fenêtres ouvertes sur le serveur X11

xwininfo -tree -root
 
#
wmctrl -l

Fermer un fenêtre en ligne de commande

wmctrl -l
wmctrl -ic 0x02e00085

ou

# replace WID with your window ID
kill $(wmctrl -lp | awk '/^WID/ {print $3}')

Notes install X11 sur RedHat7

yum downgrade glibc glibc-common
yum downgrade plymouth --setopt=protected_multilib=false
 
yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
 
yum install gcc make kernel-headers kernel-devel
 
rpm -qa | grep kernel
uname -r
 
rpm -e kernel-3.10.0-327.28.3.el7.x86_64
 
mount /dev/cdrom /mnt/
./VBoxLinuxAdditions.run
 
#yum install bash-completion
 
systemctl status vboxadd
systemctl status vboxadd-service
systemctl status vboxadd-x11
 
#yum groupinstall 'X Window System' 'GNOME'
yum groupinstall 'Server with GUI'  --skip-broken --setopt=protected_multilib=false
yum downgrade dbus-libs avahi-libs dbus avahi-autoipd
yum groupinstall 'Server with GUI'  --skip-broken --setopt=protected_multilib=false
 
 
yum install open-vm-tools open-vm-tools-desktop
  1. Install xauth: sudo yum install xorg-x11-xauth
  2. Edit the /etc/ssh/sshd_config file, and enter the X11Forwarding variable in Yes.
  3. Restart the sshd service: sudo service sshd restart

WayPipe

Similar to ssh -X

waypipe ssh user@theserver weston-terminal
 
waypipe -c lz4=9 ssh remote-server application-binary

How to make xterm black background by default

Add to ~/.Xdefaults :

xterm*background: black
xterm*foreground: white

or

alias xterm='xterm -bg black -fg white'
2025/03/24 15:06

Wrapper to use su as sudo - Emulating sudo's behaviour with su

Ma proposition

sudo.sh

#!/bin/bash
 
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details
 
ARGS_STRING=''
 
add_arg() {
        ARGS_STRING="${ARGS_STRING} $*"
}
 
echo "!!! WARNING: Using a fake sudo command !!!" >&2
 
while [ "${1-}" != "" ]; do
        case $1 in
        -s)
                shift
                add_arg "-s $1"
                ;;
        -u)
                shift
                add_arg "-p $1"
                ;;
        --)     # End of all options
                shift
                break
                ;;
        *)
                add_arg -c
                add_arg "'$*'"
                shift
                break
                ;;
        esac
        shift
done
 
# echo su "${ARGS_STRING}"
eval su "${ARGS_STRING}"

Autres exemples

Exemple 1
su_wrapper() {
    su -s /bin/bash -c "$(printf "%q " "$@")"
}

ou

su_wrapper() {
    local IFS=' '
    su -c "$*"
}

Source : https://stackoverflow.com/questions/24340664/emulating-sudos-behaviour-with-su

Exemple 2

sudo-su

#! /bin/sh
set -e
 
# A wrapper around su and sudo to implement a basic sudo-style interface with
# su and a basic su-style interface with sudo.
# 
# This can be useful when using tools such as pdebuild(1) that integrate
# privilege escalation only with sudo, or only with su: by having it run
# this program instead, you actually use su, or sudo instead seemlessly.
#
# Copyright (C) Tanguy Ortolo <tanguy+sudo-su@ortolo.eu> 2011
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details. 
 
 
usage()
{
    rc=$1
    echo "Usage: sudo-su COMMAND" >&2
    echo "       su-sudo -c \"COMMAND\"" >&2
    echo "sudo-su uses su to implement a basic sudo-style interface" >&2
    echo "su-sudo uses sudo to implement a basic su-style interface" >&2
    exit $rc
}
 
fake_sudo()
{
    TEMP="$(getopt -s sh -o +h --long help -n "$0" -- "$@")"
    if [ "$?" != 0 ]
    then
        usage $?
    fi
    eval set -- "$TEMP"
    while [ "$1" != "--" ]
    do
        case "$1"
        in
            -h|--help) usage 0 ; shift ;;
        esac
    done
    shift
    if [ "$#" -eq 0 ]
    then
        echo "sudo-su requires a command" >&2
        usage 1
    fi
 
    command=""
    for arg in "$@"
    do
        # To represent single quotes from single-quote mode:
        # leave single-quote mode, enter double-quote mode, write the single quote,
        # leave double-quote mode, enter single-quote mode.
        arg="$(echo "$arg" | sed -e "s/'/'\"'\"'/g")"
        if [ -z "$command" ]
        then
            command="'$arg'"
        else
            command="$command '$arg'"
        fi
    done
 
    exec su -c "$command"
}
 
fake_su()
{
    TEMP="$(getopt -s sh -o hc: --long help,command: -n "$0" -- "$@")"
    if [ "$?" != 0 ]
    then
        usage $?
    fi
    eval set -- "$TEMP"
    while [ "$1" != "--" ]
    do
        case "$1"
        in
            -h|--help) usage 0 ; shift ;;
            -c|--command) command="$2" ; shift 2 ;;
        esac
    done
    shift
    if [ "$#" -ne 0 ]
    then
        echo "We take only a -c option, no argument, sorry" >&2
        usage 1
    fi
    if [ -z "$command" ]
    then
        echo "su-sudo requires a command" >&2
        usage 1
    fi
 
    exec sudo sh -c "$command"
}
 
 
case "$(basename $0)"
in
    sudo*) fake_sudo "$@" ;;
    su*) fake_su "$@" ;;
esac

Sources :

Autres

Proper usage of su :

su -c "$0" "$ZOO_USER" "$@"
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki