Oct 09

Ever wondered how one is attached to things that even though you might postpone/forget it, someday or the other you get a chance to get back on things you love. Yes guys ! I am back in blogosphere.

Revamping a lot of stuff in office and some exciting things are shaping up.

For starters, I have been invited in a number of colleges this month to speak on LAMP architecture in an Enterprise, Ethical Hacking, FOSS in careers.

I am loving this ! :D

Sep 10

Frequently while searching for strings or patterns in a log file in a Linux/Unix server, you will come across a situation where the log files have been compressed by logrotate.

root@spartan [~]# ls -al /var/log/exim_mainlog*
-rw-r—–    1 mailnull mail     190715738 Sep 10 08:18 /var/log/exim_mainlog
-rw-r—–    1 mailnull mail     77593857 Sep  7 04:06 /var/log/exim_mainlog.1.gz
-rw-r—–    1 mailnull mail     88615088 Aug 31 04:05 /var/log/exim_mainlog.2.gz
-rw-r—–    1 mailnull mail     72980206 Aug 24 04:07 /var/log/exim_mainlog.3.gz

Now if you want to search within the compressed files one would have to un-compress using gunzip or tar and use grep.

Better way is to use `zgrep`.

root@spartan [~]# zgrep ’string’ /var/log/exim_mainlog.1.gz

This would search for the pattern or string within the compressed archive without the need of un-compressing it. Sweet :D

Additional note, zgrep is available in the gzip package,

root@spartan [~]# whereis zgrep
zgrep: /usr/bin/zgrep /usr/share/man/man1/zgrep.1.gz

root@spartan [~]# rpm -qf /usr/bin/zgrep
gzip-1.3.3-13.rhel3

Aug 07

We have a box running Ubuntu Hardy 8.04 in office. The box began acting weird with random reboots and display problems but that’s another story.

While moving around logged in from the virtual console, I could see a lot of un-necessary services were started in runlevel 2 ( default runlevel in Ubuntu which boots to X Window System ).

Now, Redhat/CentOS has chkconfig –list and chkconfig servicename off to check and disable services.

Ubuntu has a package sysv-rc-conf which can be installed via APT,

sudo apt-get install sysv-rc-conf

sysv-rc-conf is a ncurses based program which allows to enable/disable services in all runlevels.

Enabling and disabling services becomes a walk in the park which would otherwise involve removing symbolic links from the respective /etc/rc.d/ runlevel directory.

Update: Alternative way to disable services is to use the default update-rc.d script.

update-rc.d cups remove

This will remove the symbolic links corresponding to the service name from /etc/rc.d/ directories from all run levels.