a collection of miscellaneous projects of Paul Philippov

Linux Useful Tips

How to install comfortable Debian environment on Dell Latitude D630

$ su
# sed -i '/cdrom/d' /etc/apt/sources.list
# echo 'deb stretch contrib non-free' > \  
# apt update
# apt upgrade

# apt install firmware-linux firmware-iwlwifi
# echo 'GRUB_CMDLINE_LINUX_DEFAULT="video=SVIDEO-1:d"' >> /etc/default/grub
# grub-mkconfig -o /boot/grub/grub.cfg

# apt install sudo
# /sbin/usermod -a -G sudo <username>
# /sbin/usermod -a -G adm <username>
# reboot

after reboot, install useful tools

$ sudo apt install apt-transport-https aptitude nfs-common
$ sudo apt install ack feh inkscape jq mc ttf-mscorefonts-installer vim
$ sudo apt install build-essential git git-gui htop ruby ruby-dev rsync yarn
$ git config --global alias.up 'pull --rebase --autostash'
$ echo 'gem: --no-document' > ~/.gemrc
$ sudo gem update --system
$ gem pristine --all
$ sudo gem install bundler

replace Firefox ESR with Mozilla Firefox browser

$ sudo mkdir /opt
$ cd /opt
$ sudo wget
$ sudo tar xvf firefox-61.0.2.tar.bz2
$ sudo rm firefox-61.0.2.tar.bz2
$ mkdir -p ~/.local/share/applications
$ echo '[Desktop Entry]
Name=Firefox Stable
Comment=Web Browser
GenericName=Web Browser
X-GNOME-FullName=Firefox Stable Web Browser
Exec=/opt/firefox/firefox %u
' >> ~/.local/share/applications/firefox-stable.desktop
$ sudo apt autoremove --purge firefox-esr

remove unwanted packages

$ sudo apt autoremove --purge evince-gtk sugar-browse-activity apache2-doc debian-faq doc-debian libreoffice* xbrlapi 

configure fonts

$ mkdir -p ~/.config/fontconfig
$ echo "
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
" > ~/.config/fontconfig/fonts.conf

How to increase size of /tmp partition

$ sudo mount -o remount,size=12G /tmp/

How to fix "[drm:drm_atomic_helper_commit_cleanup_done [drm_kms_helper]] flip_done timed out" error

$ sudo vi /etc/default/grub

add video=SVIDEO-1:d to params of GRUB_CMDLINE_LINUX_DEFAULT

$ sudo update-grub

How to purge uninstalled packages

$ dpkg --get-selections | grep deinstall | awk '{print $1}'| xargs sudo apt-get -y --purge autoremove

How to create a bootable USB-stick from an ISO image

$ cat image.iso > /dev/sdX
$ sync

How to chroot into a guest system

$ sudo proot -q qemu-arm -S /mnt/path/to/guest-root/

How to secure SSH access

Add to /etc/hosts.allow

ALL: <your ISP IP range>

Add to /etc/hosts.deny

sshd: ALL

How to run sudo without a password

$ ME=$(whoami)
$ echo "$ME ALL=(ALL) NOPASSWD: ALL" | sudo tee "/etc/sudoers.d/$ME"
$ sudo chmod 0440 "/etc/sudoers.d/$ME"

Please note, that's insecure and dangerous! Use with caution.

How to look up hardware info

$ sudo dmidecode

How to look up partition UUIDs

$ ls -l /dev/disk/by-uuid

How to add a PPA in Ubuntu

$ sudo add-apt-repository ppa:aptname

How to add a PPA key to Ubuntu keyring

$ sudo apt-key adv --keyserver --recv-keys <key id>

Iterative deborphaner

$ while [ $(deborphan | wc -l) -ne 0 ]; do deborphan | xargs sudo dpkg --purge; done

by Philippe Teuwen

How to set non-US keyboard & language

$ sudo dpkg-reconfigure locales
$ sudo dpkg-reconfigure console-setup
$ sudo dpkg-reconfigure console-data
$ sudo dpkg-reconfigure console-locales
$ sudo dpkg-reconfigure keyboard-configuration 

How to remove orphan packages in ArchLinux

$ sudo pacman -Rs $(pacman -Qqtd)

