Wednesday, August 14, 2019

Remove Boxes in Docx files after editing in Google Docs

Google recently introduced improved editing of DOCX or Microsoft Word Document 2007 files. Previously DOCX documents could be edited but need to be saved as Google Doc files or later exported to another format.If it did open DOCX files, the level of compatibility would be roughly equivalent to Libre Office opening a DOCX file.
But recently Google has improved this and made it so that DOCX documents could be saved in the same format. This makes it possible to edit Word files on Android devices without having to use the Microsoft Word Android app. The Word app famously wanted an upgrade to Office365 before it could connect to Google drive in the past. It's possible now but it's a hit or miss affair. It was fine connecting to Dropbox or Box.com and doing it without the upgrade.
But this improvement hasn't been without a cost. DOCX documents saved in Google Docs end up with a Control Box around every paragraph. This first time it happened, it sucked out whatever joy there was of being able to save to DOCX in Google Docs. It was even quite clear what the box around the paragraph was.
But getting rid of it is simple. Select All text and using Ctrl-A.  Then Right-Click on the selected text and from the menu choose "Remove Content Control". The boxes should be removed.
This is a pain when editing and sharing DOCX over Google Drive with someone who is using Microsoft Word to edit the file.
Google Docs get updated from time to time without much fanfare. Hope this will be fixed soon.
 

Wednesday, July 3, 2019

Configure iscsi quickly on CentOS 7

If you have a Network Attached Storage (NAS), the best way to connect it to other servers is using the iSCSI method. Most companies use a NAS to store files and have employees connect to it directly to share files. But that method is not suitable to connect to other servers. This can be done when disk space on the a server runs low. Some setup on the NAS is needed to setup iSCSI on the NAS. Basically, an iSCSI LUN is created and then connected to a newly created or existing iSCSI target (aka iSCSI server). Refer to the NAS's configuration manual for detail.
Before we configure a Linux server to connect to a NAS over iSCSI, some information is needed first. This will help us when it is needed in the setup process.
First note the IP address of the NAS. Second, well need to know the iSCSI Target Name. This identifies the disk assigned to be used. If everything has ben setup properly, an ISCSI LUN would have been created and assigned to an ISCSI Target. Finally, the mount point for the disk needs to be known, too. This is the directory where the applications on the Linux server writes files to.

First install the necessary software components. At the command line

sudo yum install iscsi-initiator-utils

This will install the iSCSI initiator aka client files. Edit the file /etc/iscsi/initiatorname.iscsi and
add the line below if it isn't already there

InitiatorName=iqn.2014-08.com.example:client

This is the name of the initiator or client. In the example above, it is  'iqn.2014-08.com.example:client' 

Note: if an access control list (ACL) was set in the NAS, set ACL on target (iSCSI server) to match this client name. This will allow the client to connect to the iSCSI server.
Now start the iSCSI system

# systemctl start iscsi

Next, discover the targets available on the NAS. In the example below the NAS IP address is 192.168.1.25

# iscsiadm -m discovery -t st -p 192.168.1.25
192.168.1.25:3260,0 iqn.2000-01.com.synology:backupecc
192.168.1.25:3260,0 iqn.2000-01.com.synology:diskstation.target-1.d87a5fcd9b
192.168.1.25:3260,0 iqn.2000-01.com.synology:diskstation.target-11.d87a5fcd9

Look at the list and see whether the iSCSI target assigned is in the list. If it is, it's time to connect to it.  Set the iSCSI server to start automatically every time the server starts. Then restart it.

# systemctl enable iscsid.service
# systemctl restart iscsid.service

Add the target to our initiator (or connect our client to the target/ iSCSI server).The format of the command is

iscsiadm -m node -T <discovered target iqd> -p <ip of target> -l

So the execute the command using the information gathered

# iscsiadm -m node -T iqn.2000-01.com.synology:diskstation.target-11.d87a5fcd9b -p 192.168.1.25 -l
Logging in to [iface: default, target: iqn.2000-01.com.synology:diskstation.target-11.d87a5fcd9b, portal: 192.168.1.25,3260] (multiple)
Login to [iface: default, target: iqn.2000-01.com.synology:diskstation.target-11.d87a5fcd9b, portal: 192.168.1.25,3260] successful.

Look for the device name created from the command above.

# lsblk --scsi
NAME HCTL       TYPE VENDOR   MODEL             REV TRAN
sda  2:0:0:0    disk SYNOLOGY iSCSI Storage    3.1  iscsi
sr0  0:0:1:0    rom  QEMU     QEMU DVD-ROM     1.5. ata


In the above example, the device name is /dev/sda .

Confirm that it is not connected in READONLY mode. The RO column should be 0

# lsblk | egrep "NAME|sda"
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0  500G  0 disk


Connecting to the iSCSI target is like opening the server case and installing and connecting a new hard disk. Since the disk is connected, the disk has to be prepared. First, format the disk

