This blog covers Unix system administration HOWTO tips for using inline for loops, find command, Unix scripting, configuration, SQL, various Unix-based tools, and command line interface syntax. The Unix OS supports tasks such as running hardware, device drivers, peripherals and third party applications. Share tips/comments. Read the comments. But most importantly: Read Disclaimer - Read Disclaimer.
Friday, December 29, 2006
Quick and Dirty Setup of the Internet
Here's what I did.
Modified the /etc/resolv.conf file. I put these entries into it.
#vi /etc/resolv.conf
nameserver 168.126.63.1
nameserver 168.126.63.2
:wq! (saves and quits vi)
Modified the /etc/nsswitch.conf file. I added the dns entry into it.
#vi /etc/nsswitch.conf
hosts: nis files dns [NOTFOUND=return]
:wq! (saves and quits vi)
Sunday, December 24, 2006
How to Check email via Command Line
Here's how to do that.
--If you type "?", you will get a list of help messages. For example, if you want to save all messages to a file, type the following:
#mailx
(Type "?" for help)
s * saveallmail (hit enter)
quit (hit enter to exit mail)
Troubleshooting with mailx -v (Sendmail and Mail)
#mailx -v supportATtopbloglists.com (hit enter)
Subject: Top Blog Lists (hit enter)
Top Blog Lists has hit 100 members in less than 3 weeks. Join other successful bloggers at http://www.topbloglists.com (hit enter)
. (hit enter)
EOT
--Watch the output scroll--
mailx coupled with -v are very useful because they provide the verbose output of Sendmail. It shows the connection, session and disconnect. It's very useful for troubleshooting purposes (e.g. viewing IPs, DNS, mail configurations, version numbers, etc).
Attach a File to Message via Command Line
Here's an example of an email attachment.
# uuencode my_binaryfile1 | mailx -s "Email binary as attachment" esofthub@esofthub.com
For multiple attachments, I use a mail client such as dtmail, Netscape or FireFox. But I've seen this done too.
# uuencode my_binaryfile1 my_binaryfile2 | mailx -s "Email binary as attachment" esofthub@esofthub.com
For NON-binary type files
Please note the ~r (tilde command followed by r)
# mailx esofthub@esofthub.com (hit enter)
Subject: End of Week Status Report (hit enter)
~rendofweekstatus.dat (hit enter)
~. (hit enter)
EOT
The above procedure (non-binary) works great for inline text files.
Also,
# cat endofweekstatus.dat | mailx -s "End of Week Status Report" esofthub@esofthub.com
Set up a Cron Job and Email the Results
# crontab -e (crontab editor)
45 06 * * 05 sort /home/esofthub/endofweeklystatus.dat | mailx -s "End of Week Status Report" aliasedgroup
:wq! (save results)
The minute is 45
The hour is 06
The day of the month is any (*)
The month of the year is any (*)
The day of the week (05) is Friday
Wednesday, December 13, 2006
Convert a ISO Standard to DOS and vice versa
Occasionally, there is a need to convert a UNIX formatted file (or files) to a DOS format and vice versa. As a unix system administrator, I’ve performed this task many times. In the examples below, I’ll demonstrate the task singly and then multiple using an inline loop.
Convert an ISO Standard formatted file to DOS standard formatted file
# csh
# unix2dos filenameUNIX > filenameDOS
# foreach i (*)
? unix2dos $i > $i.$$
? mv $i.$$ $i
?end
Convert a DOS formatted file to ISO standard formatted file
# dos2unix filenameDOS > filenameUNIX
# foreach i (*)
? dos2unix $i > $i.$$
? mv $i.$$ $i
?end
Saturday, December 09, 2006
How to Capture xterm/cmdtool Output
#script -a /tmp/outputfilename (whatever is typed after this command execution is captured)
When you are done, enter control d to terminate the capture process.
How to Change the Values of the PROM (EEPROM)
#eeprom (gives you a default listing)
e.g.
#eeprom security=command
enter new prom password (it prompts you for a new password)
To remove the OBP password
#eeprom security=noneopen
Sunday, December 03, 2006
Append an Entry to a File
#echo "138.123.34.12 myhost" >> /etc/hosts
#cat >> /etc/hosts
"138.123.34.12 myhost" (hit enter)
then execute a control d
Display Only Unique Lines From a File
#uniq filename
e.g. #uniq filename > outputfile (All of the duplicate lines are filtered out. outputfile only has unique lines in it.)