Tips

Table of Contents

Fix screen brightness on wakeup

When LinuxMint (19.1) wakes up it has a maximum brightness and I have to lower it manually each time, which is inconvenient. To fix it automatically I have done these:

  • Created a script /usr/local/bin/fix-backlight.sh with a content like this:

    #!/bin/bash
    echo 368 > /sys/class/backlight/intel_backlight/brightness
    echo 51 > '/sys/class/leds/smc::kbd_backlight/brightness'
    
  • Made it executable:

    chmod +x /usr/local/bin/fix-backlight.sh
    
  • Created the service /etc/systemd/system/fix-backlight.service with a content like this:

    [Unit]
    Description=Run /usr/local/bin/fix-backlight.sh
    After=suspend.target hibernate.target hybrid-sleep.target
    
    [Service]
    ExecStart=/usr/local/bin/fix-backlight.sh
    
    [Install]
    WantedBy=suspend.target hibernate.target hybrid-sleep.target
    
  • Enabled this service:

    systemctl enable fix-backlight.service
    

Reference: https://unix.stackexchange.com/questions/152039/how-to-run-a-user-script-after-systemd-wakeup

How to build a VPN

Block adds

sudo wget https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts -O /etc/hosts

Use Secure DNS

Edit /etc/systemd/resolved.conf and place this content:

[Resolve]
# Use Quad9.net DNS, and Cloudflare DNS.
# Both supports DNS over TLS and DNSSEC,
# and promises not to log DNS queries.
DNS=9.9.9.9 1.1.1.1 2620:fe::fe 2606:4700:4700::1111
FallbackDNS=149.112.112.112 1.0.0.1 8.8.8.8 8.8.4.4 \
            2620:fe::9 2606:4700:4700::1001 2001:4860:4860::8888 2001:4860:4860::8844
# Attempt to use DNS over TLS
DNSOverTLS=opportunistic
# Enforce DNSSEC validation.
DNSSEC=true

Then restart systemd-resolved.service:

systemctl restart systemd-resolved.service

Reference:

Download a single package at a time

The command `apt upgrade` opens several download connections in parallel and sometimes this may be a problem because it saturates the network connections and bloks your work. It would be better if its download is less aggressive.

This can be improved with this setting:

echo 'Acquire::Queue-Mode "access";' >/etc/apt/apt.conf.d/75download

References:

Create a Wi-Fi hotspot in less than 10 minutes with Pi Raspberry!

If you have installed `ufw` on the Raspberry Pi, make sure to edit `/etc/default/ufw` and to set `DEFAULT_FORWARD_POLICY="ACCEPT"`.

Build an OpenVPN container

If you want to run this OpenVPN container on a RaspberryPi, you have to build the image yourself, like this:

git clone https://github.com/kylemanna/docker-openvpn
cd docker-openvpn
docker build -t kylemanna/openvpn .

Install font Monaco

mkdir -p /usr/share/fonts/truetype/Monaco
cd /usr/share/fonts/truetype/Monaco
wget https://github.com/mikesmullin/gvim/raw/master/.fonts/Monaco_Linux.ttf
fc-cache -f .

Reference:

Set color prompt

On ~/.bashrc uncomment force_color_prompt=yes and set PS1 like this:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]'

Enable bash completion

  • Make sure that the package bash-completion is installed:

    apt install bash-completion
    
  • Make sure that these lines at the end of ~/.bashrc are uncommented:

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
        . /etc/bash_completion
    fi
    

Enable/disable wifi from terminal

nmcli r wifi on
nmcli r wifi off

Author: Dashamir Hoxha

Created: 2020-08-17 Mon 16:35

Validate