≡ Menu

apple os x

HowTo: Iterate Bash For Loop Variable Range Under Unix / Linux

How can I iterate bash for loop using a variable range of numbers in Unix or Linux or BSD or Apple OS X operating systems?
[click to continue…]

Howto: Send The Content Of a Text File Using mail Command In Unix / Linux

I'd like to send an email with the content of a text file using mail command in Unix / Linux operating system. How do I do it?
[click to continue…]

UNIX: Recursive Delete Directory / Files

How do I delete (remove) a directory called $HOME/foo and its content including all files and sub-directories under Unix like operating systems? What is the best way to completely delete /tmp/foo/ with all it's content?
[click to continue…]

OpenSSH: ssh-add / ssh-agent Command Set Maximum Lifetime In Seconds

I'm using a Mac OS X and combination of ssh-agent+ssh-add to adds RSA or DSA identities to the authentication agent. ssh-agent provides me a secure way of storing the private key. However, I'd like to expire identities added to the agent within half an hour. How do I set lifetime of identities added to the agent under Unix / Linux / BSD / Apple OS X operating systems?
[click to continue…]

Linux / Unix: scp Copy All Hidden Dot Files

I'm using scp command to copy files from one server to another server. The problem is that I'm unable to copy all hidden files (such as .bash_history). How do I copy hidden files using the scp command under Unix like operating systems?
[click to continue…]

Carry Private SSH RSA / DSA Key For Connection Using Unix / Linux Shell Script

How do I add my RSA or DSA keyfile in shell script itself for the connection so that I need to carry only one file on my USB pen drive instead of $HOME/.ssh/id_rsa file under Unix / Linux operating systems?
[click to continue…]

Linux / Unix: Disable OpenSSH Host Key Checking

I've a remote Unix server running with OpenSSH remote login service. The openssh is configured for passwordless login using ssh keys. Our ISP allows to boot all Linux servers into the rescue mode. It allow us to bring a server online remotely in order to troubleshoot system problems that would normally only be resolved by an OS Reload (such as accidentally deleting files or wrong firewall configurations blocking ssh access). When server boots into a remote rescue mode I can connect using SSH. They SSH keys will not be the same in the rescue mode so I get key mismatch messages as SSH keys are re-generated on each boot:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
e1:9b:5c:16:a6:cd:11:10:3a:cd:1b:a2:16:cd:e5:1c.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for www.cyberciti.biz has changed and you have requested strict checking.
Host key verification failed.

How do I ignore OpenSSH hos key checking from my Apple OS X laptop while login using the ssh?
[click to continue…]

Linux: Neighbour Table Overflow Error and Solution

I setup a CentOS Linux based Linux server running as a gateway and firewall server. However, I'm getting the following messages in the /var/log/messages log file:

Dec 20 00:41:01 fw01 kernel: Neighbour table overflow.
Dec 20 00:41:01 fw01 last message repeated 20 times

OR


Dec 20 00:41:01 fw03 kernel: [ 8987.821184] Neighbour table overflow.
Dec 20 00:41:01 fw03 kernel: [ 8987.860465] printk: 100 messages suppressed.

Why does kernel throw "Neighbour table overflow" messages in syslog? How do I fix this problem under Debian / CentOS / RHEL / Fedora / Ubuntu Linux?
[click to continue…]

Linux / Unix: Sort Specific Field or Column

How do I sort output of find . -type f -iname "pattern*" -ls command by seventh column in Linux? Sample input:

