Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, December 11, 2020

Tamil Numerals and Tamil Fractions

 Tamil Numerals

To type the Tamil numerals in any word documents or even typesetting in Latex set the Tamil99 keyboard layout in IBus Else if you know the Unicode character for the numerals you can encode it directly. In Tex editors such as TeXstudio lets you encode the Unicode Characters by pressing CTRL+ALT+u or you can goto Edit ---> Insert Unicode character, a dialog box will open ,now you can insert your Unicode character.  I will tell you how to type in Tamil as well as its Unicode character

^#0        0BE6                          0

^#1        0BE7                          1

^#2        0BE8                 ௨         2

^#3        0BE9                          3

^#4        0BEA                          4

^#5        0BEB                          5

^#6        0BEC                         6

^#7        0BED                          7

^#8        0BEE                          8

^#9        0BEF                          9

-          0BF0                 ௰          10  

-          0BF1                           100     

-          0BF2                            1000

The Tamil numbers 10,100 and 1000 comes under the Extended Tamil99 Standard, Linux in IBus supports only the standard Tamil99 Layout; select these from Special characters in Libreoffice in Linux. In case of LaTeX you can insert the  Unicode Character in your TeX editor. 

Tamil Fractions: 

 

Most Tamil fonts don't encode the Tamil Fractions glyphs. These fractions are mentioned in the supplementary block [11FC0-11FFF]. There are only two fonts support these fractions 1. Lohit Tamil chart   and  2. Noto Sans Tamil Supplement  . As I've mentioned earlier IBus doesn't  support the extended characters so you have to insert the Unicode characters.Comparing to the fonts from the Lohit Tamil chart, Noto Sans Tamil supplement is better.I will mention the Unicode character,its Tamil fraction, indo-arabic numeral representation and its Tamil word.


11FC0         𑿀         1/320        முந்திரி 

11FC1         𑿁           1/160       அரைக்காணி

11FC2         𑿂           1/80         காணி

11FC3         𑿃          1/64         கால் வீசம் 

11FC4        𑿄            1/40        அரை மா

11FC5        𑿅           1/32        அரை வீசம்

11FC6        𑿆           3/80        முக்காணி

11FC7        𑿇           3/64        முக்கால் வீசம்

11FC8        𑿈            1/20        மா

11FC9        𑿉           1/16        வீசம்   -1

11FCA*       𑿊           1/16        மாகாணி  -2

11FCB        𑿋            1/10        இருமா

11FCC       𑿌           1/8         அரைக்கால்

11FCD       𑿍            3/20        மும்மா

11FCE       𑿎           3/16        மூவீசம்

11FCF       𑿏            1/5         நான்கு மா

11FD0       𑿐            1/4         கால்

11FD1       𑿑             1/2         அரை -1

11FD2*      𑿒             1/2         அரை -2

11FD3       𑿓            3/4         முக்கால்

11FD4       𑿔             -           கீழ்

𑿔 ---- Downsizing factor when prefixed to a fraction it reduces it by a factor of 1/320

*  ---- Alternate way of writing


Reference:

https://pravins.fedorapeople.org/tamil-fraction-symbol-proposal-fonts/n4430.pdf

https://www.unicode.org/charts/fonts.html

https://unicode.org/charts/PDF/U0B80.pdf

https://www.unicode.org/charts/PDF/Unicode-12.0/U120-11FC0.pdf

 

 

Saturday, November 21, 2020

Writing a Letter using Latex

Latex is a typesetting system which follows the WISWYM paradigm.It can be used to   typeset any kind of document such as books,reports and even letters.  

To write a letter in you have load the letter class. By default it uses the modified block layout.

Important Packages to Load:

These are the important packages to  load in my perspective, they are

  • Nag 
  • Inputenc
  • fontenc
  • microtype
  • setspace
  • datetime
  • block [if you need the full block layout]

 The package Nag is to prevent from running obsolete or depreciated commands.  

Inputenc  is for loading unicode encodings and fontenc is for the extended character set.

 The microtype package is for character protrusion and font expansion, furthermore the adjustment of interword spacing and additional kerning, as well as hyphenatable letter spacing (tracking) and the possibility to disable all or selected ligatures.

The set space package as the name indicates sets the line spacing. The datetime packages helps modifies the date to our liking. 

