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:

var=""

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

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

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

OR

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

https://github.com/Motion-Project
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
Solution:

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'>
<fontconfig>
<match target="font">
<edit mode="assign" name="antialias">
<bool>false</bool>
</edit>
</match>
</fontconfig>

 

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

Q6: How to create a soft or symbolic link?

I am installing p4v in /opt, but /usr/bin is on my path. Is it possible to create a soft or symbolic link for p4v from /opt to /usr/bin, so I can just type “p4v” since /usr/bin is in my path?

See man ln.

To create a symlink at /usr/bin/bar which references the original file /opt/foo, use:

ln -s /opt/foo /usr/bin/bar

You would need to apply the above command as root (i.e. with sudo).

Q7: How to increase/decrease the icon size on Ubuntu 18 launchpad (apps grid)?

edit /usr/share/gnome-shell/theme/gnome-shell.css (search for #dash. then change the icon size)

After that, restart the gnome shell by hit alt + F2, and type r and hit “enter”.

Q8: How to change cursor size on Ubuntu 18?

Go to “setting” application, click the Universal Access Tab and click Cursor size under the Seeing column.

Q6: How to install and run Cloud9 IDE on your local Ubuntu?

Cloud9’s git repository and instructions have changed since the other answer was posted. See https://github.com/c9/core/ for more information. The following instructions seem to work for me on a vanilla Ubuntu 14.04.

  1. Install Git if you haven’t already:
    sudo apt-get update && apt-get install build-essential
    sudo apt-get install git
  2. Install node.js if you don’t already have a recent version installed:
    # Install node.js
    wget -O  ~/node-v0.10.33-linux-x64.tar.gz http://nodejs.org/dist/v0.10.33/node-v0.10.33-linux-x64.tar.gz
    tar -zxf ~/node-v0.10.33-linux-x64.tar.gz
    rm       ~/node-v0.10.33-linux-x64.tar.gz
    echo 'export PATH=$PATH:~/node-v0.10.33-linux-x64/bin' >> ~/.bashrc
    source ~/.bashrc
  3. Download and setup Cloud9:
    # Setup and start Cloud9 server
    # (You can get a zip file instead of using git)
    git clone https://github.com/c9/core.git c9sdk
    c9sdk/scripts/install-sdk.sh
  4. After the server starts successfully, you can stop it with Ctrl-C. Then you can start it with a different workspace:
    node c9sdk/server.js -w ~/my_workspace/
  5. Visit http://localhost:8181 to see the Cloud9 IDE in your browser.