How to re-compile a package from source in Debian/Ubuntu

$ sudo apt-get build-dep <pkgname>
$ sudo apt-get source <pkgname>
$ cd <pkgname-version>
$ dpkg-buildpackage -us -uc -nc

How to build a backport package in Debian/Ubuntu

$ sudo -s
# echo "deb-src sid main" >> /etc/sources.list.d/sid.list
# apt-get update
# apt-get install build-essential
# apt-get build-dep <pkgname>
# apt-get -b source <pkgname>
# dpkg -i <debs>
# exit

How to fix syslog-ng in OpenVZ Debian VPS

If you are getting the error syslog-ng: Error setting capabilities, capability management disabled; error='Operation not permitted' add the following line to /etc/default/syslog-ng:


How to enable radeon driver

$ sudo -s
# apt-get install firmware-linux-nonfree libgl1-mesa-dri
# mkdir /etc/X11/xorg.conf.d
# echo 'Section "Device"
  Identifier "Device0"
  Driver "radeon"
EndSection' > /etc/X11/xorg.conf.d/10-radeon.conf
# exit

How to enable Rus/Lat keyboard switching in LXDE on Debian

$ echo "@setxkbmap -model evdev -layout us,ru -variant , \
           -option grp:caps_toggle,grp_led:caps,compose:ralt" | \
  sudo tee -a /etc/xdg/lxsession/LXDE/autostart

How to disable both screensaver and dpms

$ xset s off -dpms

How to enable web camera in Skype

$ sudo mv /usr/bin/skype /usr/bin/skype.real
$ echo "LD_PRELOAD=/usr/lib/i386-linux-gnu/libv4l/ skype.real" | \
  sudo tee -a /usr/bin/skype

How to break a paywall

$ echo '# Breaking the Wall
' | sudo tee -a /etc/hosts

How to get a list of obsolete config files

$ dpkg-query -W -f='${Conffiles}\n' | grep obsolete

How to fix wget does not resolve local hosts

In /etc/nsswitch.conf change

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4


hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

How to speed-up Dell D630 ALPS Touchpad on Debian Jessy

$ xinput --set-prop 11 "Synaptics Move Speed" 24 24 0 0


$ xinput --set-prop 11 339 24 24 0 0

How to app GoogleCloudPrint printer to Debian Linux

$ wget
$ sudo dpkg -i cupscloudprint_20140814.2-1_all.deb  
$ sudo /usr/share/cloudprint-cups/
$ lpoptions -d GCP-Printer_Name

Optionally, print a test page:

$ lpr /usr/share/cups/data/testprint

How to add a WiFi connection to NetworkManager from console

$ sudo nmcli con add con-name MyConn ifname wlan0 type wifi ssid MySSID ip4 gw4
$ sudo nmcli con modify MyConn wifi-sec.key-mgmt wpa-psk
$ sudo nmcli con modify MyConn wifi-sec.psk MyPass123456

How to check root partition for errors

$ sudo touch /forcefsck
$ sudo reboot


$ sudo shutdown -rF now

How to setup fail2ban

Install fail2ban and add a config file jail.local into /etc/fails2ban/ directory.

ignoreip = <admin ip or subnet>
bantime = 84600
maxretry = 3
action = %(action_mwl)s

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true

enabled = true 

How to download snapshot of a droplet from DigitalOcean

$ ssh root@droplet "dd if=/dev/vda | gzip -1 -" | dd of=image.gz
$ gunzip image.gz
$ sudo losetup --partscan --find --show image
> /dev/loopX
$ sudo mount /dev/loopXp1 /mnt
$ sudo umount /mnt
$ sudo losetup -d /dev/loopX

How to check amount and parameters of installed memory modules

$ sudo dmidecode -t memory
$ sudo lshw -short -C memory

How to add missing Intel firmware for i915 card

Download missing files from Intel's blobs repository and place them into /lib/firmware/i915/ directory. Then run

$ sudo update-initramfs -u

How to add local hosts to Pi Hole DNS

$ sudo -s
# echo ' mywebsite.local' >> /etc/hosts.local
# echo 'addn-hosts=/etc/hosts.local'  >> /etc/dnsmasq.d/02-mydns.conf
# systemctl restart dnsmasq.service
# exit