Linux - ybendito/tips GitHub Wiki

Common

Network sharing


nfs

  • Server: install nfs-utils, edit /etc/exports + sudo exportfs -rav+ ensure nfs-server.service is running
  • Client: mount -vvvv <server address>:<path on server> <path on client>

smb

  • Server: install samba, start smb.service, sudo smbpasswd -a <username>
  • Client:
    mount -t cifs -o username=user //192.168.1.122/myshare /mnt/share

qemu custom parameters (2 variants)

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<qemu:commandline>
<arg value='-global'/>
<arg value='e1000.mitigation=off'/>
<env name='ID' value='wibble'/>
</qemu:commandline>
 **OR**
<commandline xmlns="http://libvirt.org/schemas/domain/qemu/1.0">
<arg value='-global'/>
<arg value='e1000.mitigation=off'/>
<env name='ID' value='wibble'/>
</commandline>

virsh hmp commands

virsh -c qemu:///system qemu-monitor-command --hmp <domain> '<command> [...]'
v qemu-monitor-command --hmp red 'system_powerdown'

port scan

for TCP `nmap -sT -p5900-5960 virtlab1009.lab.eng.rdu2.redhat.com`

SR-IOV configuration

echo 2 > /sys/class/net/enp1s0f0/device/sriov_numvfs
ip link set enp1s0f0 vf 0 mac 52:54:00:ac:39:e2

Mount QCOW2 image

#!/bin/bash
echo mounting $1 on $2
if [ -e $2/. ]; then
  echo directory $2 exists
else
  echo creating $2
  mkdir $2
fi
modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 $1
fdisk /dev/nbd0 -l
mount /dev/nbd0p3 $2
echo running nested shell, type 'exit' to unmount
bash
umount $2
qemu-nbd --disconnect /dev/nbd0
rmmod nbd

enter ruby namespace

#!/bin/bash

if [ x$1 == x ]; then
   echo $0 program args ...
   echo this command will run inside autohck namespace
   echo RUN as admin!
   exit
fi

pid=`ps ax | grep 'ruby bin/auto_hck' | grep -v grep | head -n1 | awk '{print $1;}'`
if [ x$pid == x ]; then
    echo Ruby instance is not found
else
    echo Found ruby process $pid
    echo command to run: $*
    sudo nsenter -m -n -t $pid $*
fi

Extract RPM content

rpm2cpio file.rpm | cpio -idmv

⚠️ **GitHub.com Fallback** ⚠️