Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

May 052013
 

Move forward or backward by a word in bash shell

Answer:

To move more efficiently in bash shell, you can use the following short cuts

Meta + f (move forward by a word)
Meta + b (move backward by a word)

The Meta key is the Alt key under most systems, on Mac, you would need to enable "use option as meta key" in the Terminal's Preference.

Mar 092013
 

Traceroute using TCP

Answer:

It is common now for a server to disable the ICMP and make commands like *ping* & *traceroute* failed to do the diagnostics. However, newer version of *traceroute* have a TCP mode that if you know a particular server is opening a port for TCP connection, then you can use command like..

# sudo traceroute -T www.google.com
traceroute to www.google.com (74.125.235.242), 30 hops max, 60 byte packets
 1  136.182.34.2 (136.182.34.2)  0.557 ms  0.572 ms  0.621 ms
 2  125.235.129.111 (125.235.129.111)  11.232 ms  11.242 ms  11.235 ms
 3  otejbb205.int-gw.kddi.ne.jp (124.215.194.161)  1.602 ms otejbb206.int-gw.kddi.ne.jp (124.215.194.177)  2.123 ms  2.119 ms
 4  ix-ote210.int-gw.kddi.ne.jp (106.187.6.114)  11.182 ms ix-ote210.int-gw.kddi.ne.jp (106.187.6.98)  11.156 ms ix-ote210.int-gw.kddi.ne.jp (106.187.6.114)  11.199 ms
 5  203.181.102.94 (203.181.102.94)  63.248 ms  63.272 ms  63.262 ms
 6  209.85.249.195 (209.85.249.195)  2.523 ms  2.252 ms  2.191 ms
 7  64.233.175.0 (64.233.175.0)  6.512 ms  6.448 ms  6.537 ms
 8  64.233.174.0 (64.233.174.0)  11.154 ms  11.474 ms  10.738 ms
 9  216.239.43.243 (216.239.43.243)  11.108 ms  11.713 ms  12.141 ms
10  kix01s02-in-f18.1e100.net (74.125.235.242)  11.103 ms  10.582 ms  10.882 ms
Feb 212013
 

Diagnosing network connectivity with mtr

Answer:

To check the network connectivity to a specific server, you can use the mtr command.

e.g.

# mtr --report google.com
HOST: localhost                   Loss%   Snt   Last   Avg  Best  Wrst StDev
  1. 106.187.33.2                  0.0%    10    1.3   5.3   0.6  21.4   6.7
  2. 124.215.199.121               0.0%    10    0.6   6.5   0.4  12.4   4.8
  3. otejbb206.int-gw.kddi.ne.jp   0.0%    10    2.1   3.7   2.1  12.5   3.3
  4. ix-ote210.int-gw.kddi.ne.jp   0.0%    10    2.1   6.4   2.1  15.2   4.5
  5. 203.181.102.94                0.0%    10    2.6   2.7   2.2   3.9   0.6
  6. 209.85.249.195                0.0%    10    3.2   5.3   2.3  22.8   6.6
  7. 64.233.175.0                  0.0%    10    7.0  13.5   6.8  49.8  13.7
  8. 64.233.174.0                  0.0%    10   20.0  12.7  11.1  20.0   3.0
  9. 216.239.43.145                0.0%    10   12.0  11.8  11.5  12.2   0.2
 10. kix01s01-in-f8.1e100.net      0.0%    10   11.2  11.4  11.1  11.9   0.3
Nov 262012
 

What is the meaning of kill -0?

Answer:

They are usually used to check if a given PID really exist or not (no side effect on Linux).

E.g.

# kill -0 3182
-bash: kill: (3182) - No such process
# kill -0 3184
# nothing will be returned if process really exists.