Leave task running after logging out from SSH

Assume you are logged in to a remote server via SSH and are running a task which takes longer to complete than you want to wait.

The straight-forward option would be to terminate the task and re-run it at a later time, but that is not always an acceptable option.

Instead you can send the active task to background and leave it running even after you log out.

  • Press Ctrl-Z to pause the task
  • Type bg to send it to the background and resume running
  • Type disown to disassociate the process with your SSH login, so that it does not terminate when you log out
  • Type exit to log out



Installing fonts locally in Linux

You can simply copy the font either as separate .TTF files or as a whole directory named after the family of the font, into the hidden directory .fonts inside your user’s home directory.

Then, if you want to start using the new font immediately, do rebuild the font cache with the command:

  • fc-cache -f -v

Enabling PostgreSQL server at startup

To have PostgreSQL server start automatically at boot do:

  • sudo systemctl enable postgresql

See differences between PDF files

A very convenient tool to visually display differences between two PDF files is diffpdf.

Fast image viewer for Linux

Meet feh – a fast and minimalist image viewer, suitable for quickly scrolling though your collection of resized photos without annoying jerks and delays.

It can be installed from your package repository.

One way to use it is to open the terminal window in the folder where your images are stored and run command:

  • feh -ZF

Here “Z” stands for zoom, and “F” stands for full screen. So it goes full screen and any images smaller than the screen size will be zoomed up. You can also add “r” parameter to recursively scan all subdirectories.

You can also set delay between slides. Read more about it all:

  • man feh

Client IP in SSH session

If you are writing a bash script and you want to know the remote public IP address of the client logged into the session via SSH, a simple way to do this is:

  • my_ip=`echo $SSH_CLIENT | awk '{ print $1}'`; echo $my_ip

Connecting to MySQL without a password

There may be situations when you need to log into MySQL without providing a password. Well, not exactly without providing it at all, but without doing it in an interactive way or writing it in the command line in plain text. A real life example is doing database dump for backup purposes.

Luckily MySQL provides a mechanism to do just that. What you do is you create a file accessible only to you and MySQL and save your password within.

The procedure is very simple:

  • Go to your home directory
  • Create a hidden file named .my.cnf
  • Open it in a text editor
  • Create a section called “[client]” and provide your MySQL password, like this:
  • Update access rights for better security:
chmod 600 .my.cnf