Some website may say use the newlfm and isodoc packages but compare to them this package doesn't have any other options and works within the letter class makes it an ideal package for the letter layout

 code for loading the packages:

\RequirePackage[orthodox]{nag}                         \documentclass[a4paper,12pt,oneside]{letter}        \usepackage[utf8]{inputenc}                             \usepackage[T1]{fontenc}              \usepackage{microtype}                  \usepackage{setspace}                           \usepackage[nodayofweek]{datetime}

Page styles:

The letter class supports the following styles

        1. Headings
        2. Empty
        3. First Page
        4. Plain      

We  will be using the page style empty. The code to load the style is 

\pagestyle{empty}  

  Writing the letter:

We are using the empty page style,by default the letter class leaves an 1 inch space for the header and another 1.5 in for the top margin. We will be removing the header in our document. This will make sure there will be 1.5 inch margin from top,left and right.

The commands supported inside the document are 

          1. \address
          2. \signature
          3. \name
          4. \location
          5. \telephone  
          6. \opening
          7. \closing
          8. \encl
          9. \cc 

We begin the document by \begin{document}  in the letter the address of the sender is first written.  The From address is typed within the \address command. using \\ for starting a new line. The \signature command  as the name implies will put your name in closing leaving a space for you to manually sign your letter.

     \begin{document}   

     \address{type your address}             

     \signature{your name}

