DirectoryComputersBlog Details for "My SysAd Blog"

My SysAd Blog

My SysAd Blog
My UNIX-based blog covers a collection of tips for installations, programming, scripting, configuration, SQL, maintenance, troubleshooting, and command line syntax. What exactly is UNIX? Unix stands for UNiplexed Information and Computing System--ori
Articles: 1, 2, 3, 4, 5, 6, 7

Articles

Remove the PHPSESSID From URL
2007-10-29 13:20:00
The last couple of days I have been trying to remove unsightly PHPSESSIDs from my URLs. Here's how one looked on google.com.http://www.xxxxxx.com/details_ xxxxxx__xxxxxxxxxxxxxx-.html?PHPSESSID=97 6fc83764c21749f95e831xxx6a3bxxI opened up the php.ini file in Notepad and changed the 1 to 0. I'll check later on to see if it worked.session.use_trans_sid = 0-----You can also put this in your config fileini_set('session.use_trans_sid', false);You can also modify the .htaccess file but a lot of web hosts won't let you do this type of modification. I tried.php_flag session.use_trans_sid off
Get Better Compression with bzip2 Command - UNIX
2007-10-28 15:32:00
I was trying out the bzip2 compression command. I did notice better compression rates with larger files (testing large tarballs) compared to gzip or compress. But it does take quite a bit of time to perform the compression. Here's one run I did.# ls -l mytest20.tar-rw-r--r-- 1 root other 50747392 Oct 28 23:58 mytest20.tar# gzip mytest20.tar# ls -l mytest20.tar.gz-rw-r--r-- 1 root other 9763163 Oct 28 23:58 mytest20.tar.gz# gunzip mytest20.tar.gz# bzip2 mytest20.tar# ls -l mytest20.tar.bz2-rw-r--r-- 1 root other 5757170 Oct 28 23:58 mytest20.tar.bz2To uncompress use bunzip2 or bzip2 -d# bunzip2 mytest20.tar.bz2# ls -l mytest20.tar-rw-r--r-- 1 root other 50747392 Oct 28 23:58 mytest20.tar
More About: Compression , Unix , Command , Compress
Display MAC, IP and DNS information for Windows
2007-10-22 13:05:00
I've had few questions about obtaining the MAC and IP addresses on a Windows box. Personally, I find the ipconfig command as the easiest way to get this information. Here's an example.C:Documents and Settingsesofthub>ipconfig /allWindows IP Configuration Host Name . . . . . . . . . . . . : ixxx Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Mixed IP Routing Enabled. . . . . . . . : Yes WINS Proxy Enabled. . . . . . . . : NoEthernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Intel(R) PRO/1000 CT Network Connection Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : xxx.xxx.x.x Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : xxx.xxx.xx.x DHCP Server . . . . . . . . . . . : xx...
More About: Information , Display
Modify a Command's Scheduling Priority with nice
2007-10-18 15:39:00
There may be times when you need to modify the priority of a command (process). You can do this by using the nice command. It modifies the scheduling priority of the command . 19 is the lowest priority, 1 is the highest priority, and 10 is the default. Here are a few examples.Highest priority# nice -n 1 myfindLowest priority# nice -n 19 myfindDefault priority is 10# nice myfind
More About: Nice , Modify , Modi , Priority
Check Sent Mail Status with mailq
2007-10-17 16:05:00
I had a number of users informed me that their messages were "stuck in the queue or something hanging." Their concerns were confirmed after using the mailq command. After a brief investigation, it was discovered was a small hiccup with DNS.Here's an example of the mailq output.# mailqor# mailq -v /var/spool/mqueue (19 requests)----Q-ID---- --Size-- -Priority- ---Q-Time--- ---------Sender/Recipient--------l9HDvk50 0367 5 120046 Oct 17 22:57 user1 user2l9GGhCW02706 1333 7770119 Oct 17 01:43 user3 user1l9GGhCX02706 1363 7770119 Oct 17 01:43 user4 user5...
More About: Mail , Check , Status
Recovering a Corrupted Mailbox -- UNIX
2007-10-16 14:13:00
The other day I had user who was having problems popping mail from the mail server. My first thoughts were wrong password, POP server issue or permissions. Well, it was none of the above. Then I started thinking about the mailbox itself. Here's what I found.Btw, this example is not the original user's mailbox but it should demonstrate the problem.Notice there are three lines that don't make much sense.# cd /var/mail# more user1$^$RM?T5,1@$" 0JP @ZLFrom user2 Fri Jun 29 22:51:34 2007Return-Path: Received: (from user2@localhost) by esoft (8.11.6+Sun/8.11.6) id l5TDpYJ01536 for root; Fri, 29 Jun 2007 22:51:34 +0900 (KST)Date: Fri, 29 Jun 2007 22:51:34 +0900 (KST)From: Super-User Message-Id: ......I deleted those 3 lines and re-saved the mailbox. After that, he was able to pull his mail successfully.# more user1From user2 Fri Jun 29 22:51:34 2007Return-Path: Received: (from user2@localhost) by esoft (8.11.6+Sun/8.11.6) id l5TDpYJ01536 for root; Fri, 29 J...
More About: Unix , Erin
The Popular XV Image Viewer for UNIX
2007-10-12 20:00:00
Yesterday, I received an email asking me about a versatile jpeg image viewer for UNIX. My initial thoughts were to use the common browser or the image related utilities in /usr/openwin/bin -- imagetool or snapshot.Then I started thinking about XV. XV is a popular image viewing shareware program. I have found it to be very effective at resizing screenshots, cropping, expanding, and converting images to different image formats. Personally, I've been using XV (3.10 and now 3.10a) for a number of years without complaint.I installed xv in my /opt/apps directory.# /opt/apps/xv &
More About: Unix , Popular , Image , Viewer , Image Viewer
Display a Specified Number of Lines From Multiple Files
2007-10-11 14:43:00
Here's an ad-hoc way of viewing a specified number of lines that begins with line one. In this example, the templated report has 8 lines and only its values change each day.I only want to show the first 5 lines for each file. Here's a quick and dirty way of doing that.In this template file (Mon), the values are only shown for illustration purposes .# cat MonAverage Stats: 100Hourly Stats: 4Daily Stats: 103Weekly Stats: 700Monthly Stats: 2812###############END END###############Display 5 different files and show their first 5 lines# head -5 Mon Tue Wed Thu Fri==> Mon Average Stats: 100Hourly Stats: 4Daily Stats: 103Weekly Stats: 700Monthly Stats: 2812 ==> Tue Average Stats: 102Hourly Stats: 4Daily Stats: 104Weekly Stats: 706Monthly Stats: 2822 ==> Wed Average Stats: 104Hourly Stats: 5Daily Stats: 110Weekly Stats: 730Monthly Stats: 2842 ==> Thu Average Stats: 90Hourly Stats: 200Daily Stats: 2400Weekly Stats: 4499Monthly Stats: 3006 ==> Fri Average Stats: 101Hourly Stats: 3Daily ...
More About: Files , Lines , Number
Delete Extra Spaces Between Words in a File
2007-10-05 16:01:00
I had a file peppered with extra spaces, which were between the terms (chars need to be contiguous). I could read it but it was fairly annoying. I used the tr utility to delete most of the extra spaces and then vi'ed the file to rid it of the rest. To accomplish this task, here's an example using the tr utility -- nothing fancy.Since Blogger is displaying this test file without the extra spaces, please take my word for it.# cat filenameThis is a test. We will delete the extra spaces.This can be accomplished with the UNIX tr utility.# cat filename | tr -s ' ' ' 'This is a test. We will delete the extra spaces.This can be accomplished with the UNIX tr utility.Output to newfilename# cat filename | tr -s ' ' ' ' > newfilenameView newfilename contents# more newfilenameThis is a test. We will delete the extra spaces.This can be accomplished with the UNIX tr utility.Per a reader's request, here's a picture...
More About: File , Words , Extra , Delete , Spaces
Manage Removing Directories from a Stack with popd
2007-10-04 14:00:00
I thought about adding the popd command verbiage to the last post (pushd), but I do like to keep these HOWTOs pithy. The pushd command was used to push directories onto a stack, so now I'm going to use the popd to remove directories from the stack. Again, I will use the dirs command to display the stack.# csh# dirs/usr/local/popper / /export/home/esoft/xml/XMLDIR /opt/myapps/etc# pwd/usr/local/popperRemoves /usr/local/popper directory# popd/ /export/home/esoft/xml/XMLDIR /opt/myapps/etc# dirs/ /export/home/esoft/xml/XMLDIR /opt/myapps/etc# pwd# /Removes /opt/myapps/etc directory# popd +2# / /export/home/esoft/xml/XMLDIR# dirs/ /export/home/esoft/xml/XMLDIR# pwd/
More About: Directories , Manage , Director , Dire , Rect
Manage Adding Directories to a Stack with pushd
2007-10-04 13:19:00
While working on my FreeAdLists personal project at home, I decided it was time to better manage my pwd efforts. I quickly grew weary and impatient (exacerbated by the fact I'm fighting a nasty cold and acute rhinitis) of changing directories so many darn times, so I decided it was time to use a stack (stack starts with 0). Here are few examples of the pushd and dirs commands, which pushes a directory and displays a stack, respectively.# csh# cd /# pushd `pwd`/ /export/home/esoft/xml/XMLDIR /opt/apps/apps1# pushd /usr/local/popper# dirs/usr/local/popper / /export/home/esoft/xml/XMLDIR /opt/apps/apps1# pwd/usr/local/popperSwitches between the first two directories paths# pushd/ /usr/local/popper /export/home/esoft/xml/XMLDIR /opt/apps/apps1# dirs/usr/local/popper / /export/home/esoft/xml/XMLDIR /opt/apps/apps1# pwd# /Moves /export/home/esoft/xml/XMLDIR to the top of the stack# pushd +2/export/home/esoft/xml/XMLDIR / /usr/local/popper /opt/apps/apps1# dirs/export/home/esoft/xml/XMLDI...
More About: Directories , Manage , Director , Dire , Push
Download an XML feed with wget
2007-09-30 19:20:00
For one of my projects, I was attempting to download a 70MB XML feed. Unfortunately, it was taking forever to download via HTTP and crashing my MSIE 6.0 and Firefox 2.0.0.7 browsers. I ended up using the wget utility to complete the task. Here's what I did.C:Documents and SettingsesoftDesktop>wget www.xxxx.com/partnerfeeds/esofthub%20list s/esofthub%20xmllists.xml--02:02:09-- http://www.xxxx.com/partnerfeeds/esofthub %20lists/esofthub%20xmllists.xml => `esofthub xmllists.xml'Resolving www.xxxx.com... xx.1xx.x.2xxConnecting to www.xxxx.com|xx.1xx.x.2xx|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 70,722,387 (67M) [text/xml]100%[========================== ==========>] 70,722,387 130.78K/s ETA 00:0002:08:32 (182.75 KB/s) - `esofthub xmllists.xml' saved [70722387/70722387]If you don't have wget, here's a couple site you can go to get it.Download WGET for WindowsDownload GNU WGET
More About: Feed
Ping Multiple Workstations and Mail Results
2007-09-26 18:34:00
Here's a simple Z Shell script to check for network connectivity. If you have several dozen workstations, manually pinging each one can be a laborious task. This script pings (w/2 second timeout) and mails the results to a group alias. You can automate by scheduling it with a cron job.# vi pinger.zsh#!/bin/zshlog=/tmp/log.`date '+%d%h%Y%H%M'`echo >> $logdate >> $logecho >> $logfor i in {1..30}doping wkstn$i 2if [ $? = 0 ]thenecho wkstn$i up >> $logelseecho wkstn$i down >> $logfidonecat $log | mailx -s "Workstation Status: `basename $log`" groupalias@esofthub.com#rm $log:wq!
More About: Mail , Results , Ping , Result
Use .htaccess to Deny Internet Protocol (IP) Address or Domain Name
2007-09-22 05:41:00
You can use the .htaccess file to deny sites that are wreaking havoc on your site. I have a dozen or so IPs from a couple countries that are doing just that to one of my sites. You can block specific IPs/IP blocks or deny by domain names.The first two lines (deny statements) are indicative of what I did. By the way, I don't control the main configuration of the host (server), so I had to use this file.# vi .htaccessorder allow,denyallow from alldeny from xxx.xxx.xx.xxxdeny from xxx.xxx.xxx.xxxdeny from xx.xxx.xx.deny from xxx.xx.deny from xx.:wq!
More About: Internet , Domain , Domain Name , Address , Protocol
Joining and Renaming Multiple Files Using a for loop
2007-09-19 14:00:00
I'm doing this personal project where I parsed almost 26,000 items into a particular format. I then parsed 300 of those items into a unique filename, so I ended up with 86 unique files. Lastly, I added a header and footer to each unique file and then renamed it to its original filename.# for i in `ls *_num_*`docat header $i footer > $i.$$mv $i.$$ $iecho $i donedone
More About: Files , Loop , Nami , Naming
Delete Tabs, Newlines, Carriage Returns, or Spaces from a File
2007-09-17 19:42:00
There are times when you might want to delete formatting characters from a file. The tr command does an excellent job of performing this task. Here are some examples.Remove tabs# more filenameesoft esoft esoftesoft esoft esoft# cat filename | tr -d ' 'esoftesoftesoftesoftesoftesoft# tr -d ' ' filenameRemove newlines# cat filename | tr -d ' 'esoft esoft esoftesoft esoft esoftRemove carriage returns# cat filename | tr -d ' 'Remove spaces# cat filename | tr -d " "
More About: File , Tabs , Delete , Spaces
Evaluate NFS Statistical Information with nfsstat
2007-09-14 10:17:00
The nfsstat command is used to show the statistical information of Network File System (NFS) and Remote Procedure Call (RPC). It's useful for showing NFS activity between the server and client. Here's a few examples.Show stats# nfsstatEvaluate NFS mount stats between server/client# nfsstat -mReinitialize the stats# nfsstat -z
More About: Information
My SysAd Blog Reader Appreciation Shout
2007-09-13 14:08:00
I want to thank all the "My SysAd Blog " readers that Stumble this site now and then. It's really nice to see that on a daily basis. It hasn't been Stumbled or Dugg like some of the Linux blogs but that was never the objective. But at any rate, I definitely appreciate the stumbles and thank you for helping me share the information. Maybe I will get lucky one of these days...I guess my content should improve first :)By the way, this is a terse "howto type" blog, so if you're looking for verbosity, that's another (or see man page) blog, so please checkout my technical blogroll :)Respectfully,Roy WoodTry my favorite Free browser: Get FireFoxMy Favorite Links Linux Screw The UNIX Forums Unix Guru Universe Mika's Blog PC Blade Computing Planet Sysadmin Aspiring Sysdmin Operating Systems - Unix, Linux, Mac OS X, Windows TechEd Bloggers PatchLog | patches 'n hacks @unixville The Sys Admin Tech@Sakana Alex Goncalves's Weblog Unix Admin Corner Geeky Bits Bash Shell ...
More About: Reader , Appreciation , Shout , Reci
Setup a nisplus Server and Populate its Tables
2007-09-12 16:55:00
Setup a nisplus server and then populate its tables. Here's a run on my box. Some of the non-interactive portion of the run has been omitted.# cd /etc# cp -p /etc/nsswitch.conf /etc/nsswitch.conf.sav# cp -p /etc/nsswitch.nisplus /etc/nsswitch.conf# domainname esofthub.com | tee /etc/defaultdomain# domainnameesofthub.comFor safey reasons, use copies of the /etc files. Copy those /etc files to a staging area /var/nisfiles.# cd /var# mkdir nisfiles; chmod 755 nisfiles# cd /etc# cp -p hosts rpc services netmasks networks netgroup services protocols /var/nisfiles# cd /var/nisfilesCreate empty files. It's recommended that you don't populate the contents of the local passwd and shadow files across the namespace.# touch passwd shadow ipnodes timezone bootparams group aliases auto_home auto_master ethersBourne Shell# PATH=$PATH:/usr/lib/nis; export PATHC Shell# setenv PATH ${PATH}:/usr/lib/nis# csh# setenv PATH ${PATH}:/usr/lib/nis# nisserver -v -r -d esofthub.comThis script sets up this ...
More About: Tables , Setup , Server , Pula , Serve
Forward Mail to a Different Account with .forward
2007-09-10 14:19:00
There are times when you might need to forward your mail to another email account. The .forward file is used to accomplish this task. Here are a couple examples.All email will be forwarded to this email address, esoft@esofthubInTheWoods.com.# echo "esoft@esofthubInTheWoods.com" > $HOME/.forwardOr# cat > $HOME/.forwardesoft@esofthubInTheWoods.co mcontrol ^d
More About: Mail , Account , Forward , Diff
Output Strings in Lowercase -- UNIX
2007-09-08 16:23:00
I should have done this post earlier when I was talking about capitalizing strings. I just forgot. Anyways, here's an easy way to output strings as lowercase.# cat uppercasefile | tr "[:upper:]" "[:lower:]"this file's contents are in uppercase but its output should be lowercased# tr "[:upper:]" "[:lower:]" uppercasefilethis file's contents are in uppercasebut its output should belowercased# cat uppercase | tr '[A-Z]' '[a-z]'this file's contents are in uppercase but its output should be lowercased# tr '[A-Z]' '[a-z]' uppercasefilethis file's contents are in uppercase but its output should be lowercasedOutput lowercase strings to file# tr '[A-Z]' '[a-z]' uppercasefile > outputfile_lower# date | tr "[:upper:]" "[:lower:]"sat sep 8 23:24:20 kst 2007
More About: Unix , Strings , Tring
Traverse an Argument List using shift Command
2007-09-07 12:05:00
You can move through an argument list using the shift command. Here's an example using an inline while loop and and an inline for loop.# shThe while loop# set M Y S Y S A D B L O G# while [ $# -gt 0 ]> do> echo $*> shift> doneM Y S Y S A D B L O GY S Y S A D B L O GS Y S A D B L O GY S A D B L O GS A D B L O GA D B L O GD B L O GB L O GL O GO GGThe for loop# set M Y S Y S A D B L O G# for i in $*> do> echo $*> shift> doneM Y S Y S A D B L O GY S Y S A D B L O GS Y S A D B L O GY S A D B L O GS A D B L O GA D B L O GD B L O GB L O GL O GO GG
More About: List , Command , Shift
Print a File in Landscape Mode via Command Line
2007-09-05 11:40:00
I was asked how to print a file in landscape mode via the command line. I haven't done that in awhile, so I had to delve into my old notes. Here's the syntax.# /usr/lib/lp/postscript/postprint -pland filename | lp
More About: Landscape , File , Mode , Print , Line
Set File or Directory Access Control List with setfacl
2007-09-04 17:06:00
The setfacl command is used to add, modify, delete an ACL entry (or entries) or replace the entire Access Control List (ACL) on a file or directory. Here are a few examples.Replaces the entire ACL via man page--setfacl -s user:esoft:rwx,user::rwx,group::rw-,mask: r--,other:--- testfileor its octal equivalent--setfacl -s user:esoft:7,user::7,group::6,mask:4,othe r:0 testfileBefore changing ACL# getfacl testfile# file: testfile# owner: root# group: otheruser::rw-group::r-- #effective:r--mask:r--other:r--# ls -l testfile-rw-r--r-- 1 root other 0 Sep 4 23:26 testfileAfter changing ACL# setfacl -s user:esoft:rwx,user::rwx,group::rw-,mask: r--,other:--- testfile# getfacl testfile# file: testfile# owner: root# group: otheruser::rwxuser:esoft:rwx #effective:r--group::rw- #effective:r--mask:r--other:---# ls -l testfile-rwxr-----+ 1 root other 0 Sep 4 23:27 testfileSame as above but in octal# rm testfile# touch testfile# ls -l ...
More About: File , Directory
Get the Access Control List on a File or Directory
2007-09-03 17:41:00
The getfacl command is used to obtain the filename, file owner, file group owner, and its Access Control List or ACL. It will display the ACL for a regular file or a directory. Here are some examples of its use.On a file# getfacl newcron# file: newcron# owner: esoft# group: staffuser::rw-group::r-- #effective:r--mask:r--other:r--On a directory# getfacl MyDir# file: MyDir# owner: root# group: otheruser::rwxgroup::r-x #effective:r-xmask:r-xother:r-x
More About: File , Directory
Free Virtual Network Computing Remote Control Software
2007-09-01 19:12:00
Virtual Network Computing (VNC) is a client/server software package that allows remote access to graphical desktops. Here's some information about VNC at TightVNC.org. The downloads are free under the GNU General Public License and available on several platforms.
More About: Software , Remote Control , Free
Send Network Packets to a Host with spray
2007-08-31 16:26:00
The spray command is used to send packets to a hostname, URL, or IP. It reports how many packets were received and transfer rate. However, spray can NOT be used as a network benchmark because it uses unreliable connectionless protocols such as UDP. Here's an example of its use on my box.# spray esoftsending 1162 packets of length 86 to esoft... 754 packets (64.888%) dropped by esoft 26 packets/sec, 2317 bytes/sec
More About: Network , Host , Send , Spray , Pray
Troubleshooting a Network with the Snoop Utility
2007-08-30 10:55:00
One of the most useful networking utilities is the snoop command. It is used to capture and inspect network packets. Here are some examples of its use.Snoop a network in the promiscuous mode (captures and displays all packets as received)# snoopUsing device /dev/hme (promiscuous mode)192.168.1.26 -> esoft TELNET C port=2319 esoft -> 192.168.1.10 TELNET R port=2319 Using device /dev/hm192.168.1.26 -> esoft TELNET C port=2319Snoop a particular host# snoop client-10Prints detailed ETHER, IP and TCP header data (a lot of data)# snoop -vSnoop between two hosts# snoop client-10 client-11Capture snoop output to a file (binary format)# snoop -o snoop_captureRead captured snoop output from file# snoop -i snoop_capturePrints summary mode# snoop -V
More About: Network , Utility , Troubleshooting , Troubleshoot
Date Command in Debian Linux
2007-08-29 12:52:00
Here are some interesting uses of the date command in Debian Linux by Mary M. Chaddock, GSEC, GCUX. She is a Network Security Administrator for Abilene Christian University in Texas. Thanks Mary for the nice email, and of course, the date tip.Mary said, "Specifically, I often have a need to convert log dates or search logs for specific dates when the log date is in epoch format."Displays the current date'date +%s'Gives date two weeks ago'date +%s --date=-2week'Converts an epoch timestamp'date --date=@1187103930'
More About: Command , Debian Linux
System Activity Reporter Command Monitors CPU, Disk and Virtual Memory
2007-08-27 13:35:00
The system activity reporter or sar command is useful in reporting system resource utilization. It can report on CPU, disk, and virtual memory use. Here are some examples.Three samples for every 5 secondsFor CPU utilization# sar 5 3For disk utilization# sar -d 5 3For virtual memory utilization#sar -g 5 3
More About: System , Memory , Disk , Virtual , Reporter
More articles from this author:
1, 2, 3, 4, 5, 6, 7
47341 blogs in the directory.
Statistics resets every week.


Contact | About
© Blog Toplist 2008 - Supported by Web Catalog - SEO by FeWorks
eXTReMe Tracker