# mkfs.ext4 /dev/sda
<output truncated>
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


or a better option would be

# mkfs.xfs /dev/sda
<output truncated>
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


Mount it to the mount point created or the directory where the system will store the files to the iSCSI disk to. In this example the mount point is /mnt/disk

# mount /dev/sda /mnt/disk

If everything is successful thus far, make it permanent by doing the following
1. Find UUID
2. insert into /etc/fstab

Finding the  UUID
# blkid /dev/sdb
/dev/sda: UUID="3d86fad7-1896-4538-acae-e78269b3a6a7" TYPE="ext4"

Make note of the UUID value. Edit /etc/fstab

# vi /etc/fstab

add the following line

UUID=3d86fad7-1896-4538-acae-e78269b3a6a7 /mnt              ext4           _netdev         0 0
                               

The format of the line is
<UUID>  <mount point> <what filesystem was created on it (ext4/xfs)> _netdev <this option waits for the network to start before connecting to the iSCSI disk> 0 0
The next time the Linux server restarts, it will connect to the new iSCI disk automatically. Test the disk anyway.

# mount /mnt/disk
# touch /mnt/disk/TestFile

The command above creates empty file called TestFile. If there are no errors in creating the file, the setup is complete. For more information, execute this command

# iscsiadm -m session -P 3

References
https://www.itzgeek.com/how-tos/linux/centos-how-tos/configure-iscsi-target-initiator-on-centos-7-rhel7.html
https://www2.linuxacademy.com/howtoguides/21208-how-to-share-your-storage-with-iscsi/
https://www.certdepot.net/rhel7-configure-iscsi-target-initiator-persistently/
https://www.thegeekdiary.com/complete-guide-to-configuring-iscsi-in-centos-rhel-7/


Sunday, September 16, 2018

De-Mystifying and Installing Orace Java for Linux

There is always some confusion when it comes to installing Java for Linux. A lot of applications are available for Java, especially for business. However, most of the instructions that come with these applications are for installing Java for Windows, which may seem to make it seem that installing Java for Windows is easier. Installing Java for Linux is in fact no more harder. It's just that Java itself has so many options. 
First, there are three different editions of Java: 
  1. Java Standard Edition (SE)
  2. Java Enterprise Edition (EE)
  3. Javae Micro Edition (ME). 
Most of the time, when refering to Java during installation, the instructions are referring to Java SE (Java Standard Edition). 
Next, Java offers several packages for installation.There are two different Java SE packages
  1. Java Runtime Environment (JRE) or sometimes called Java SE Runtime Edition. JRE is an implementation of the Java Virtual Machine (JVM). The JVM is the component that runs compiled Java applications and applets.
  2. Java Development Kit (JDK). JDK includes the JRE (and JVM) and other software that is required for developing, and compiling Java applications and applets.
Certain applications require a specific version of JRE, for example JRE 8 or JRE 10, These application will mention which version it requires or get a hint from the installation instructions.
Finally, thereare also two different implementations of Java: OpenJDK and Oracle Java. OpenJDK is the reference implementation of Java and is fully open source. Oracle Java was the original reference implementation and is commonly used by commercial applications. It is not surprising that commercial application require Oracle Java instead of OpenJDK. Most Java applications will work fine with either implementation. However, use the version recommended by the application being installed. If the application refers to downloading Java from Oracle, then it's likely requires Oracle Java. 
Since most business application require Oracle Java, the instructions below are specifically for Oracle Java. To install OpenJDK, the steps are simpler since it can be installed directly using the yum command without downloading the installation file (Step 3). The steps are divided into several steps
  1. Get the download URL for the Oracle Java JRE (http://www.oracle.com/technetwork/java/javase/index.html). Accept the license.
  2. Download the JRE rpm file using the URL file (it should look something like this: http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm). This can be done using either wget or curl.
    1. Using wget:  wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm"
    2. Using curl: curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm
  3. Install the RPM file using YUM: 
    sudo yum localinstall jre-8u161-linux-x64.rpm
  4. Confirm alternatives setting and take note of the path: sudo alternatives --config java
  5. Setup the environment variable for all users using the path from the step above (eg. /usr/java/jre1.8.0_161/jre):
    sudo sh -c "echo export JAVA_HOME=/usr/java/jre1.8.0_161/jre >> /etc/environment"  
Finally, setup the shell environment by adding the following commands to the /etc/bashrc file
export JAVA_HOME=/usr/java/jre1.8.0_161
export JRE_HOME=/usr/java/jre1.8.0_161/jre
export PATH=$PATH:/usr/java/jre1.8.0_161/bin:/usr/java/jre1.8.0_161/jre/bin
 
For extra points, the jar and jac Java components can also be setup to ensure a wider range of applications can use the installed java.
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_161/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_161/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_161/bin/jar
alternatives --set javac /opt/jdk1.8.0_161/bin/javac