{"id":1083,"date":"2020-10-13T08:29:43","date_gmt":"2020-10-13T08:29:43","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=1083"},"modified":"2020-10-13T08:29:44","modified_gmt":"2020-10-13T08:29:44","slug":"linux-utils","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2020\/10\/13\/linux-utils\/","title":{"rendered":"Linux Utils"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Ping<\/h1>\n\n\n\n<p>I have used <code>ping<\/code> often but never to an extend that I could understand the complete range of options and power available at hand.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote has-background has-vivid-red-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p>ping &#8211; send ICMP ECHO_REQUEST to network hosts<\/p><cite>from &#8211; man page of ping<\/cite><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">ICMP Packet details<\/h2>\n\n\n\n<p>An IP header without options is 20 bytes. An ICMP ECHO_REQUEST packet contains an additional 8 bytes worth of ICMP header followed by an arbitrary amount of data. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Examples<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>ping hostname #www.samarthya.me<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ping www.samarthya.me\nPING samarthya.me (148.72.168.185) 56(84) bytes of data.\n64 bytes from server4.hostsoch.in (148.72.168.185): icmp_seq=1 ttl=53 time=251 ms\n64 bytes from server4.hostsoch.in (148.72.168.185): icmp_seq=8 ttl=53 time=252 ms\n^C\n--- samarthya.me ping statistics ---\n2 packets transmitted, 2 received, 0% packet loss, time 2007ms\nrtt min\/avg\/max\/mdev = 250.972\/251.358\/252.325\/0.657 ms<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ping ip #148.32.168.185<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ping 148.72.168.185\nPING 148.72.168.185 (148.72.168.185) 56(84) bytes of data.\n64 bytes from 148.72.168.185: icmp_seq=1 ttl=53 time=251 ms\n64 bytes from 148.72.168.185: icmp_seq=2 ttl=53 time=251 ms\n64 bytes from 148.72.168.185: icmp_seq=3 ttl=53 time=251 ms\n^C\n--- 148.72.168.185 ping statistics ---\n3 packets transmitted, 3 received, 0% packet loss, time 2002ms\nrtt min\/avg\/max\/mdev = 251.039\/251.231\/251.438\/0.601 ms<\/code><\/pre>\n\n\n\n<p>Options available that I can use are<\/p>\n\n\n\n<figure class=\"wp-block-pullquote is-style-solid-color\"><blockquote><p>ping [-aAbBdDfhLnOqrRUvV46] [-c count] [-F flowlabel] [-i interval] [-I interface] [-l preload] [-m mark] [-M pmtudisc_option] [-N nodeinfo_option] [-w deadline] [-W timeout] [-p pattern] [-Q tos] [-s packetsize] [-S<\/p><p>sndbuf] [-t ttl] [-T timestamp option] [hop \u2026] destination<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">-c [COUNT] <\/h2>\n\n\n\n<figure class=\"wp-block-pullquote has-background has-vivid-red-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p>Stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.<\/p><cite>from official man pages<\/cite><\/blockquote><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>ping -c 10 10.0.1.11\nPING 10.0.1.11 (10.0.1.11) 56(84) bytes of data.\n64 bytes from 10.0.1.11: icmp_seq=1 ttl=64 time=0.609 ms\n64 bytes from 10.0.1.11: icmp_seq=2 ttl=64 time=0.624 ms\n64 bytes from 10.0.1.11: icmp_seq=3 ttl=64 time=0.586 ms\n64 bytes from 10.0.1.11: icmp_seq=4 ttl=64 time=0.603 ms\n64 bytes from 10.0.1.11: icmp_seq=5 ttl=64 time=0.624 ms\n64 bytes from 10.0.1.11: icmp_seq=6 ttl=64 time=0.602 ms\n64 bytes from 10.0.1.11: icmp_seq=7 ttl=64 time=0.688 ms\n64 bytes from 10.0.1.11: icmp_seq=8 ttl=64 time=0.620 ms\n64 bytes from 10.0.1.11: icmp_seq=9 ttl=64 time=0.663 ms\n64 bytes from 10.0.1.11: icmp_seq=10 ttl=64 time=0.604 ms\n\n--- 10.0.1.11 ping statistics ---\n10 packets transmitted, 10 received, 0% packet loss, time 9000ms\nrtt min\/avg\/max\/mdev = 0.586\/0.622\/0.688\/0.035 ms<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">-s [Packet Size]<\/h2>\n\n\n\n<figure class=\"wp-block-pullquote has-background has-vivid-red-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p>Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.<\/p><cite>from official man pages<\/cite><\/blockquote><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>ping -s 64 -c 2 10.0.1.11\nPING 10.0.1.11 (10.0.1.11) 64(92) bytes of data.\n72 bytes from 10.0.1.11: icmp_seq=1 ttl=64 time=0.665 ms\n72 bytes from 10.0.1.11: icmp_seq=2 ttl=64 time=0.612 ms\n\n--- 10.0.1.11 ping statistics ---\n2 packets transmitted, 2 received, 0% packet loss, time 1000ms\nrtt min\/avg\/max\/mdev = 0.612\/0.638\/0.665\/0.036 ms<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">DIG<\/h1>\n\n\n\n<p>dig is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dig www.samarthya.me\n\n; &lt;&lt;>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.6 &lt;&lt;>> www.samarthya.me\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 48626\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 1220\n;; QUESTION SECTION:\n;www.samarthya.me.              IN      A\n\n;; ANSWER SECTION:\nwww.samarthya.me.       13357   IN      CNAME   samarthya.me.\nsamarthya.me.           13357   IN      A       148.72.168.185\n\n;; Query time: 221 msec\n;; SERVER: 192.19.189.10#53(192.19.189.10)\n;; WHEN: Tue Oct 13 08:05:36 UTC 2020\n;; MSG SIZE  rcvd: 75<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">ss<\/h2>\n\n\n\n<p>Utility to investigate sockets (Socket Statistics), similar to <code>netstat<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -e --extended<\/code><\/pre>\n\n\n\n<p>Shows detailed information<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -e\nNetid State      Recv-Q Send-Q                                                                 Local Address:Port                                                                                  Peer Address:Port                \nu_str ESTAB      0      0                                                        \/run\/dbus\/system_bus_socket 14506                                                                                            * 14457                 &lt;->\nu_str ESTAB      0      0                                                                                  * 13157                                                                                            * 13158                 &lt;->\nu_str ESTAB      0      0                                                                                  * 17900                                                                                            * 17901                 &lt;->\nu_str ESTAB      0      0                                                                                  * 17937                                                                                            * 17936                 &lt;->\nu_str ESTAB      0      0                                                                                  * 17909                                                                                            * 17910                 &lt;->\nu_str ESTAB      0      0                                                                                  * 17888                                                                                            * 17887                 &lt;->\nu_str ESTAB      0      0                                                                                  * 17922                                                                                            * 17921  <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -l # All listening ports<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -l\nNetid State      Recv-Q Send-Q                                                                 Local Address:Port                                                                                  Peer Address:Port                \nnl    UNCONN     0      0                                                                               rtnl:kernel                                                                                            *                     \nnl    UNCONN     768    0                                                                            tcpdiag:kernel                                                                                            *                     \nnl    UNCONN     4352   0                                                                            tcpdiag:ss\/11768                                                                                          *                     \nnl    UNCONN     0      0                                                                               xfrm:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                            selinux:systemd\/1                                                                                         *                     \nnl    UNCONN     0      0                                                                            selinux:dbus-daemon\/492                                                                                   *                     \nnl    UNCONN     0      0                                                                            selinux:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                            selinux:dbus-daemon\/492                                                                                   *                     \nnl    UNCONN     0      0                                                                            selinux:systemd\/1                                                                                         *                     \nnl    UNCONN     0      0                                                                              audit:systemd\/1                                                                                         *                     \nnl    UNCONN     0      0                                                                              audit:auditd\/422                                                                                        *                     \nnl    UNCONN     0      0                                                                              audit:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                          fiblookup:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                          connector:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                                nft:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                             uevent:kernel                                                                                            *                     \nnl    UNCONN     0      0                                                                             uevent:systemd-udevd\/393                                                                                 *                     \nnl    UNCONN     0      0                                                                             uevent:systemd\/1                                                                                         *                     \nnl    UNCONN     0      0                                                                             uevent:-4117                                                                                             *                     \nnl    UNCONN     0      0                                                                             uevent:tuned\/907                                                                                         *                     \nnl    UNCONN     0      0                                                                             uevent:-4107                                                                                             *                     <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -s #summary<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -s\nTotal: 226 (kernel 0)\nTCP:   8 (estab 2, closed 1, orphaned 0, synrecv 0, timewait 0\/0), ports 0\n\nTransport Total     IP        IPv6\n*         0         -         -        \nRAW       0         0         0        \nUDP       3         2         1        \nTCP       7         4         3        \nINET      10        6         4        \nFRAG      0         0         0 <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -ta #all tcp ports<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -t -a\nState       Recv-Q Send-Q                                                                   Local Address:Port                                                                                    Peer Address:Port                \nLISTEN      0      128                                                                          127.0.0.1:10248                                                                                              *:*                    \nLISTEN      0      128                                                                                  *:sunrpc                                                                                             *:*                    \nLISTEN      0      10                                                                           127.0.0.1:45556                                                                                              *:*                    \nLISTEN      0      5                                                                        192.168.122.1:domain                                                                                             *:*                    \nLISTEN      0      128                                                                                  *:ssh                                                                                                *:*                    \nLISTEN      0      128                                                                          127.0.0.1:ipp                                                                                                *:*                    \nLISTEN      0      100                                                                          127.0.0.1:smtp                                                                                               *:*                    \nLISTEN      0      128                                                                          127.0.0.1:43483                                                                                              *:*                    \nESTAB       0      0                                                                         10.80.241.80:ssh                                                                                     10.52.43.159:51667                \nESTAB       0      0                                                                         10.80.241.80:ssh                                                                                     10.52.43.159:51356                \nESTAB       0      0                                                                         10.80.241.80:39224                                                                                  54.242.91.190:ssh                  \nESTAB       0      64                                                                        10.80.241.80:ssh                                                                                     10.52.43.159:52010                \nLISTEN      0      128                                                                               &#91;::]:7946                                                                                            &#91;::]:*                    \nLISTEN      0      128                                                                               &#91;::]:10250                                                                                           &#91;::]:*                    \nLISTEN      0      128                                                                               &#91;::]:sunrpc                                                                                          &#91;::]:*                    \nLISTEN      0      128                                                                               &#91;::]:ssh                                                                                             &#91;::]:*                    \nLISTEN      0      128                                                                              &#91;::1]:ipp                                                                                             &#91;::]:*                    \nLISTEN      0      100                                                                              &#91;::1]:smtp                                                                                            &#91;::]:*        <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -tl # All TCP listening ports<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -tl\nState       Recv-Q Send-Q                                                                   Local Address:Port                                                                                    Peer Address:Port                \nLISTEN      0      128                                                                          127.0.0.1:10248                                                                                              *:*                    \nLISTEN      0      128                                                                                  *:sunrpc                                                                                             *:*                    \nLISTEN      0      10                                                                           127.0.0.1:45556                                                                                              *:*                    \nLISTEN      0      5                                                                        192.168.122.1:domain                                                                                             *:*                    \nLISTEN      0      128                                                                                  *:ssh                                                                                                *:*                    \nLISTEN      0      128                                                                          127.0.0.1:ipp                                                                                                *:*                    \nLISTEN      0      100                                                                          127.0.0.1:smtp                                                                                               *:*                    \nLISTEN      0      128                                                                          127.0.0.1:43483                                                                                              *:*                    \nLISTEN      0      128                                                                               &#91;::]:7946                                                                                            &#91;::]:*                    \nLISTEN      0      128                                                                               &#91;::]:10250                                                                                           &#91;::]:*                    \nLISTEN      0      128                                                                               &#91;::]:sunrpc                                                                                          &#91;::]:*                    \nLISTEN      0      128                                                                               &#91;::]:ssh                                                                                             &#91;::]:*                    \nLISTEN      0      128                                                                              &#91;::1]:ipp                                                                                             &#91;::]:*                    \nLISTEN      0      100                                                                              &#91;::1]:smtp                                                                                            &#91;::]:*  <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ping I have used ping often but never to an extend that I could understand the complete range of options and power available at hand. ping &#8211; send ICMP ECHO_REQUEST to network hosts from &#8211; man page of ping ICMP Packet details An IP header without options is 20 bytes. An ICMP ECHO_REQUEST packet contains [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1087,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[112,116,115],"class_list":["post-1083","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-technical","tag-linux","tag-technical","tag-utils","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=1083"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1083\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/1087"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=1083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=1083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=1083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}