How to install/uninstall libreoffice using terminal on ubuntu 16.04

On windows I was comfortable using GUI to install and uninstall software but in Ubuntu I am more comfortable using terminal. Please fine below steps to Uninstall LibreOffice from Ubuntu 16.04.

sudo apt-get remove --purge libreoffice*  
sudo apt-get clean  
sudo apt-get autoremove  

Steps to install LibreOffice on Ubuntu using terminal

sudo add-apt-repository ppa:libreoffice/ppa  
sudo apt-get update  
sudo apt-get install libreoffice  

Using .deb file
1. Download .deb file from Current latest version is
There might be a new version when you are reading this. Please use latest version.
2. Run following commands

tar -xvzf LibreOffice_5.4.2_Linux_x86-64_deb.tar.gz  
cd LibreOffice_5.4.2_Linux_x86-64_deb/DEBS/  
dpkg -i *.deb  

Ubuntu Quick Reference

change folder ownership

sudo chown -R $USER /var/www  

Rename folder

mv CodeIgniter-3.1.6/ codeignitor316  

Copy Folder (Please make sure folder path is from root directory and not the relative path)

sudo cp -r /var/www/mediawiki /var/www/mediawiki  

Copy File

sudo cp /var/www/  

unfiz tar file

tar xzf file.tar.gz  

List of installed softwares. Second command will save this list in text file.

apt list --installed  
dpkg --get-selections > list.txt  

Uninstall app

sudo apt remove <app_name>

NGINX start and stop

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
# Error log
tail -f /var/log/nginx/error.log

Update local host file

sudo -i gedit /etc/hosts


Upgrade sublime text

sudo apt-get install --only-upgrade sublime-text

Some useful commands

Activity command
sudo service postgresql start
sudo service postgresql stop
sudo service postgresql restart
Update Host file
sudo nano /etc/hosts

Getting started with PHP

Your PHP code goes inside the

code here  

To display text in HTML output page

echo "this is output";  

Make sure to end your line of PHP code with a semicolon

String Manipulations
$name = "Luke Perry";
echo strlen($name); // 10  
echo substr($name, 0, 3); // Luk  
echo strtoupper($name); // LUKE PERRY  
echo strpos($name, "e Perry"); // 3  
// concatenation
echo "hello" . "user";  

All variable names in PHP start with a dollar sign


comment is started with either of following code



> Greater than
< Less than  
<= Less than or equal to  
>= Greater than or equal to
== Equal to
!= Not equal to
Conditional Sentence
    if ( 2 > 10) {
        echo " ok";
    else if ( 2 == 33 ) {
        echo "ccc";
    else if ( 3 == 34) {
        echo "this is 3";
    else {
        echo "nothing mathcn";
    switch (2) {
        case 0:
            echo 'The value is 0';
        case 1:
            echo 'The value is 1';
        case 2:
            echo 'The value is 2';
            echo "The value isn't 0, 1 or 2";

Using or clause with switch

    switch ($i) {
        case 0:
            echo '$i is 0.';
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
            echo '$i is somewhere between 1 and 5.';
        case 6:
        case 7:
            echo '$i is either 6 or 7.';
            echo "I don't know how much $i is.";
Working with Array

defining array and adding new element

        // Add your array elements after
        // "Beans" and before the final ")"
        $array = array("Egg", "Tomato", "Beans" );        
$states = array();
$array = array_push($states, "Montana");
$array = array_push($states, "North Carolina");
$array = array_push($states, "California");
echo $array; // returns 3  

Pushing multiple elements together

$states = array(); // target array
$array = array_push($states, 
"North Carolina", 
echo $array; // returns 3  

Print array

echo $tens[2];  
echo $tens{2};  

Modify and delete array element

$languages[1] = "green";
        foreach($languages as $lang) {
          print "<p>$lang</p>";

another example

        // Echoes the first five even numbers
        for ($i = 2; $i < 11; $i = $i + 2) {
          echo $i;

fuzzywuzzy : string matching Python

Many times while dealing with text analytics, we need to compare text. There are multiple algorithms and approaches to do the job. Lets have a look at fuzzywuzzy library.

pip install fuzzywuzzy  
pip install python-Levenshtein  

fuzzywuzzy will work even if you dont install python-Levenshtein but installing it will enhance performance.

Using fuzz.ratio

This is basic comparison and output is as below

>>> from fuzzywuzzy import fuzz
>>> from fuzzywuzzy import process
>>> fuzz.ratio("ABCD", "ABCD")
>>> fuzz.ratio("ABCD", "ABCDE")
>>> fuzz.ratio("ABCD", "ABCDEF")
>>> fuzz.ratio("ABCD", "ABCDEFG")
>>> fuzz.ratio("ABCD", "ABCDEFGH")
>>> fuzz.ratio("ABCD", "ABCDEFGHI")
>>> fuzz.ratio("ABCD", "ABCDEFGHIJ")
Using partial_ratio

ratio is very simple comparison, you can use partial_ratio to do sub-string mapping.

>>> fuzz.partial_ratio("ABCD", "ABCDEFGHIJ")

But evening partial ration fails when words are scarmbled.

>>> fuzz.partial_ratio("India Vs Aus","Aus Vs India")
Using tokensortratio

Basically “India Vs Aus” and “Aus Vs India” are same thing but people can use either ways and both are valid. In cases of words where sequence might be different,you can use tokensortratio

>>> fuzz.token_sort_ratio("India Vs Aus","Aus Vs India")
>>> fuzz.token_sort_ratio("India cricket team Vs Aus cricket team","Aus Vs India")

Now lets add further complication, if I add ‘cricket team’ in one of the word, match does not work.


In such cases, using tokensetration might help you.

>>> fuzz.token_set_ratio("India cricket team Vs Aus cricket team","Aus Vs India")
Which matching algorithm to use ?

Well, just because fuzz.tokensetratio works even with extra words, it might not be suitable for your application. Ultimately, it will boils down to what you want ti compare and how is use data.

You can take a look at other libraries such as jellyfish if you are looking for alternative approaches.