Postgresql login

Change the authentication method in the PostgreSQL configuration file pg_hba.conf from md5 to trust and reload the configuration.

#Approach A (Bitnami installations using system packages):
sudo sed -ibak 's/^\([^#]*\)md5/\1trust/g' /opt/bitnami/postgresql/conf/pg_hba.conf
sudo -u postgres pg_ctl reload

#Approach B (Self-contained Bitnami installations):
sudo sed -ibak 's/^\([^#]*\)md5/\1trust/g' /opt/bitnami/postgresql/data/pg_hba.conf
sudo -u postgres pg_ctl reload

Connect to the PostgreSQL database and set the password to a new value:

psql -U postgres
postgres=# alter user postgres with password 'NEW_PASSWORD';
postgresl=# \q

Finally, change the authentication method back to md5 and reload the old PostgreSQL configuration:

#Approach A (Bitnami installations using system packages):
sudo sed -ibak 's/^\([^#]*\)trust/\1md5/g' /opt/bitnami/postgresql/conf/pg_hba.conf
sudo -u postgres pg_ctl reload

#Approach B (Self-contained Bitnami installations):
sudo sed -ibak 's/^\([^#]*\)trust/\1md5/g' /opt/bitnami/postgresql/data/pg_hba.conf
sudo -u postgres pg_ctl reload

Connect to sftp

From the terminal one can connect by using the following command:

ssh user@remote-server

From Files manager, go to Other Locations and then enter the remote address at the bottom of the window

Vpn client on Ubuntu

Install the following packages

sudo apt install openvpn network-manager-openvpn network-manager-openvpn-gnome
or
sudo apt install network-manager-l2tp network-manager-l2tp-gnome

Then, restart network-manager

sudo service network-manager restart

For OpenVPN, import the following configuration

sudo nmcli connection import type openvpn file huawei.ovpn

For l2tp, configure IPSec pre-shared key, phase 1 and phase 2 algorithms

Phase1 Algorithms: enc-integ-group 
                   aes128-sha1-modp1024
Phase2 Algorithms: enc-integ
                   aes128-sha1

If it doesn’t work, reboot the computer and try again with the previous command.

Cluster inspection

The basic command used to view cluster objects is

kubectl get pods,svc,ingress.. -n <namespace>

However, this command doesn’t always work. Particularly, in situations when the namespace is being terminated. If this is the case, a more advanced command can be used:

kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -l <label>=<value> -n <namespace>

Cluster deploy

Create rancher-cluster.yml file, containing all the nodes, following the official example : https://rancher.com/docs/rancher/v2.x/en/installation/ha/kubernetes-rke/

rke up --config ./rancher-cluster.yml

Install helm and run all prerequisites for installing it: https://rancher.com/docs/rancher/v2.x/en/installation/ha/helm-rancher/

kubectl -n kube-system create serviceaccount tiller

kubectl create clusterrolebinding tiller \
  --clusterrole=cluster-admin \
  --serviceaccount=kube-system:tiller

helm init --service-account tiller

Install rancher

helm install rancher-latest/rancher \
  --name rancher \
  --namespace cattle-system \
  --set hostname=<rancher.url>

Backup & rollback cluster: https://rancher.com/docs/rke/latest/en/etcd-snapshots/

rke etcd snapshot-save --config cluster.yml --name snapshot-name 
rke etcd snapshot-restore --config cluster.yml --name snapshot-name

Additional step, fix rancher ingress route with tls.source=letsEncrypt by running:

kubectl edit ingress/<rancher.ingress> -n cattle-system

Mount NTFS with permissions

Identify the partition

sudo blkid

Mount the partition once

sudo mount /dev/sdXN -t ntfs-3g -o permissions [Mount point]

Map the users defined on the Windows system present on [Mount point].

When there are no more significant files, ntfs-3g.usermap creates the mapping file into the file UserMapping in the current directory. This file has to be moved to the hidden directory .NTFS-3G in the root of [Mount point]

ntfs-3g.usermap [Mount point]
#or
ntfsusermap [Mount point]

Mount the partition on boot by editing /etc/fstab

UUID=[The UUID of the partition]   [Mount point]     ntfs-3g permissions     0       1

Example:

UUID=7FC482015907F743   /media/Data     ntfs-3g permissions     0       1

Then, reboot the computer. On boot, it should automatically mount the partition on the specified mount point with options ‘permissions’ and you will be able to edit the permissions of the files on the NTFS partition with ‘chmod’ and ‘chown’ !

NOTE: Performing a full shutdown on Windows will allow the drives to be fully mounted by Ubuntu. This can be accomplished by holding the SHIFT key as you press the “Shut down” button on the “Power” menu.

More info at the following address: https://wiki.archlinux.org/index.php/NTFS-3G

Image Convert

Make sure ImageMagick is installed or install it

ls -al /etc/ImageMagick-6/policy.xml
#if not present, install
sudo apt install imagemagick

Once you have it installed, use the ‘convert’ command-line tool of ImageMagic. Just provide the paths to individual images and at the end of the command, name the output file. For example, something like this:

convert image1.jpg image2.png image3.bmp output.pdf
#or resize by procentage
convert  -resize 50% source.png dest.jpg
#or resize to specific size
convert -resize 1024X768  source.png dest.jpg

If the following error appears:

convert: not authorized `pictures.pdf' @ error/constitute.c/WriteImage/1028.

Edit /etc/ImageMagick-6/policy.xml and change\ the PDF rights from none to read|write there. 

<policy domain="coder" rights="read|write" pattern="PDF" /> 

Install Node.js and npm

You can install Node.js and npm directly from NodeSource repository. Node.JS provides an easy to use a bash script for this purpose.
What you have to keep in mind that you need to specify which major version of Node.Js you want to install.
Let’s say you want to install Node.Js version 11. You can use the following commands:

curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -

To install the Node.js package, use the following command. Npm is also installed with this package.

sudo apt install nodejs

To upgrade Node.js, please execute the following:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

And in the end, check the installation.

node --version
npm --version

Desktop shortcut

  • Create Symlink in LinuxDesktop way: To create a symlink without a terminal, just hold Shift+Ctrl and drag the file or folder you want to link to to the location where you want the shortcut.

Fix Grub

sudo dd bs=4M if=Downloads/ubuntu-19.04-desktop-amd64.iso of=/dev/sdb conv=fdatasync
  • connect to the internet
  • install boot-repair:
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt update
sudo apt install boot-repair
  • run boot-repair and apply the default configuration

GRUB settings are stored in the /etc/default/grub file. Edit this file to change GRUB2’s settings. Scripts are also located in the /etc/grub.d/ directory. For example, on Ubuntu, there are scripts here that configure the default theme. There’s also an os-prober script that checks the system’s internal hard drives for other installed operating systems — Windows, other Linux distributions, Mac OS X, and so on — and automatically add them to GRUB2’s menu.

When you run the update-grub command, GRUB automatically combines the settings from the /etc/default/grub file, the scripts from the /etc/grub.d/ directory, and everything else, creating a /boot/grub/grub.cfg file that’s read at boot.

In other words, to customize your GRUB2 settings, you’ll have to edit the /etc/default/grub file and then run the sudo update-grub command.

sudo grub-install /dev/nvme0n1
sudo update-grub

For more info, feel free to read the following article: https://www.howtogeek.com/196655/how-to-configure-the-grub2-boot-loaders-settings/