Skip to content

Instantly share code, notes, and snippets.

View brunneis's full-sized avatar

Rodrigo Martínez brunneis

View GitHub Profile
@brunneis
brunneis / current-block-size.sh
Created February 28, 2018 11:43
Get the block size of the partition to which belongs the current directory
#!/bin/bash
stat -c %S -f .
@brunneis
brunneis / vmdk-bd.sh
Created March 1, 2018 15:14
Create a vmdk linked to a real device (VirtualBox)
#!/bin/bash
VBoxManage internalcommands createrawvmdk -filename sda.vmdk -rawdisk /dev/sda
@brunneis
brunneis / lvm-cheatsheet.md
Created March 2, 2018 20:55
LVM cheatsheet

Resize logical volume

lvresize -L +485G --resizefs /dev/fedora/root

@brunneis
brunneis / ssh-proxy.sh
Last active May 11, 2018 16:03
Create SSH proxy (SOCKS)
# f -> Requests ssh to go to background just before command execution
# C -> Requests compression of all data
# q -> Quiet mode
# N -> Do not execute a remote command
# p -> Port to connect to on the remote host
sudo ssh -D 1984 -f -C -q -N -p 22 username@servername
@brunneis
brunneis / enable-all.sh
Last active April 3, 2018 10:05
Enable all ports in firewalld (internal zone) if firewalld is a must
#!/bin/bash
firewall-cmd --zone=internal --add-port=0-65535/tcp --permanent
@brunneis
brunneis / poweron-hours.sh
Last active March 9, 2018 14:51
Number of hours the disk was powered on (S.M.A.R.T.)
# apt install -y smartmontools
DISK_DRIVE=sdc
sudo smartctl -a /dev/$DISK_DRIVE -d sat | grep Power_On_Hours
@brunneis
brunneis / rare-commands.md
Last active March 11, 2018 16:01
Useful (not so) rare commands
watch [options] command

Reload a file periodically


hdparm [options] device

-Tt - check drive read timings


@brunneis
brunneis / nextcloud-owncloud-commands.md
Last active December 14, 2019 13:00
Useful commands for dockerized Nextcloud / OwnCloud instances

Fix internal error after moving data

MariaDB [(none)]> use nextcloud;
MariaDB [nextcloud]> truncate oc_filecache;

Fix permissions

chown -R 33:33 config data
@brunneis
brunneis / nmap-ssh.sh
Created March 31, 2018 17:31
Scan devices listening on port 22 (SSH)
#!/bin/bash
sudo nmap -sS -p 22 192.168.10.0/24
@brunneis
brunneis / freeze-package.sh
Created March 31, 2018 17:55
Avoid updates for a given package (apt)
#!/bin/bash
PACKAGE=linux-u-boot-orangepione-next
sudo apt-mark hold $PACKAGE