Duplicate Line Finder


Have you ever duplicated a cron entry, or just wanted to find duplicate lines in a file.


Here is a simple one liner, which shows all lines which occur more than once in a file or standard output.


sort cronfile.223 | uniq -c | awk ' $1 != 1 '

So to check that cron directly – just do this:

crontab -l | uniq -c | awk ' $1 != 1 '


[tags]UNIX, awk, script, uniq, Unix Coding School[/tags]

Legato Networker Restore


You want to perform a restore from a legato networker backup server.
Also called NSR backup system


To restore from an NSR (networker) backup system, just run recover.

It is best if you cd into the required directory first.


cd /var/www/httpd

It will list your last back ups with dir. You can type help for more info.

Or just add, then when done – type recover.

dir shows if the tape containing your backup, is online or not.


[tags]NSR, Netwoker, Net backup, Legato, Unix Coding School[/tags]

mysql API socket connection


Sometimes you need to connect to mysql server with a UNIX socket, rather than a Port.

Generally this is when running multiple versions, on a box when you do not want to
or cannot connect to multiple ports.


If you want to connect to the mysql server from the command line, you can use -S.

Or within Perl – append mysql_socket to the dsn


mysql -uUSER -pPASSWORD -S /tmp/mysql.sock


Where your socket is /tmp/mysql.sock


[tags]MySQL, Socket, UNIX, Perl, Perl Coding School[/tags]

Check NSR Legato Networker Backups


You want to view the back ups performed via Legato Networker NSR.


Use mminfo – media manager for NSR. It can show which filesystems were backed up,
when they were backed up, to which tapes and the retension period.


mminfo -ot -s SERVER -c CLIENT -q 'savetime>=last week' -r 'volume,client,savetime(18),ssid,name,written,pool'

mminfo -ot -s SERVER -c CLIENT -q 'savetime>=last week' -r 'volume,client,savetime(18),ssid,name,written,pool,ssretent'


For more information on available options, do a man mminfo

[tags]NSR, Backups, Legato, mminfo, Unix Coding School[/tags]

RISC System 6000 Boot LEDs


Your RS6000 ain’t booting. 🙂 Or you are just interested what the LEDs mean.


See Example


  1. Power On [LED 100 – 199]
  2. BIST [LED 100 – 199]
  3. POST [LED 201 – 298]
  4. Load Kernel [LED 299]
  5. Configuration [LED 500 – 999]
  6. INIT [LED 553]

init than loads /etc/inittab services – then /sbin/rc.boot (phase 3 of system boot),
/etc/rc (startup shell script), subsystems (cron, qdaemon, tcpip), getty (enable terminals)


[tags]RISC System bootup LEDs, AIX startup sequence, Unix Coding School[/tags]

Clearing an AIX Print Queue


You have jobs stuck in the print queue. You want to clear the queues and remove all jobs.


You have to stop all processes and remove the files from spooling directories.

Probably worth taking a backup of these files first. 🙂 All at own risk.



stopsrc -cs qdaemon # bring down qdaemon and clear qdforks.
stopsrc -s lpd


rm /etc/qconfig.bin # compiled /etc/qconfig


rm /var/spool/lpd/qdir/* # queue requests; JDF


rm /var/spool/lpd/stat/* # info on status of devices


rm /var/spool/lpd/pio/msg* # error message files.


rm /var/spool/qdaemon # temp copies of queue jobs


rm /var/spool/lpd/* # temp copies of remote jobs


ps -ef | grep pio # kill any of these processes; look for piobe, pioformat, pioout


ps -ef | grep qd # kill any of these processes; look for qdforks.


startsrc -s qdaemon # restarting qdaemon
startsrc -s lpd # restarting lpd


lssrc -s qdaemon #look for active
ps -ef | grep qdaemon
lssrc -s lpd # look for active
ps -ef | grep lpd


ps -ef | grep srcmstr # if there are 2 running, kill -9 one of them with higher PID.


As a last resort – reboot


[tags], Unix Coding School[/tags]

DNS, Sendmail and Building Linux


Have been aware of DNS and sendmail for over 10 years, but never really dabbled.


Hit a lot of issues, mainly with dodgy clients – like outlook (ended up moving over completely to mozilla’s thunderbird email client!). Also with port forwarding and firewall, default routes, etc.

To set it all up these were my steps:

1) Build RH Linux server with fedora core 4 (5 is out now too I think).
2) Ensure BIND was installed. yum is your friend! 🙂 Do yum –help as root.
3) Edit /etc/named.conf – add my zone file. Always make a bu: cp -i /etc/named.conf /etc/named.conf.$(date +%j)
4) Copied localdomain.zone to puterpet.zone # this domain is retired now. 🙂
5) Modified puterpet.zone to include my info: SOA (start of authority) – in my case I said zion.puterpet.com as this then relates to the ip of broadband router. Bit backward in logic, specify your DNS server with a name registered in your DNS server! 🙂 Then I created an A record and NS for zion; CNAME for www to zion and CNAME for mail; lastly an MX record for mail. I’ll happily supply my zone file if someone wants a peek. 🙂
6) Register domain name with www.domaincentral.com.au – $12.50 a year! 🙂 Give it the ip of my DNS server – which is actually the broadband router, with port 53 forwarded to my RH Linux box. domaincentral have been great (I’ve now got 3 domains with them). www.puterpet.com – this one www.techie-blogs.com and darlingranges.com (still setting this up).
7) Setup port forwarding on broadband router, then fire up named and it was all good. Setup up virtual hosts (www.puterpet.com and mail.puterpet.com) in that domain. Now can setup any mail account or host in that domain, it is just beautiful! 🙂
8) Installed/updated sendmail. Especially like watching sendmail’s incoming and outgoing messages. 🙂
9) Edit /etc/mail/sendmail.mc – which is a macro config file that gets fed into m4 (macro language). Had to update m4, etc as kept breaking during conversion.
10) Edited various other files under /etc/mail – such as relay_domains (allow email from puterpet.com, etc); aliases …
12) Installed dovecot – which services POP and SMTP requests.
13) Created some accounts to handle mail – sales; enquiries, etc.
14) Modified my apache confs to handle and redirectmatch to new domain.



[tags]sendmail, DNS, POP, SMTP, Red Hat Linux, Unix Coding School[/tags]