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

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
Text Editor for Simple Formatting
2007-08-26 10:46:00
The fmt utility is a simple text formatter. It will fill lines up to a specified character width -- default is 72. Here are some examples.Original file# more sysadThis blogis primarilya howto for UNIXsystem administration.Its articles consist of Solaris,Sybase, Oracle, and miscellaneoustips and operating system information.Here's the default of 72 characters wide.# fmt sysadThis blog is primarily a howto for UNIX system administration. Itsarticles consist of Solaris, Sybase, Oracle, and miscellaneous tips andoperating system information.Here's the same file but formatted 35 characters wide.# fmt -35 sysadThis blog is primarily a howto forUNIX system administration. Itsarticles consist of Solaris,Sybase, Oracle, and miscellaneoustips and operating systeminformation.Combine files (default width)# fmt sysad sysadThis blog is primarily a howto for UNIX system administration. Itsarticles consist of Solaris, Sybase, Oracle, and miscellaneous tips andoperating system information. Th...
More About: Text Editor , Text , Simple , Editor
Merge Lines From One or More Files
2007-08-25 11:31:00
The paste command will merge corresponding lines from one or more files. Each file is treated as a column. Here's an example of its use.# paste city cityHelena HelenaBosie BosieOlympia OlympiaSalem SalemDenver Denver# paste city stateHelena MontanaBosie IdahoOlympia WashingtonSalem OregonDenver ColoradoRedirect output to file# paste city state > CityState# more CityStateHelena MontanaBosie IdahoOlympia WashingtonSalem OregonDenver Colorado
More About: Files , Lines , Merge
Limit User's File Size -- UNIX
2007-08-23 20:18:00
If you are hurting for disk space, you might want to look into limiting the file size a user can create. Depending on the shell, you can do this by using either limit or ulimit command -- add to a user's initialization file to make permanent. Here are a few examples.# sh# ulimit -f 5000# mkfile 6m MBFile Size Limit Exceeded - core dumped# ksh# ulimit -f 5000# mkfile 6m MBFile Size Limit Exceeded(coredump)# csh# limit filesize 5m# mkfile 6m MBFile Size Limit Exceeded (core dumped)# bash# ulimit -f 5000# mkfile 6m MBFile Size Limit Exceeded (core dumped)
More About: Unix
Convert Tab to Specified Number of Spaces
2007-08-21 16:47:00
You can also use the expand utility to specify the number of spaces between a tab. See below for an illustration.Original file with tabs# cat -v -t esoftfileesoft^Iesoft^Iesoft^Iesoftesoft^ Iesoft^Iesoft^Iesoftesoft^Iesoft^Iesoft^I esoftesoft^Iesoft^Iesoft^Iesoftesoft^Ieso ft^Iesoft^IesoftConvert tab to 20 spaces# expand -20 esoftfile | cat -t -vesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftConvert tab to 10 spaces# expand -10 esoftfile | cat -v -tesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftConvert tab to 2 spaces# expand -2 esoftfile | cat -v -tesoft esoft esoft esoftesoft esoft eso...
More About: Spaces , Vert , Number
Remove Tabs From a File -- UNIX
2007-08-21 16:18:00
Occasionally, you might want to remove tabs from a file. This can be accomplished with the expand command. Here's an easy way of doing that.View tabs (^I)# cat -v -t esoftfileesoft^Iesoft^Iesoft^Iesoftesoft^ Iesoft^Iesoft^Iesoftesoft^Iesoft^Iesoft^I esoftesoft^Iesoft^Iesoft^Iesoftesoft^Ieso ft^Iesoft^IesoftView tabs (^I) removed and replaced with 5 spaces to stdout# expand esoftfile | cat -v -tesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftesoft esoft esoft esoftTabs removed and output written to file# expand esoftfile > esoftfile_notabVerify tabs removed# vi esoftfile_notabesoft esoft esoft esoft$esoft esoft esoft esoft$esoft esoft esoft esoft$esoft esoft esoft esoft$esoft esoft esoft esoft$~~~:set list
More About: Unix , File
Double Space a Single Spaced File -- UNIX
2007-08-20 14:04:00
You can use the powerful stream editor (sed) utility to convert a single-spaced file to a double-spaced file. Conversely, you can take a double-spaced file and convert it to a single-spaced file. Here's an illustration.Single -spaced to double-spaced file# more tstfileThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testNow output to stdout and tstfile1 -- double-spaced# sed G tstfile | tee tstfile1This is a testThis is a testThis is a testThis is a testThis is a testThis is a testVerify tstfile1 is double-spaced# more tstfile1This is a testThis is a testThis is a testThis is a testThis is a testThis is a testDouble -spaced to single-spaced fileNow output to stdout and tstfile2 -- single-spaced# sed 'n;d' tstfile1 | tee tstfile2This is a testThis is a testThis is a testThis is a testThis is a testThis is a testVerify tstfile2 is single-spaced# more tstfile2This is a testThis is a testThis is a testThis is a testThis is a testThis is a testExtra...To t...
More About: Space , Unix , File
Sun Studio 12 C/C++ & Fortran Compilers and Tools
2007-08-19 12:54:00
Sun is offering a free download of its Sun Studio 12 software. Provides compilers for C, C++, and Fortran for Solaris OS on SPARC and Solaris/Linux on x86/x64 platforms.Also, here's GCC For SPARC Systems 4.0.4
More About: Tools , Tran , Studio 1
Nvu or "New View" Web Authoring Application
2007-08-18 17:00:00
Nvu or "New View " is a complete and 100% open source web authoring application that I use to modify my websites. It works on Linux, Microsoft Windows, and Macintosh platforms. A great deal of technical expertise is not required to use this application.From the Nvu site: "Anyone is welcome to download Nvu at no charge, including the source code if you need to make special changes. Developers are encouraged to get involved and help make Nvu even better."
More About: Application
Specify or Report Default Permissions with umask
2007-08-17 11:14:00
The umask command can be used to specify default permissions on files you create. It also can be used to report on a file's current defaults. Here are some examples.Explanation of what the octal digits mean0 - don't restrict any permissions1 - restrict execute permissions2 - restrict write permissions4 - restrict read permissionsReport current umask setting# umaskProvides complete access to every file you create on the system to everyone.# umask 000Provides complete access to you and your group. The others (world) are excluded.# umask 007Provides complete access to you but limits group and others to read and execution.# umask 022
More About: With U , Missi
Change the Operational Status of Processors
2007-08-16 15:58:00
The psradm command can be used to change the operational status of a processor(s) in a multiprocessor system. The statuses are online, offline and no-intr. Here are a few examples.Take processors 2 and 3 offline# psradm -f 2 3Process ors 1 and 2 are not interrupted by I/O processes# psradm -i 1 2Bring a specified processor, 3, online# psradm -n 3Bring all processors online# psradm -a -n
More About: Change , Status , Operation
Log Telnet and FTP Sessions in Log File
2007-08-15 17:03:00
For security reasons, you might opt to log telnet and FTP sessions. On my box, those sessions are logged into the /var/adm/messages file. To make this change, you will have to modify the /etc/rc2.d/S72inetsvc script. Here's an example.Go to the bottom of this file and look for this line, /usr/sbin/inetd -s &# vi /etc/rc2.d/S72inetsvc.../usr/sbin/inetd -s &Change to /usr/sbin/inetd -s -t &: wq!You will have to recycle the inetd daemon.
More About: File , Telnet , Sessions
Reverse the Contents of a File
2007-08-14 13:36:00
The tail command can be used to reverse the contents of a file. Here's an example.# cat > filenameTHIS IS AN EASY WAY TO REVERSE THE CONTENT OF A FILE.THE REVERSAL WILL DO MORE THAN 10 LINES. IT WILL REVERSE THE ENTIRE FILE.EOM.# tail -r filename.EOMTHE REVERSAL WILL DO MORE THAN 10 LINES. IT WILL REVERSE THE ENTIRE FILE.THIS IS AN EASY WAY TO REVERSE THE CONTENT OF A FILE.
More About: File , Contents , Tent , The Con
Display either Files or Directories -- UNIX
2007-08-14 13:00:00
I'm revisiting the common but important ls command. Here's an easy way to show either files or directories that are in the current directory.Listing files only# ls -l | awk '{if (substr($1,1,1) == "-") {print}}'-rw-r--r-- 1 esoft other 103936 Jul 7 21:11 070707_archive.tar-rw-r--r-- 1 esoft other 348672 Jul 7 21:44 07072007_archive.tar-rw-r--r-- 1 esoft other 330240 Jul 7 21:16 07072007Y_arch.tar-rw-r--r-- 1 esoft other 482 Jun 2 19:42 crontab_file-rw-r--r-- 1 esoft other 1029 May 30 00:21 exclude-rw-r--r-- 1 esoft other 0 May 30 00:24 include-rw-r--r-- 1 esoft other 103936 Jul 7 21:14 Jul07%s070707_archive.tar...Listing directories only# ls -ld */.drwxr-xr-x 2 esoft sys 512 Oct 22 2005 default/.drwxr-xr-x 3 esoft other 512 Jul 7 20:03 esoft/.drwx------ 2 esoft staff 512 May 30 22:16 Mail/.drwxr-xr-x 2 esoft other 512 Jul 7 20:57 RAID/.drwxr-xr-x 3 esoft other 512 Jul 7 ...
More About: Unix , Display , Directories , Files , Director
More articles from this author:
1, 2, 3, 4, 5, 6, 7
81436 blogs in the directory.
Statistics resets every week.


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