MAC OS X, Linux, Windows and other IT Tips and Tricks

26 Mar 13 resolving addresses starting with /etc/hosts

as most Linux administrators know if you type the command, for example:
You get the resolving of the address ONLY through DNS resolving and NOT using the local /etc/hosts file first.
Of course if you use the command:
You get to see the IP which with be tried to be resolved first through local /etc/hosts file and then the resolver(DNS request).
But this might no be so practical if done in a script.
Here is where the command getent comes to the rescue.
So to insure that the name resolving starts with using the /etc/hosts and then DNS if not found in /etc/hosts, the command would look like this.
getent ahosts
Note: If you look in man page of getent you won’t see this information though..:-).

16 Feb 12 Forcing a keep-alive in ssh sessions

The following configuration will prevent an SSH session to terminate automatically upon long time of inactivity:

File: ~/.ssh/config
Host *
Protocol 2
TCPKeepAlive yes
ServerAliveInterval 60
StrictHostKeyChecking = no

19 Sep 11 Change the bash session timeout

Sometimes we need to have a longer bash session timeout value to be able to stay logged-in while nothing is happening on the terminal. Here is the setting you can include in your .bashrc or .profile files:
export TMOUT=0
This will set the shell session to have no timeout duration.
export TMOUT=345600
This will set the timeout duration to four days (345600 seconds).

14 Feb 10 Replacing the missing ‘tac’ command in MAC OS X

After looking into Fink Command and Porticus I could not find the GNU command ‘tac’ for writing bash scripts.
So I found these replacements which works well from the following link (Thanks guys :-))

Normal use of tac: .....| tac |.......

Replacement Nr. 1
.....| awk '{print NR,$0}' | sort -nr | sed 's/^[0-9]* //' | .......
Replacement Nr. 2
tac () {
awk '1 { last = NR; line[last] = $0; } END { for (i = last; i > 0; i--) { print line[i]; } }'