Remember the code B.U.S.I.E.R.
echo b > /proc/sysrq-triggerTo obtain a view of a mounted filesystem (e.g. /) Without anything mounted on top
mount --bind / /mntTo get some kernel module information and parameter description the command modinfo can be used.
# modinfo iTCO_wdt
filename: /lib/modules/4.9.0-1-amd64/kernel/drivers/watchdog/iTCO_wdt.ko
alias: platform:iTCO_wdt
license: GPL
version: 1.11
[...]If the module is loaded, the kernel can be queried for information using systool.
# systool -v -m r8169
Module = "r8169"
Attributes:
coresize = "81920"
initsize = "0"
initstate = "live"
[...]Shutdown the machine and use the qemu-img command to resize the image. This example shows how to add 20 gigabytes to the vm-storage.img qcow2 image.
qemu-img resize vm-storage.img +20GOnce this is done, you need to resize the partitions inside. The virt-resize tool can be used for this (It's capable of resizing, shrinking or ignore different partitions inside the same image). This example shows how to expand the first partition on the vm-storage.img image to fill the available space.
virt-resize --expand /dev/sda1 vm-storage.img vm-storage-out.imgThe output image (here vm-storage-out.img) must be already present. A simple way with qcow2 images is simply to copy the source disk to a new destination file and then write on that.
cp vm-storage.img vm-storage-out.imgTo perform the commands on debian, install the libguestfs-tools package.
apt install libguestfs-toolsTo access all local system domain with virsh, first, the user must be part of the libvirt group.
usermod -a -G libvirt <username>Then, one must set the LIBVIRT_DEFAULT_URI environment variable to qemu:///system. Here is an example for bash.
export LIBVIRT_DEFAULT_URI=qemu:///systemTo mount a partition inside a raw disk image, one must know the offset (in bytes) of that partition from the start of the file. Then it can be mounted using the correct parameter for the mount command:
mount -o loop,ro,offset=xxxxxx disk_image.raw /mnt/image/To find the correct offset one can use a tool like parted.
# parted disk_image.raw
GNU Parted 3.2
Using /path/to/disk_image.raw
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit? [compact]? B
(parted) print
Disk /path/to/disk_image.raw: 250059350016B
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1048576B 16000221183B 15999172608B linux-swap(v1)
2 16000221184B 250059161599B 234058940416B ext4The number below the Start column is the offset.
mkdosfs /dev/diskpart -s 64 -S 512 -F 32The netstat tool is useful to show data on the port where processes are listening.
netstat -lTo show open TCP ports and established connections
netstat -vatnTo show open UDP ports
netstat -vaunOn the client machine (where you want to connect from)
ssh-keygen -t rsaAfter key generation is completed, transfer the key to the server machine (where you want to connect to). Supposing you saved your keys in ~/.ssh
cat ~/.ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys'Copy file from host C to host A, where the connection is A-B-C and A/C have no direct communication.
With OpenSSH <7.3
A$ scp -oProxyCommand="ssh -W %h:%p B" thefile C:destinationOtherwise
A$ scp -oProxyJump=B thefile C:destination
>>>>>>> 562edbfdf64089154651be6602e39120b4c35c87Wayland ignores .profile. You can still set environment variables leveraging the files in ~/.config/environment.d.
$ cd ~/.config/environment.d/
$ cat 60-openssl.conf
OPENSSL_ENABLE_MD5_VERIFY=1
NSS_HASH_ALG_SUPPORT=+MD5Disable the automatic downloading of updates in background
gsettings set org.gnome.software download-updates falseThe sysbench tool can be used to stress I/O, RAM access or CPU.
sysbench --test=fileio --file-total-size=512M prepare
sysbench --test=fileio --file-total-size=512M --file-test-mode=rndrw --init-rng=on --max-time=600 --max-requests=0 run
sysbench --test=fileio --file-total-size=512M cleanupsysbench --test=memory run --memory-total-size=1G
sysbench --test=memory run --memory-total-size=1G --memory-oper=readsysbench --test=cpu --cpu-max-prime=20000 runThe skill tool can be used to forcefully logout an user.
skill -KILL -u <username>Or the session can be terminated by killing the parent process
$ who
fbattaglia pts/0 2017-02-23 18:50 (2001:470:c89a:0:3655:ee9c:2c74:1282)
$ ps -dN|grep pts/0
17904 pts/0 00:00:00 bash
$ kill -9 17904Check ~/.gnupg/gpg-agent.conf and set pinentry to
pinentry-program /usr/bin/pinentry-ttyor
pinentry-program /usr/bin/pinentry-shThen restart the agent with
gpg-connect-agent reloadagent /byeOne can use the xxd tool
echo 5C1840 | xxd -p -r > data.binWe can use hexdump
cat filename.bin | hexdump -v -CCreate the following file
/usr/local/share/fontconfig/conf.avail/99-vscode.confWith this content:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!-- Force RGBA subpixel aliasing to none in code and code-insiders -->
<match target="pattern">
<or>
<test name="prgname">
<string>code</string>
</test>
<test name="prgname">
<string>code-insiders</string>
</test>
</or>
<edit name="rgba" mode="assign">
<const>none</const>
</edit>
</match>
</fontconfig>And then create a link to the following path
/etc/fonts/conf.d/99-vscode.confYou can check the progress of the sync op by using /proc/meminfo
watch grep -e Dirty: -e Writeback: /proc/meminfoEnable this to allow some applications to work in a sandbox (e.g. iridium). This applies to both Debian 9 and current (as the time of writing) sid.
echo kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/00-local-userns.conf
service procps restartThis works from dpkg 1.16.2 onwards.
dpkg --add-architecture <arch>To list installed kernel images/headers and residual configurations, this can be used.
dpkg --list | egrep -i --color 'linux-image|linux-headers'To find which package owns a file, the tool apt-file can be used.
apt-file search /path/to/fileBut first, the tool must be installed and the local database updated.
apt install apt-file
[...]
apt-file update
[...]The find command can be used for this
find . -name "*.extension" -type f -exec cp -v {} ./destination-dir \;Debian 9 uses systemctl to handle reboots, shutdowns, etc. The old SysV style commands can be restored by installing a compatibility package.
apt install systemd-sysvDebian 9 uses the new ip tool to handle interface configuration. The old style ifconfig can be restored by installing a package.
apt install net-toolsThe resolv.conf file is now managed by systemd-resolved service: to leverage the file updated by this service one can create a link this way
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf# cat /etc/systemd/network/wired.network
[Match]
Name=eth0
[Network]
DHCP=ipv4
IPv6AcceptRA=true
[DHCP]
UseDNS=true
UseNTP=true
SendHostname=true
UseDomains=trueBack to Menu