7782638 15084 -rw-r--r-- 1 tom tom 15422474 Aug 1 2011 ./logserver42/2011/hsbcreports_201107.html
7782637 14504 -rw-r--r-- 1 tom tom 14830464 Jul 1 2011 ./logserver42/2011/hsbcreports_201106.html
7782643 14408 -rw-r--r-- 1 tom tom 14730488 Dec 1 2011 ./logserver42/2011/hsbcreports_201111.html
7782640 19656 -rw-r--r-- 1 tom tom 20101379 Oct 1 2011 ./logserver42/2011/hsbcreports_201109.html
7782634 17588 -rw-r--r-- 1 tom tom 17985190 Apr 1 2011 ./logserver42/2011/hsbcreports_201103.html
7782641 20796 -rw-r--r-- 1 tom tom 21263382 Nov 1 2011 ./logserver42/2011/hsbcreports_201110.html
7798789 13296 -rw-r--r-- 1 tom tom 13590695 Mar 1 2012 ./logserver42/2012/hsbcreports_201202.html
7798788 12220 -rw-r--r-- 1 tom tom 12495686 Feb 1 2012 ./logserver42/2012/hsbcreports_201201.html
5701709 1648 -rw-r--r-- 1 tom tom 1681600 Nov 1 11:14 ./logserver42/2012/hsbcreports_201210.html
7798802 8944 -rw-r--r-- 1 tom tom 9138603 Jun 1 10:13 ./logserver42/2012/hsbcreports_201205.html
5701710 648 -rw-r--r-- 1 tom tom 657811 Nov 10 11:13 ./logserver42/2012/hsbcreports_201211.html
7798805 7360 -rw-r--r-- 1 tom tom 7523891 Sep 1 10:11 ./logserver42/2012/hsbcreports_201208.html
7323999 776 -rw-r--r-- 1 tom tom 787924 Jun 12 2006 ./logserver42/2006/hsbcreports_200605.html
7324001 140 -rw-r--r-- 1 tom tom 139058 Aug 22 2006 ./logserver42/2006/hsbcreports_200607.html
7324000 44 -rw-r--r-- 1 tom tom 41447 Jun 12 2006 ./logserver42/2006/hsbcreports_200606.html
7324003 1972 -rw-r--r-- 1 tom tom 2014614 Oct 1 2006 ./logserver42/2006/hsbcreports_200609.html
7356496 3136 -rw-r--r-- 1 tom tom 3205737 Dec 1 2007 ./logserver42/2007/hsbcreports_200711.html

I need the following output:

7324000 44 -rw-r--r-- 1 tom tom 41447 Jun 12 2006 ./logserver42/2006/hsbcreports_200606.html
7324001 140 -rw-r--r-- 1 tom tom 139058 Aug 22 2006 ./logserver42/2006/hsbcreports_200607.html
5701710 648 -rw-r--r-- 1 tom tom 657811 Nov 10 11:13 ./logserver42/2012/hsbcreports_201211.html
7323999 776 -rw-r--r-- 1 tom tom 787924 Jun 12 2006 ./logserver42/2006/hsbcreports_200605.html
5701709 1648 -rw-r--r-- 1 tom tom 1681600 Nov 1 11:14 ./logserver42/2012/hsbcreports_201210.html
7324003 1972 -rw-r--r-- 1 tom tom 2014614 Oct 1 2006 ./logserver42/2006/hsbcreports_200609.html
7356496 3136 -rw-r--r-- 1 tom tom 3205737 Dec 1 2007 ./logserver42/2007/hsbcreports_200711.html
7798805 7360 -rw-r--r-- 1 tom tom 7523891 Sep 1 10:11 ./logserver42/2012/hsbcreports_201208.html
7798802 8944 -rw-r--r-- 1 tom tom 9138603 Jun 1 10:13 ./logserver42/2012/hsbcreports_201205.html
7798788 12220 -rw-r--r-- 1 tom tom 12495686 Feb 1 2012 ./logserver42/2012/hsbcreports_201201.html
7798789 13296 -rw-r--r-- 1 tom tom 13590695 Mar 1 2012 ./logserver42/2012/hsbcreports_201202.html
7782643 14408 -rw-r--r-- 1 tom tom 14730488 Dec 1 2011 ./logserver42/2011/hsbcreports_201111.html
7782637 14504 -rw-r--r-- 1 tom tom 14830464 Jul 1 2011 ./logserver42/2011/hsbcreports_201106.html
7782638 15084 -rw-r--r-- 1 tom tom 15422474 Aug 1 2011 ./logserver42/2011/hsbcreports_201107.html
7782634 17588 -rw-r--r-- 1 tom tom 17985190 Apr 1 2011 ./logserver42/2011/hsbcreports_201103.html
7782640 19656 -rw-r--r-- 1 tom tom 20101379 Oct 1 2011 ./logserver42/2011/hsbcreports_201109.html
7782641 20796 -rw-r--r-- 1 tom tom 21263382 Nov 1 2011 ./logserver42/2011/hsbcreports_201110.html

[click to continue…]

Bash Shell: Find Out If a Variable Is Set or Not

How do I check if a bash shell variable called $input is defined or not under BSD / Apple OS X / Unix / Linux like operating systems?
[click to continue…]