Pseudo-terminal will not be allocated because stdin is not a terminal

If you need to run a job using cron and this job includes some remote access to Linux servers using ssh, your script may not behave the way you want:

Pseudo-terminal will not be allocated because stdin is not a terminal

The ssh tool provides the option -t.

As per ssh’s manpage:

-t’ Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

If you need to run a sudo command on the remote server, the option -t must be used several times as follows:
ssh -t -t -t -t fool@remote_host "sudo systemctl status apache2"

How to display the current time in a different timezone than yours ?

To quote an example from the Superuser forum:

It’s 6pm in Taipei, what time is it here?

date --date='TZ="Asia/Taipei" 18:00'
Fri Jul 16 11:00:00 BST 2010

At 11am here in London, what time is it in Taipei?

TZ=Asia/Taipei date -d "11:00 BST"
Fri Jul 16 18:00:00 CST 2010


Setting up a desktop notification in Ubuntu after login

The following actions have been tested successfully on Ubuntu 19.04

Setting a desktop notification in Ubuntu after login requires creating a Desktop application following the Freedesktop specifications.
All such applications run as a user must be located in $HOME/.config/autostart

The autostart folder may not exist.
If not :

mkdir -p $HOME/.config/autostart

As an example, this desktop application will be named welcome.desktop

Create this file as follows :

touch $HOME/.config/autostart/welcome.desktop

Add the following lines in it :

cat welcome.desktop

[Desktop Entry]
Comment=Startup Script

Create the bash script that will display the notification message :


#!/usr/bin/env bash

notify-send “Good morning ${USERNAME^} !” “Did you check your backups ?”

Make sure that the Exec field in your welcome.desktop file points to your script.

Reboot your Ubuntu machine and log in. Your custom desktop notification will be displayed !

Further readings :

XDG autostart specification

Different ways of autostarting applications in Linux

Desktop Application Autostart Specification

Python auto-completion in Vim with python-jedi on Ubuntu 19.04

python-jedi is a plugin available for Vim that features auto-completion for the Python programming language.
It is available as an Ubuntu package :

apt install vim-python-jedi

To enable it as a user :

vim-addons install python-jedi


vam install python-jedi

To start using it in Vim, the keyboard shortcut CTRL+Space is a good start for auto-completing.

Further readings :

jedi autocompletion library for VIM

VIM for development on Stackabuse

Running anacron as a user

By default, anacron execute jobs as root.
Anacron jobs can be run as normal user as well.

mkdir -p .anacron/{etc,spool}

cp /etc/anacrontab .anacron/etc

The variables $HOME and $LOGIN are set to root by default in /etc/anacrontab. Adjust their values accordingly.

To make sure that your anacron jobs will be run, add the following line in your $HOME/.profile :

/usr/sbin/anacron -s -t $HOME/.anacron/etc/anacrontab -S $HOME/.anacron/spool

According to anacron’s manpage :

-s : serialize execution of jobs. Anacron will not start a new job before the previous one is finished.
-t : specify the anacrontab instead of using the default one.
-S : specify the spooldir to store timestamps in.

Sources :

Debian’s manpage for anacron

Debian’s manpage for anacrontab

Askubuntu answer

Anacron for specific user

How to report when two files are the same ?

Comparing two files and looking for possible differences on a Linux like operating system is a common action.

diff is one of those utilities that you get to know when you deal with text files.

It is part of the coreutils, bundle of utilities provided by GNU : Coreutils manual

If you simply want to know if two files are the same, the GNU version of diff comes up with this feature using the -s or –report-identical-files options.

More information : Debian manpage for diff

Using shell variables in awk

It is possible to use shell variables within a awk command in a shell script.
As mentioned in the GNU Awk official documentation, one use case is that the shell variable holds the pattern that will be used by awk.
Here is one of the given examples :

printf "Enter search pattern: "
read pattern
awk -v pat="$pattern" '$0 ~ pat { nmatches++ }
END { print nmatches, "found" }' /path/to/data

If the pattern search is a bit more complicated than the one below $0 ~ pat, then this feature does not work anymore.

More details :

AWK : Using Shell Variables in Programs