Skip to content

Instantly share code, notes, and snippets.

View okv's full-sized avatar
🐾
I may be slow to respond.

Oleg Korobenko okv

🐾
I may be slow to respond.
View GitHub Profile

Remote hard reset via ssh

Sometimes, reboot or shutdown -r now, don’t work anymore.

echo s > /proc/sysrq-trigger &&
echo u > /proc/sysrq-trigger &&
echo s > /proc/sysrq-trigger &&
echo b > /proc/sysrq-trigger
# become root
sudo -s
# do the job
sed 's/#GRUB_DISABLE_RECOVERY="true"/GRUB_DISABLE_RECOVERY="true"/' -i /etc/default/grub
update-grub

You should obtain a similar result, easier, enabling the hidden config option (about:config).

  1. In Firefox's address bar, type about:config and accept the warning that it will give. Now it appears in front of you a long list of config options. Filter it typing the keyword quit in the filter bar (up top). After that the filter acts you will have only few lines. Click on browser.showQuitWarning and set it true by clicking on it.
  2. You can use this filter again with the keyword warnon and see if the options "warn when close tabs" and similar are set to true. 3.In the Firefox's Options/Preferences (or Edit/preferences it depends from system and version), go to the Tabs section and check the option "Warn me when closing multiple tabs". This will prevent you to close a window with multiple tab.

You will not completely disable CTRL-Q but at least you will make it harmless.

@okv
okv / gist:2b0d9b6c1c73c036cabc
Created July 22, 2014 10:29
Icinga2: Configuration Syntax Highlighting using Vim
PREFIX=~/.vim && mkdir -p $PREFIX/{syntax,ftdetect} && curl https://raw.githubusercontent.com/Icinga/icinga2/ec75e7dcbbf8c5650197a82107969936220707c8/tools/syntax/vim/syntax/icinga2.vim > $PREFIX/syntax/icinga2.vim && curl https://raw.githubusercontent.com/Icinga/icinga2/ec75e7dcbbf8c5650197a82107969936220707c8/tools/syntax/vim/ftdetect/icinga2.vim > $PREFIX/ftdetect/icinga2.vim

Disable linux account

Lock, expire and set no login shell for account:

(export user="someuser" && usermod -L "$user" && chage -E0 "$user" && usermod -s /sbin/nologin "$user" && echo "User $user is locked")

unlock:

@okv
okv / ubuntu-12.04-tips.md
Last active October 13, 2015 22:38
Tips and tricks for ubuntu 12.04 like single line bash scripts for allowing hibernate, adding useful ppa's, etc.

Enable hibernate in the menu at Ubuntu 12.04 (details at https://help.ubuntu.com/12.04/ubuntu-help/power-hibernate.html)

echo -e "[Re-enable hibernate by default]\nIdentity=unix-user:*\nAction=org.freedesktop.upower.hibernate\nResultActive=yes\n" | sudo tee /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla > /dev/null && echo "All done, now you can hibernate from the menu"

Allow run sudo pm-hibernate without password at Ubuntu 12.04 for selected USER_OR_GROUP

USER_OR_GROUP="plugdev"; echo "%$USER_OR_GROUP ALL=(ALL) NOPASSWD: `which pm-hibernate`" | sudo tee /etc/sudoers.d/hibernate > /dev/null && echo "All done, now you can run 'sudo pm-hibernate' from '$USER_OR_GROUP' without password"