We begin the letter with the \begin{letter} followed by the receipient address. Next we add the opening greeting of the letter with \opening  followed by the subject of the letter. There is no command for the  subject. The subject must be below 1pt from the  opening and should be left justified  so we use the \begin{spacing} environment were we write our  subject.

   \begin{letter}{receipient's address} 

Before the \opening run the following  commands so that there won't be  a huge space from the top. Use the following commands with caution.If you have an header file then you shouldn't use this command. 

     \makeatletter
  \def\@texttop{}
  \setlength\headheight{0\p@}
  \setlength\headsep{0\p@}
  \setlength\footskip{0\p@}
  \setlength\topmargin{20pt}
  \setlength\footnotesep{0\p@}
  \setlength{\skip\footins}{0\p@}
  \makeatother

               \opening{Dear sir/Madam}
               \begin{spacing}{1}
                 \begin{flushleft}
                    Re: Your subject
                 \end{flushleft}
               \end{spacing}

After this write your content of the letter. A business or formal letters should be a one  page document. Finish the letter with the \closing{Regards,} command. If you have  enclosures with the letter then run the \encl{\\1. xy \\2. xx} and if you have multiple receipients then you should add courtesy copy command          \cc{\\1. aa \\2.bb

End the document with \end{letter} and \end{document}. The signature and closing might not be adequately right justified so use the \hfill command within that command. Finally save the file and compile in pdflatex and if compiled successfully it will produce a pdf containing your letter which you can now print. 

Monday, October 19, 2020

You too can easily write in Hindi in Linux using IBus

 

 Yes you read that right, you can easily write in Hindi using IBus in Linux. Select itrans transliteration method for the Devanagari writing system.  Open your favorite editor and you can now type in Hindi. I am giving the keymap for the letters all you had to do is combine them.

Vowels

 

Consonants

 

 

 

 

 

 
 

 Numerals

 

Ligatures 


 






References:

1. https://www.aczoom.com/itrans/html/dvng/dvng.html


Thursday, October 15, 2020

Easy way to write in Tamil in Linux Using Ibus

 In the last post I had written on how to use IBus. Now we will see how to write in Tamil. When you select Tamil in the preferences it will give you a wide range of options such as Phonetic,Tamil99, Vutam, Inscript , Typewriter, Itrans and lk-renganathan. Of these use the phonetic and Tamil99  which are easier to write. One limitation is that it does not support the Tamil99 extended characters, viz the Tamil numeral for 10,100,1000 and fractions
Keymap for Tamil Phonetic

vowels


Image showing tamil vowels and its keymap




Consonants

Image Showing tamil Consonants and its keymap


Grantha Words 

The word க்ஷ  is a ligature of க+ஷ, and similarly ஶ்ரீ is a ligature of  ஶ் +ரீ . To write  க்ஷ  properly in Tamil phonetic layout do the following.
 
First type ஷ் then move your cursor before ஷ்   and type க் then go over to your next word it will render it as க்ஷ். Similary  for க்ஷி  first type ஷி move your cursor before ஷி and   type க் then go over to your next word now it will render it as ஷி 

Image Showing Grantha words and its keymap

* in Tamil99 layout. 

Tamil99 Keymap for Grantha Words

For the Grantha words one can use Tamil99 layout and for others phonetic layout as it is easy to write in tamil using phoentic layout.

image showing grantha word in tamil99 keymap




image showing grantha word and its  tamil99 keymap


image showing grantha word and its  tamil99 keymap


image showing grantha word and its  tamil99 keymap


image showing grantha word and its  tamil99 keymap

image showing grantha word and its  tamil99 keymap

Tamil Numerals And Special Characters 


In the Tamil language numerals are represented by letters and also there are special ligatures, we have to use the Tamil99 input method for writing this special characters

image showing tamil numerals and its tamil99 keymap



Image showing special characters and its tamil99 keymap


References:




Wednesday, July 24, 2019

QEMU: How to transfer files from Host to Guest

In virtual box there is a way to transfer files from host to guest and vice versa using the guest additions. In qemu there is a way to transfer files. First install
libguestfs-tools.

apt-get install libguestfs-tools

The libguestfs-tools package contains two important programs guestmount and guestunmount. To mount a image say with qcow2 format run

guestmount -a hd.qcow2 -m /dev/sda  /mnt/dir 

-a hd.qcow2: this option must be followed by a image file.
-m /dev/sda: the disk layout  your image file has. If you don't know just type random disk no and it will give you a layout of the image file.
 /mnt/dir: the mount point of your image.

No you can transfer your file. To unmount run

guestunmount  /mnt/dir

IMPORTANT: Never mount an image when qemu is running. It will corrupt the image.

Reference:

 http://ask.xmodulo.com/mount-qcow2-disk-image-linux.html
 

Tuesday, July 23, 2019

HOW-TO: QEMU

There are many  popular virtualization software in the wild  such as virtual box, vmware, etc. But there is another virtualization software native to linux and is opensource that is Qemu. It can also emulate hardware level virtualization.
To install qemu run the following command

apt-get install qemu

make sure you install qemu-system-gui otherwise you will be left without GUI and you will only see

VNC server started at 127.0.0.1:5869

make sure you also installed libsdl-dev and libconsole packages. If you don't want to have GUI then uninstall qemu-system-gui package and install gvncviewer.

apt-get install gvncviewer

To run gvncviewer use the following command

/usr/bin/gvncviewer localhost ::1:5869

First we need  to create a virtual hard disk  file. The native format for qemu is a raw file but if you have more disk space then it is recommended to use qcow2 format to create a virtual image we use the qemu-img command.

qemu-img create -f qcow2 hd.qcow2 1G

if you use .img for your image qemu will give warning about explicitly specifying a format.
-f qcow2 says create a  image with the format qcow2
1G says the file must of size 1 GB

To run your virtual os if your system is 32 bit then run qemu-system-i386 and  if it's 64 bit then run qemu-system-x86_64

For example to run freedos

qemu-system-i386 -m 512 -cpu host -enable-kvm -hda hd.cow2  -cdrom freedos.iso -boot order=d

-m 512: use ram of 512 MB
-cpu host: Emulate host cpu
-boot order=d: boot from cdrom

After you have installed your virtual os run

qemu-system-i386 -m 512 -cpu host -enable-kvm hd.qcow2

That's it you can now use your virtual os.



 

Sunday, July 21, 2019

HOW TO:Iptables rules for Debian Linux Desktop

Iptables rules follows a distinct classification 

Tables ---------> Chains  ----------> Rules

For Desktop the default tables is filter  it contains three chains INPUT, FORWARD and OUTPUT. The Input chain is for the incoming connection and the output chain is for the outgoing connection. For a strict policy deny input, output and the forward packets and then allow which ports are to be allowed.

Another important thing is you have allow certain icmp protocols,many tutorials tell you to drop the icmp protocol altogether but is unwise to do so. There are three icmp protocols  one  must allow they are 
  1. Ping
  2. Destination unreachable and 
  3. Time exceeded
Ping is a diagnostic tool that  helps to check if the network is  working  or not. If one is worried about ping of death or anything  you can always limit how much icmp packets you receive. 

The state module has been depreciated in favour of conntrack module. The ctstate has five options 

INVALID meaning that the packet is associated with no known connection

ESTABLISHED meaning that the packet is associated with a connection which has seen packets in both directions

NEW meaning that the packet has started a new connection, or otherwise associated with a connection which has not seen packets in both directions

RELATED meaning that the packet is starting a new connection, but is associated with an existing connection, such as an FTP data transfer, or an ICMP error.

 UNTRACKED : The packet is not tracked at all, which happens if you explicitly untrack it by using -j CT --notrack in the raw table.If  a packet is marked within the raw table with the NOTRACK target, then that packet will show up as  UNTRACKED in the state machine. This also means that all RELATED connections will not be seen, so some caution must be taken when dealing with the UNTRACKED connections since the state machine will not be able to see related ICMP messages et cetera. 

SNAT :  A virtual state, matching if the original source address differs from the reply destination.  

DNAT:  A virtual state, matching if the original destination differs from the reply source. 

INPUT chain policy

iptables -P INPUT DROP 

we are rejecting new connection if it does not have syn bit set in the packet header

iptables -A INPUT -p tcp ! --syn -m conntrack --ctstate NEW -j DROP 

Accepting  localhost connections  and established and related connections

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -p tcp -m conntrack --ctstate NEW -m limit --limit 60/s --limit-burst 30 -j ACCEPT

Dropping spoofing packets that originate from internet

iptables -A INPUT -s 10.0.0.0/8 -j DROP
iptables -A INPUT -s 169.254.0.0/16 -j DROP
iptables -A INPUT -s 172.16.0.0/12 -j DROP
iptables -A INPUT -s 127.0.0.0/8 -j DROP
iptables -A INPUT -s 192.168.0.0/24 -j DROP
iptables -A INPUT -s 224.0.0.0/4 -j DROP
iptables -A INPUT -d 224.0.0.0/4 -j DROP
iptables -A INPUT -s 240.0.0.0/5 -j DROP
iptables -A INPUT -d 240.0.0.0/5 -j DROP
iptables -A INPUT -s 0.0.0.0/8 -j DROP
iptables -A INPUT -d 0.0.0.0/8 -j DROP
iptables -A INPUT -d 239.255.255.0/24 -j DROP
iptables -A INPUT -d 255.255.255.255 -j DROP

Dropping Invalid bit set in packets

iptables -A INPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP

iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP

iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j DROP

iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
 

Dropping Null scan

 iptables -A INPUT  -p tcp --tcp-flags ALL NONE -j DROP   

Dropping Xmas Scan

iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP

iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP


Dropping Fragments

iptables -A INPUT -f -j DROP

Dropping Fin scan

iptables -A INPUT -p tcp --tcp-flags  ALL FIN -j DROP  

Dropping udp packets if it's length is too small

iptables -A INPUT -p udp -m length --length 0:28 -j DROP

Limit ICMP and accept certain protocols and drop rest of them

iptables -A INPUT -p icmp -m limit --limit 1/second --limit-burst 5 -j ACCEPT
iptables -A INPUT  -p icmp --icmp-type echo-reply -j ACCEPT
iptables -A INPUT  -p icmp --icmp-type destination-unreachable -j ACCEPT
iptables -A INPUT  -p icmp --icmp-type time-exceeded -j ACCEPT
iptables -A INPUT -p icmp -j DROP 

Drop Invalid Packets and log them

iptables -A INPUT -m conntrack --ctstate INVALID,UNTRACKED -m limit --limit 2/min -j LOG --log-prefix "INVALID: " --log-level 7
iptables -A INPUT -m conntrack --ctstate INVALID,UNTRACKED -j DROP
 

FORWARD POLICY

iptables -P FORWARD  DROP
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

iptables -A FORWARD -m conntrack --ctstate INVALID -j DROP

OUTPUT POLICY

iptables -P OUTPUT   DROP

Accepting Localhost and internet  

iptables -A OUTPUT -o lo  -j ACCEPT 
iptables -A OUTPUT -m conntrack --ctstate NEW,ESTABLISHED,RELATED -j ACCEPT

Allowing certain icmp protocols and rejecting rest of them 

iptables -A OUTPUT  -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT  -p icmp --icmp-type destination-unreachable -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type time-exceeded -j ACCEPT
iptables -A OUTPUT  -p icmp -j DROP

Logging Invalid Output and rejecting Invalid packets

iptables -A OUTPUT  -m conntrack --ctstate INVALID,UNTRACKED -m limit --limit 2/min -j LOG  --log-prefix "INVALID-OUTPUT: " --log-level 7
iptables -A OUTPUT  -m conntrack --ctstate INVALID,UNTRACKED -j DROP 


After all this you have save your rules otherwise it will be gone after you reboot your computer.To do this you must first have iptables-persistent package installed on your computer. To save the rules run

iptables-save > /etc/iptables.conf

to reload  your rules on next boot add the following lines in  
/etc/network/interfaces  after the lo section

iptables-restore < /etc/iptables.conf

and save the file. 

Iptable Logs 

 

By default all the logs are  in /var/log/kern.log. To log in a different file you must have rsyslog installed. Goto the folder /etc/rsyslog.d and create a file called iptables.conf and also at the sametime create a folder /var/log called iptables and in it create two files one for input and the other for output.

:msg, contains  "INVALID-INPUT: "  /var/log/Input.log
:msg, contains  "INVALID-OUTPUT: " /var/log/output.log

& stop 

then run service rsyslog restart as root.Now all invalid packets  will be logged in these two files.



References

1.https://manpages.debian.org/unstable/iptables/iptables-extensions.8.en.html 
2.https://www.cyberciti.biz/faq/linux-iptables-multiport-range/
3.https://www.digitalocean.com/community/tutorials/a-deep-dive-into-iptables-and-netfilter-architecture
4.https://serverfault.com/questions/84963/why-not-block-icmp/84981 
5.https://john.albin.net/essential-icmp 
6.https://unix.stackexchange.com/questions/108169/what-is-the-difference-between-m-conntrack-ctstate-and-m-state-state
7.https://askubuntu.com/questions/634788/iptables-allow-just-internet-connection 
8.All about ICMP messages
9.https://www.thegeekstuff.com/2011/03/iptables-inbound-and-outbound-rules/
10.https://www.cs.montana.edu/courses/309/topics/11-security/IPTables_discussion.html 
11.https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands 
12.https://www.booleanworld.com/depth-guide-iptables-linux-firewall/
13.https://unix.stackexchange.com/questions/191607/iptables-and-return-target
14.https://askubuntu.com/questions/939562/why-dont-my-iptables-log
15.Linux Firewalls by Steve suehring and Robert Ziegler.Third Edition

Tuesday, May 29, 2018

Flatpak Basic commands

Flatpak is a  packaging  format similar to exe files in  windows. With flatpak we don't have to hunt down libraries or having compilation nightmares. Apart from Flatpak there is also Appimage, Ubuntu Snap. So we will see some basic commands. 

i.First install flatpak for debian.

apt-get install flatpak

ii.   To install apps first we have to add a repository called flathub.

flatpak remote-add --if-not-exists  flathub 
https://dl.flathub.org/repo/flathub.flatpakrepo

iii. Before installing an  app we have to  install runtimes. Runtimes are basic libraries that are needed for an app to run. The available runtimes comes from freedesktop.org, GNOME  and Kde.

flatpak install flathub org.freedesktop.Platform
flatpak install flathub org.gnome.Platform
flatpak install flathub org.kde.Platform

For Gnome and Kde it will ask which version to install and always make sure you install the latest version. Also if you wish install the SDK

flatpak install flathub org.freedesktop.Sdk
flatpak install flathub org.gnome.Sdk
flatpak install flathub org.kde.Sdk 

See Flatpak available Runtimes

iv To list the apps in the remote directory

flatpak remote-ls  flathub

v. To list the apps installed in your system

flatpak list  --app

v[a]. To list the runtimes installed in your system

flatpak  list  --runtime

vi To install an app, for example VLCX
 
flatpak install org.com.videolan

vii. To uninstall an app 

flatpak uninstall org.com.videolan

viii. To update the apps

flatpak update

Flatpak command reference 

Popular Posts