How to check if package is installed

To check if ca-certificates package is installed run this command:

dpkg -s ca-certificates
| 1 Mar 2017

Print exit code of the last command

To print exit code of the last command type:

echo $?
| 1 Mar 2017

Show raw SQL queries in PostgreSQL

If you want to inspect what queries exactly Django ORM sends to the PostgreSQL, you can do it with postgres logging. The first step is to enable logging. Add

log_statement = 'all'

to the file:

sudo vim /etc/postgresql/9.4/main/postgresql.conf

Then you are able to see raw SQL queries with command:

sudo tail -f /var/log/postgresql/postgresql-9.4-main.log
| 1 Jan 2017

How to fix ERROR: new encoding (UTF8) is incompatible

Sometimes I’m unable to create a database in UTF8 encoding because the template database is in the ASCII encoding. To fix it we need to recreate template database in UTF8. Start psql console:

psql -U postgres

Run the following commands:

UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';

DROP DATABASE template1;

CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';

UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';

\c template1

VACUUM FREEZE;
| 1 Jan 2016

Increase watches limit

Open configuration file:

sudo vim /etc/sysctl.d/90-override.conf

Add the following line to the end of the file to increase watches limit:

fs.inotify.max_user_watches = 524288
| 1 Jan 2016

How to format USB stick as FAT32

First step is to find the name of the USB stick in the system:

sudo fdisk -l

In my case the name of the device is /dev/sdc If the USB stick is mounted, unmount it with command:

sudo umount /dev/sdc

Finally, run the command to format USB stick:

mkdosfs -F 32 -I /dev/sdc
| 1 Jan 2016

How to remove all *.pyc files

Remove all *.pyc files from the current directory (and subdirectories):

find . -name \*.pyc -delete
| 1 Jan 2015

Disable Komodo Edit file association

Remove

text/plain=komodo-edit-9.desktop

from file

~/.local/share/applications/defaults.list
| 1 Jan 2015

Automatically start application during the boot

To start an application automatically in fedora, you need to create a *.desktop file in the directory ~/.config/autostart, for example:

gedit ~/.config/autostart/flux.desktop

The content of the file can be something like:

[Desktop Entry]
Type=Application
Name=flux
Comment=xflux
Exec=/home/jsn/app/xflux -l 52.3837151 -g 4.8806328
Terminal=false
| 1 Jan 2015

How to find out which package provides a specific file

If you need to find out, for example, which package in fedora provides htpasswd command, you may do it with the command:

yum provides \*bin/htpasswd
| 1 Jan 2015