Linux OS

Q1: How can I check if a variable is empty in bash?

In bash at least the following command tests if $var is empty:

if [[ -z "$var" ]]

The command man test is your friend.

Presuming bash:


if [[ -z "$var" ]]; then
 echo "not empty"
 echo "empty"

Q2: How to assign a shell command output to a variable?

var=$(command-name-here arg1)
var=$(/path/to/command arg1 arg2)


var=command-name-here var=command-name-here arg1 var=/path/to/command var=/path/to/command arg1 arg2

Q3: A motion detection or video streaming utility on Linux
A note on using motion on Raspberry Pi with the camera module (Rasp V3 with camera V2)
When you run motion, you always get a “unable to open video device” error and a grey screen

You can access the camera board on /dev/video0 by running the command:

sudo modprobe bcm2835-v4l2

This will have to be run on every boot of the device. Or you can put modprobe bcm2835-v4l2 in /etc/rc.local to make it run on every boot automatically.

Q3: How to turn off font anti-alias in Ubuntu (to further change the default font, install “unity-tweak-tool”.
You can control the antialiasing of fonts in ~/.fonts.conf

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<match target="font">
<edit mode="assign" name="antialias">


Q5: The default font of Sublime Text on Windows) is Consolas and you might change it >preference>setting. You might also install it on Ubuntu and MacOS